本文整理汇总了Python中nova.api.ec2.ec2utils.glance_id_to_id函数的典型用法代码示例。如果您正苦于以下问题:Python glance_id_to_id函数的具体用法?Python glance_id_to_id怎么用?Python glance_id_to_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了glance_id_to_id函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _translate_uuid_to_id
def _translate_uuid_to_id(self, context, image):
image_copy = image.copy()
try:
image_uuid = image_copy["id"]
except KeyError:
pass
else:
image_copy["id"] = ec2utils.glance_id_to_id(context, image_uuid)
for prop in ["kernel_id", "ramdisk_id"]:
try:
image_uuid = image_copy["properties"][prop]
except (KeyError, ValueError):
pass
else:
image_id = ec2utils.glance_id_to_id(context, image_uuid)
image_copy["properties"][prop] = image_id
try:
image_copy["properties"]["image_state"] = self.image_state_map[image["properties"]["image_state"]]
except (KeyError, ValueError):
pass
return image_copy
开发者ID:isyippee,项目名称:nova,代码行数:25,代码来源:s3.py
示例2: _translate_uuid_to_id
def _translate_uuid_to_id(self, context, image):
image_copy = image.copy()
try:
image_uuid = image_copy['id']
except KeyError:
pass
else:
image_copy['id'] = ec2utils.glance_id_to_id(context, image_uuid)
for prop in ['kernel_id', 'ramdisk_id']:
try:
image_uuid = image_copy['properties'][prop]
except (KeyError, ValueError):
pass
else:
image_id = ec2utils.glance_id_to_id(context, image_uuid)
image_copy['properties'][prop] = image_id
try:
image_copy['properties']['image_state'] = self.image_state_map[
image['properties']['image_state']]
except (KeyError, ValueError):
pass
return image_copy
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:26,代码来源:s3.py
示例3: _translate_uuid_to_id
def _translate_uuid_to_id(self, context, image):
"""
调用glance_id_to_id方法转换image_copy['id']、image_copy['properties']['kernel_id']和image_copy['properties']['ramdisk_id'];
更新image当中的相关属性,返回更新后的image数据;
"""
# 拷贝image对象给image_copy;
image_copy = image.copy()
try:
image_uuid = image_copy['id']
except KeyError:
pass
else:
image_copy['id'] = ec2utils.glance_id_to_id(context, image_uuid)
for prop in ['kernel_id', 'ramdisk_id']:
try:
image_uuid = image_copy['properties'][prop]
except (KeyError, ValueError):
pass
else:
image_id = ec2utils.glance_id_to_id(context, image_uuid)
image_copy['properties'][prop] = image_id
try:
image_copy['properties']['image_state'] = self.image_state_map[
image['properties']['image_state']]
except (KeyError, ValueError):
pass
return image_copy
开发者ID:luzheqi1987,项目名称:nova-annotation,代码行数:32,代码来源:s3.py
示例4: _s3_parse_manifest
def _s3_parse_manifest(self, context, metadata, manifest):
manifest = etree.fromstring(manifest)
image_format = 'ami'
try:
kernel_id = manifest.find('machine_configuration/kernel_id').text
if kernel_id == 'true':
image_format = 'aki'
kernel_id = None
except Exception:
kernel_id = None
try:
ramdisk_id = manifest.find('machine_configuration/ramdisk_id').text
if ramdisk_id == 'true':
image_format = 'ari'
ramdisk_id = None
except Exception:
ramdisk_id = None
try:
arch = manifest.find('machine_configuration/architecture').text
except Exception:
arch = 'x86_64'
# NOTE(yamahata):
# EC2 ec2-budlne-image --block-device-mapping accepts
# <virtual name>=<device name> where
# virtual name = {ami, root, swap, ephemeral<N>}
# where N is no negative integer
# device name = the device name seen by guest kernel.
# They are converted into
# block_device_mapping/mapping/{virtual, device}
#
# Do NOT confuse this with ec2-register's block device mapping
# argument.
mappings = []
try:
block_device_mapping = manifest.findall('machine_configuration/'
'block_device_mapping/'
'mapping')
for bdm in block_device_mapping:
mappings.append({'virtual': bdm.find('virtual').text,
'device': bdm.find('device').text})
except Exception:
mappings = []
properties = metadata['properties']
properties['architecture'] = arch
def _translate_dependent_image_id(image_key, image_id):
image_uuid = ec2utils.ec2_id_to_glance_id(context, image_id)
properties[image_key] = image_uuid
if kernel_id:
_translate_dependent_image_id('kernel_id', kernel_id)
if ramdisk_id:
_translate_dependent_image_id('ramdisk_id', ramdisk_id)
if mappings:
properties['mappings'] = mappings
metadata.update({'disk_format': image_format,
'container_format': image_format,
'status': 'queued',
'is_public': False,
'properties': properties})
metadata['properties']['image_state'] = 'pending'
#TODO(bcwaldon): right now, this removes user-defined ids.
# We need to re-enable this.
metadata.pop('id', None)
image = self.service.create(context, metadata)
# extract the new uuid and generate an int id to present back to user
image_uuid = image['id']
image['id'] = ec2utils.glance_id_to_id(context, image_uuid)
# return image_uuid so the caller can still make use of image_service
return manifest, image, image_uuid
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:82,代码来源:s3.py
示例5: _s3_parse_manifest
def _s3_parse_manifest(self, context, metadata, manifest):
manifest = etree.fromstring(manifest)
image_format = "ami"
try:
kernel_id = manifest.find("machine_configuration/kernel_id").text
if kernel_id == "true":
image_format = "aki"
kernel_id = None
except Exception:
kernel_id = None
try:
ramdisk_id = manifest.find("machine_configuration/ramdisk_id").text
if ramdisk_id == "true":
image_format = "ari"
ramdisk_id = None
except Exception:
ramdisk_id = None
try:
guestarch = manifest.find("machine_configuration/architecture").text
except Exception:
guestarch = arch.X86_64
if not arch.is_valid(guestarch):
raise exception.InvalidArchitectureName(arch=guestarch)
# NOTE(yamahata):
# EC2 ec2-budlne-image --block-device-mapping accepts
# <virtual name>=<device name> where
# virtual name = {ami, root, swap, ephemeral<N>}
# where N is no negative integer
# device name = the device name seen by guest kernel.
# They are converted into
# block_device_mapping/mapping/{virtual, device}
#
# Do NOT confuse this with ec2-register's block device mapping
# argument.
mappings = []
try:
block_device_mapping = manifest.findall("machine_configuration/" "block_device_mapping/" "mapping")
for bdm in block_device_mapping:
mappings.append({"virtual": bdm.find("virtual").text, "device": bdm.find("device").text})
except Exception:
mappings = []
properties = metadata["properties"]
properties["architecture"] = guestarch
def _translate_dependent_image_id(image_key, image_id):
image_uuid = ec2utils.ec2_id_to_glance_id(context, image_id)
properties[image_key] = image_uuid
if kernel_id:
_translate_dependent_image_id("kernel_id", kernel_id)
if ramdisk_id:
_translate_dependent_image_id("ramdisk_id", ramdisk_id)
if mappings:
properties["mappings"] = mappings
metadata.update(
{
"disk_format": image_format,
"container_format": image_format,
"status": "queued",
"is_public": False,
"properties": properties,
}
)
metadata["properties"]["image_state"] = "pending"
# TODO(bcwaldon): right now, this removes user-defined ids.
# We need to re-enable this.
metadata.pop("id", None)
image = self.service.create(context, metadata)
# extract the new uuid and generate an int id to present back to user
image_uuid = image["id"]
image["id"] = ec2utils.glance_id_to_id(context, image_uuid)
# return image_uuid so the caller can still make use of image_service
return manifest, image, image_uuid
开发者ID:isyippee,项目名称:nova,代码行数:86,代码来源:s3.py
示例6: test_glance_id_to_id_creates_mapping
def test_glance_id_to_id_creates_mapping(self):
s3imap_id = ec2utils.glance_id_to_id(self.ctxt, 'fake-uuid')
s3imap = objects.S3ImageMapping.get_by_id(self.ctxt, s3imap_id)
self.assertEqual('fake-uuid', s3imap.uuid)
开发者ID:AsherBond,项目名称:nova,代码行数:4,代码来源:test_ec2utils.py
示例7: test_glance_id_to_id
def test_glance_id_to_id(self):
s3imap = objects.S3ImageMapping(self.ctxt, uuid='fake-uuid')
s3imap.create()
s3imap_id = ec2utils.glance_id_to_id(self.ctxt, s3imap.uuid)
self.assertEqual(s3imap_id, s3imap.id)
开发者ID:AsherBond,项目名称:nova,代码行数:5,代码来源:test_ec2utils.py
注:本文中的nova.api.ec2.ec2utils.glance_id_to_id函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论