def create(self, status, last_modified): volume = Volume(0, 'vtype', status=status, id=str(uuid.uuid4()), node=self.node, account=self.account) backup = Backup(volume, status='AVAILABLE', volume_id=str(uuid.uuid4())) self.db.add_all([volume, backup]) self.db.commit() # Assign the backup as the restore of the volume volume.restore_of = backup.id volume.last_modified = last_modified self.db.commit() return volume