def read_obj(self, uuid, obj_type=None): ok, objs = self._cassandra.read(obj_type or self.obj_type, [uuid]) if not ok: self._logger.error('Cannot read %s %s, error %s' % (obj_type, uuid, objs)) raise NoIdError(uuid) return objs[0]
def read_obj(cls, uuid, obj_type=None): ok, objs = cls._cassandra.object_read(obj_type or cls.obj_type, [uuid]) if not ok: cls._logger.error( 'Cannot read %s %s, error %s' % (obj_type, uuid, objs)) raise NoIdError(uuid) return objs[0]
def read_obj(self, uuid, obj_type=None): method_name = "_cassandra_%s_read" % (obj_type or self.obj_type) method = getattr(self._cassandra, method_name) ok, objs = method([uuid]) if not ok: self._logger.error( 'Cannot read %s %s, error %s' % (obj_type, uuid, objs)) raise NoIdError('') return objs[0]
def read_vnc_obj(cls, uuid=None, fq_name=None, obj_type=None): if uuid is None and fq_name is None: raise NoIdError('') obj_type = obj_type or cls.obj_type if uuid is None: if isinstance(fq_name, basestring): fq_name = fq_name.split(':') uuid = cls._cassandra.fq_name_to_uuid(obj_type, fq_name) obj_dict = cls.read_obj(uuid, obj_type) obj = cls.vnc_obj_from_dict(obj_type, obj_dict) obj.clear_pending_updates() return obj
def read_vnc_obj(self, uuid=None, fq_name=None, obj_type=None): if uuid is None and fq_name is None: raise NoIdError('') obj_type = obj_type or self.obj_type if uuid is None: if isinstance(fq_name, str): fq_name = fq_name.split(':') uuid = self._cassandra.fq_name_to_uuid(obj_type, fq_name) obj_dict = self.read_obj(uuid, obj_type) cls = obj_type_to_vnc_class(obj_type, __name__) obj = cls.from_dict(**obj_dict) obj.clear_pending_updates() return obj