Esempio n. 1
0
    def _init_from_body_ack(self, body):
        # N2H
        assert isinstance(body, dict), repr(body)
        _result = self.ack_result = body['result']

        uuid = None
        if _result == 'ok':
            self.ack_username = str(body['username'])  # forcibly de-unicode
            try:
                uuid = UUID(body['uuid'])
            except:
                logger.error('In LoginMessage, received invalid UUID: %r',
                             body)

        self.ack_host_uuid = uuid
        self.ack_groups = \
            [UserGroup.from_json(gr)()
                 for gr in body['ack_groups']] if 'ack_groups' in body \
                                               else []

        try:
            self.ack_ssl_cert = \
                crypto.load_certificate(crypto.FILETYPE_PEM,
                                        body['SSL certificate'])
        except:
            self.ack_ssl_cert = None
Esempio n. 2
0
File: login.py Progetto: shvar/redfs
    def _init_from_body_ack(self, body):
        # N2H
        assert isinstance(body, dict), repr(body)
        _result = self.ack_result = body["result"]

        uuid = None
        if _result == "ok":
            self.ack_username = str(body["username"])  # forcibly de-unicode
            try:
                uuid = UUID(body["uuid"])
            except:
                logger.error("In LoginMessage, received invalid UUID: %r", body)

        self.ack_host_uuid = uuid
        self.ack_groups = [UserGroup.from_json(gr)() for gr in body["ack_groups"]] if "ack_groups" in body else []

        try:
            self.ack_ssl_cert = crypto.load_certificate(crypto.FILETYPE_PEM, body["SSL certificate"])
        except:
            self.ack_ssl_cert = None
Esempio n. 3
0
    def _init_from_body(self, body):
        # N2H
        assert 'files' in body, \
               repr(body)

        if 'dataset' in body:
            self.dataset = \
                AbstractBasicDatasetInfo.from_json(body['dataset'])()

        if 'ugroup' in body:
            self.ugroup = UserGroup.from_json(body['ugroup'])()

        self.sync = bool(int(body['sync']))

        _files_pre = {LocalPhysicalFileState.from_json(
                              json.loads(file_key))(): blocks
                          for file_key, blocks in body['files'].iteritems()}
        self.files = {file: [Chunk.Block.from_json(ser_block, file)()
                                  for ser_block in blocks]
                          for file, blocks in _files_pre.iteritems()}

        if 'want_restore' in body:
            self.wr_uuid = TransactionUUID(body['want_restore'])