def _translate_id_to_uuid(self, context, image): image_copy = image.copy() try: image_id = image_copy['id'] except KeyError: pass else: image_copy['id'] = ec2utils.id_to_glance_id(context, image_id) for prop in ['kernel_id', 'ramdisk_id']: try: image_id = image_copy['properties'][prop] except (KeyError, ValueError): pass else: image_uuid = ec2utils.id_to_glance_id(context, image_id) image_copy['properties'][prop] = image_uuid return image_copy
def show(self, context, image_id): image_uuid = ec2utils.id_to_glance_id(context, image_id) image = self.service.show(context, image_uuid) return self._translate_uuid_to_id(context, image)
def update(self, context, image_id, metadata, data=None): image_uuid = ec2utils.id_to_glance_id(context, image_id) metadata = self._translate_id_to_uuid(context, metadata) image = self.service.update(context, image_uuid, metadata, data) return self._translate_uuid_to_id(context, image)
def delete(self, context, image_id): image_uuid = ec2utils.id_to_glance_id(context, image_id) self.service.delete(context, image_uuid)
def test_id_to_glance_id(self): s3imap = objects.S3ImageMapping(self.ctxt, uuid='fake-uuid') s3imap.create() uuid = ec2utils.id_to_glance_id(self.ctxt, s3imap.id) self.assertEqual(uuid, s3imap.uuid)