Skip to content

Instantly share code, notes, and snippets.

@nelsnelson
Last active August 29, 2015 14:10
Show Gist options
  • Save nelsnelson/b17bb34099c1fc093f62 to your computer and use it in GitHub Desktop.
Save nelsnelson/b17bb34099c1fc093f62 to your computer and use it in GitHub Desktop.
cached image meta data
def _get_cached_image_metadata(self, instance):
# Get the system metadata from the instance
system_meta = utils.instance_sys_meta(instance)
cached_image = utils.get_image_from_system_metadata(system_meta)
# The cached_image should at least contain the inheritable
# properties dictionary, so if there are more entries than
# only the properties entry, then such meta data is sufficient
# to represent a cached image.
if cached_image and len(cached_image) > 1:
return cached_image
def _get_image_metadata(self, context, instance):
if (cached_image = self._get_cached_image_metadata(instance)):
return cached_image
# No cached image meta data available.
image_ref = instance.image_ref
# Pull the image from glance.
return compute_utils.get_image_metadata(context, self._image_api,
image_ref, instance)
def _get_disk_info(self, context, instance, block_device_info,
image_meta=None):
if not image_meta:
image_meta = self._get_image_metadata(context, instance)
return blockinfo.get_disk_info(CONF.libvirt.virt_type,
instance,
block_device_info,
image_meta)
def _hard_reboot(self, context, instance, network_info,
block_device_info=None):
"""Reboot a virtual machine, given an instance reference.
Performs a Libvirt reset (if supported) on the domain.
If Libvirt reset is unavailable this method actually destroys and
re-creates the domain to ensure the reboot happens, as the guest
OS cannot ignore this action.
If xml is set, it uses the passed in xml in place of the xml from the
existing domain.
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment