def _from_db_object(cls, context, group_snapshot, db_group_snapshots, expected_attrs=None): expected_attrs = expected_attrs or [] for name, field in group_snapshot.fields.items(): if name in cls.OPTIONAL_FIELDS: continue value = db_group_snapshots.get(name) setattr(group_snapshot, name, value) if 'group' in expected_attrs: group = objects.Group(context) group._from_db_object(context, group, db_group_snapshots['group']) group_snapshot.group = group if 'snapshots' in expected_attrs: snapshots = base.obj_make_list(context, objects.SnapshotsList(context), objects.Snapshots, db_group_snapshots['snapshots']) group_snapshot.snapshots = snapshots group_snapshot._context = context group_snapshot.obj_reset_changes() return group_snapshot
def _from_db_object(context, cgsnapshot, db_cgsnapshots, expected_attrs=None): expected_attrs = expected_attrs or [] for name, field in cgsnapshot.fields.items(): if name in OPTIONAL_FIELDS: continue value = db_cgsnapshots.get(name) setattr(cgsnapshot, name, value) if 'consistencygroup' in expected_attrs: consistencygroup = objects.ConsistencyGroup(context) consistencygroup._from_db_object( context, consistencygroup, db_cgsnapshots['consistencygroup']) cgsnapshot.consistencygroup = consistencygroup if 'snapshots' in expected_attrs: snapshots = base.obj_make_list(context, objects.SnapshotsList(context), objects.Snapshots, db_cgsnapshots['snapshots']) cgsnapshot.snapshots = snapshots cgsnapshot._context = context cgsnapshot.obj_reset_changes() return cgsnapshot