when we try to call nova.compute.utils.get_image_metadata with context.get_admin_context(), it would raise excetption.
refer to https://review.openstack.org/#/c/101005/
nova/compute/utils.py:
def get_image_metadata(context, image_api, image_id_or_uri, instance):
image_system_meta = {}
# In case of boot from volume, image_id_or_uri may be None
if image_id_or_uri is not None:
# If the base image is still available, get its metadata
try:
image = image_api.get(context, image_id_or_uri)
except (exception.ImageNotAuthorized, >>>>>>>>>>cannot get all exception exception.ImageNotFound, exception.Invalid) as e: LOG.warning(_LW("Can't access image %(image_id)s: %(error)s"), {"image_id": image_id_or_uri, "error": e}, instance=instance)
else:
flavor = flavors.extract_flavor(instance) image_system_meta = utils.get_system_metadata_from_image(image, flavor)
# Get the system metadata from the instance
system_meta = utils.instance_sys_meta(instance)
# Merge the metadata from the instance with the image's, if any
system_meta.update(image_system_meta)
# Convert the system metadata to image metadata
return utils.get_image_from_system_metadata(system_meta)
when we try to call nova.compute. utils.get_ image_metadata with context. get_admin_ context( ), it would raise excetption. /review. openstack. org/#/c/ 101005/
refer to https:/
nova/compute/ utils.py: metadata( context, image_api, image_id_or_uri, instance): system_ meta = {} get(context, image_id_or_uri) ImageNotAuthori zed, >>>>>>>>>>cannot get all exception
exception. ImageNotFound,
exception. Invalid) as e:
LOG. warning( _LW("Can' t access image %(image_id)s: %(error)s"),
{"image_ id": image_id_or_uri, "error": e},
instance= instance) extract_ flavor( instance)
image_ system_ meta = utils.get_ system_ metadata_ from_image( image,
flavor)
def get_image_
image_
# In case of boot from volume, image_id_or_uri may be None
if image_id_or_uri is not None:
# If the base image is still available, get its metadata
try:
image = image_api.
except (exception.
else:
flavor = flavors.
# Get the system metadata from the instance sys_meta( instance)
system_meta = utils.instance_
# Merge the metadata from the instance with the image's, if any meta.update( image_system_ meta)
system_
# Convert the system metadata to image metadata image_from_ system_ metadata( system_ meta)
return utils.get_