Esempio n. 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
Esempio n. 2
0
File: s3.py Progetto: 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
Esempio n. 3
0
File: s3.py Progetto: 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)
Esempio n. 4
0
File: s3.py Progetto: 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)
Esempio n. 5
0
File: s3.py Progetto: hsluoyz/patron
 def delete(self, context, image_id):
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     self.service.delete(context, image_uuid)
Esempio n. 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)
Esempio n. 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)
Esempio n. 8
0
 def delete(self, context, image_id):
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     self.service.delete(context, image_uuid)
Esempio n. 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)
Esempio n. 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)