def get_int_id_from_snapshot_uuid(context, snapshot_uuid): if snapshot_uuid is None: return try: smap = objects.EC2SnapshotMapping.get_by_uuid(context, snapshot_uuid) return smap.id except exception.NotFound: smap = objects.EC2SnapshotMapping(context, uuid=snapshot_uuid) smap.create() return smap.id
def test_get_snapshot_uuid_from_int_id(self): smap = objects.EC2SnapshotMapping(self.ctxt, uuid='fake-uuid') smap.create() smap_uuid = ec2utils.get_snapshot_uuid_from_int_id(self.ctxt, smap.id) self.assertEqual(smap.uuid, smap_uuid)