def update(res_type, obj): if not obj.uuid: obj.uuid = VncApiMock.name_to_id(res_type, obj.name) if obj.uuid is None: raise NoIdError("Object does not exist.") if obj.uuid not in DBMock.get_dict(res_type.replace('-', '_')): raise NoIdError("Object does not exist.") DBMock.update(res_type.replace('-', '_'), obj.uuid, VncApiMock.object_to_dict(obj))
def update(res_type, obj): if not obj.uuid: obj.uuid = VncApiMock.name_to_id(res_type, obj.name) if obj.uuid is None: raise NoIdError("Object does not exist.") if obj.uuid not in DBMock.get_dict(res_type.replace('-', '_')): raise NoIdError("Object does not exist.") DBMock.update(res_type.replace('-', '_'), obj.uuid, VncApiMock.object_to_dict(obj))
def list(res_type, parent_id=None, parent_fq_name=None, obj_uuids=None, back_ref_id=None, fields=None, detail=False, count=False, filters=None, shared=False): ret = [] for obj_dict in DBMock.get_dict(res_type.replace('-', '_')).values(): obj = VncApiMock.object_from_dict(res_type, obj_dict) if parent_id is not None and parent_id != VncApiMock.name_to_uuid(obj.parent_name()): continue if parent_fq_name is not None and parent_fq_name != obj.get_parent_fq_name(): continue if obj_uuids is not None and obj.uuid not in obj_uuids: continue ret.append(obj) return ret
def list(res_type, parent_id=None, parent_fq_name=None, obj_uuids=None, back_ref_id=None, fields=None, detail=False, count=False, filters=None, shared=False): ret = [] for obj_dict in DBMock.get_dict(res_type.replace('-', '_')).values(): obj = VncApiMock.object_from_dict(res_type, obj_dict) if parent_id is not None and parent_id != VncApiMock.name_to_uuid(obj.parent_name()): continue if parent_fq_name is not None and parent_fq_name != obj.get_parent_fq_name(): continue if obj_uuids is not None and obj.uuid not in obj_uuids: continue ret.append(obj) return ret