Example #1
0
    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
Example #2
0
File: s3.py Project: hsluoyz/patron
    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
Example #3
0
File: s3.py Project: hsluoyz/patron
 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)
Example #4
0
File: s3.py Project: hsluoyz/patron
 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)
Example #5
0
File: s3.py Project: hsluoyz/patron
 def delete(self, context, image_id):
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     self.service.delete(context, image_uuid)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 def delete(self, context, image_id):
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     self.service.delete(context, image_uuid)
Example #9
0
 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)
Example #10
0
 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)