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
 def show(self, context, image_id):
     """                     
     # 调用之一传进来的参数: 
     # context:上下文信息; 
     # image_id=internal_id:实例镜像的ID值(从EC2 ID值变换了格式以后得到的); 
     """  
     # id_to_glance_id:根据数据库内置ID值(实例或者说是镜像的ID)获取数据库中相应的UUID值,赋值给image_uuid; 
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     
     # 这里的service:service = service or glance.get_default_image_service();  
     # 获取service或者是GlanceImageService的对象(glance.get_default_image_service()指向的);  
     # 所以这里调用的还是/nova/image/glance.py中的show方法;  
     image = self.service.show(context, image_uuid)
     
     # 转换镜像中的image_uuid到image_id;  
     # 更新image当中的相关属性,返回更新后的image数据;  
     return self._translate_uuid_to_id(context, image)
 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)
Esempio n. 6
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. 7
0
 def delete(self, context, image_id):
     image_uuid = ec2utils.id_to_glance_id(context, image_id)
     self.service.delete(context, image_uuid)
 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 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)