def init_host(self, host): """Initialize anything that is necessary for the driver to function. Includes catching up with currently running VMs on the given host. """ # Build the adapter. May need to attempt the connection multiple times # in case the PowerVM management API service is starting. # TODO(efried): Implement async compute service enable/disable like # I73a34eb6e0ca32d03e54d12a5e066b2ed4f19a61 self.adapter = pvm_apt.Adapter( pvm_apt.Session(conn_tries=60), helpers=[log_hlp.log_helper, vio_hlp.vios_busy_retry_helper]) # Make sure the Virtual I/O Server(s) are available. pvm_par.validate_vios_ready(self.adapter) self.host_wrapper = pvm_ms.System.get(self.adapter)[0] # Do a scrub of the I/O plane to make sure the system is in good shape LOG.info("Clearing stale I/O connections on driver init.") pvm_stor.ComprehensiveScrub(self.adapter).execute() # Initialize the disk adapter self.disk_dvr = importutils.import_object_ns( DISK_ADPT_NS, DISK_ADPT_MAPPINGS[CONF.powervm.disk_driver.lower()], self.adapter, self.host_wrapper.uuid) self.image_api = glance.API() LOG.info("The PowerVM compute driver has been initialized.")
def init_host(self, host): """Initialize anything that is necessary for the driver to function. Includes catching up with currently running VMs on the given host. """ LOG.warning( 'The powervm virt driver is deprecated and may be removed in a ' 'future release. The driver is not tested by the OpenStack ' 'project nor does it have clear maintainers and thus its quality' 'can not be ensured. If you are using the driver in production ' 'please let us know the openstack-discuss mailing list or on IRC' ) # Build the adapter. May need to attempt the connection multiple times # in case the PowerVM management API service is starting. # TODO(efried): Implement async compute service enable/disable like # I73a34eb6e0ca32d03e54d12a5e066b2ed4f19a61 self.adapter = pvm_apt.Adapter( pvm_apt.Session(conn_tries=60), helpers=[log_hlp.log_helper, vio_hlp.vios_busy_retry_helper]) # Make sure the Virtual I/O Server(s) are available. pvm_par.validate_vios_ready(self.adapter) self.host_wrapper = pvm_ms.System.get(self.adapter)[0] # Do a scrub of the I/O plane to make sure the system is in good shape LOG.info("Clearing stale I/O connections on driver init.") pvm_stor.ComprehensiveScrub(self.adapter).execute() # Initialize the disk adapter self.disk_dvr = importutils.import_object_ns( DISK_ADPT_NS, DISK_ADPT_MAPPINGS[CONF.powervm.disk_driver.lower()], self.adapter, self.host_wrapper.uuid) self.image_api = glance.API() LOG.info("The PowerVM compute driver has been initialized.")
from oslo_log import log as logging from oslo_utils import fileutils from oslo_utils import imageutils from oslo_utils import units from nova.compute import utils as compute_utils import nova.conf from nova import exception from nova.i18n import _ from nova.image import glance import nova.privsep.qemu LOG = logging.getLogger(__name__) CONF = nova.conf.CONF IMAGE_API = glance.API() QEMU_IMG_LIMITS = processutils.ProcessLimits(cpu_time=30, address_space=1 * units.Gi) # This is set by the libvirt driver on startup. The version is used to # determine what flags need to be set on the command line. QEMU_VERSION = None QEMU_VERSION_REQ_SHARED = 2010000 def qemu_img_info(path, format=None): """Return an object containing the parsed output from qemu-img info.""" # TODO(mikal): this code should not be referring to a libvirt specific # flag. if not os.path.exists(path) and CONF.libvirt.images_type != 'rbd':
def __init__(self): super(ImagesController, self).__init__() self._image_api = glance.API()
def __init__(self): self.conductor_compute_rpcapi = rpcapi.ComputeTaskAPI() self.image_api = glance.API()
def __init__(self): super(ImageMetadataController, self).__init__() self.image_api = glance.API()
def info_from_instance(context, instance, network_info, populate_image_ref_url=False, **kw): """Get detailed instance information for an instance which is common to all notifications. :param:instance: nova.objects.Instance :param:network_info: network_info provided if not None :param:populate_image_ref_url: If True then the full URL of the image of the instance is generated and returned. This, depending on the configuration, might mean a call to Keystone. If false, None value is returned in the dict at the image_ref_url key. """ image_ref_url = None if populate_image_ref_url: try: # NOTE(mriedem): We can eventually drop this when we no longer # support legacy notifications since versioned notifications don't # use this. image_ref_url = glance.API().generate_image_url( instance.image_ref, context) except ks_exc.EndpointNotFound: # We might be running from a periodic task with no auth token and # CONF.glance.api_servers isn't set, so we can't get the image API # endpoint URL from the service catalog, therefore just use the # image id for the URL (yes it's a lie, but it's best effort at # this point). with excutils.save_and_reraise_exception() as exc_ctx: if context.auth_token is None: image_ref_url = instance.image_ref exc_ctx.reraise = False instance_type = instance.get_flavor() instance_type_name = instance_type.get('name', '') instance_flavorid = instance_type.get('flavorid', '') instance_info = dict( # Owner properties tenant_id=instance.project_id, user_id=instance.user_id, # Identity properties instance_id=instance.uuid, display_name=instance.display_name, reservation_id=instance.reservation_id, hostname=instance.hostname, # Type properties instance_type=instance_type_name, instance_type_id=instance.instance_type_id, instance_flavor_id=instance_flavorid, architecture=instance.architecture, # Capacity properties memory_mb=instance.flavor.memory_mb, disk_gb=instance.flavor.root_gb + instance.flavor.ephemeral_gb, vcpus=instance.flavor.vcpus, # Note(dhellmann): This makes the disk_gb value redundant, but # we are keeping it for backwards-compatibility with existing # users of notifications. root_gb=instance.flavor.root_gb, ephemeral_gb=instance.flavor.ephemeral_gb, # Location properties host=instance.host, node=instance.node, availability_zone=instance.availability_zone, cell_name=null_safe_str(instance.cell_name), # Date properties created_at=str(instance.created_at), # Terminated and Deleted are slightly different (although being # terminated and not deleted is a transient state), so include # both and let the recipient decide which they want to use. terminated_at=null_safe_isotime(instance.get('terminated_at', None)), deleted_at=null_safe_isotime(instance.get('deleted_at', None)), launched_at=null_safe_isotime(instance.get('launched_at', None)), # Image properties image_ref_url=image_ref_url, os_type=instance.os_type, kernel_id=instance.kernel_id, ramdisk_id=instance.ramdisk_id, # Status properties state=instance.vm_state, state_description=null_safe_str(instance.task_state), # NOTE(gibi): It might seems wrong to default the progress to an empty # string but this is how legacy work and this code only used by the # legacy notification so try to keep the compatibility here but also # keep it contained. progress=int(instance.progress) if instance.progress else '', # accessIPs access_ip_v4=instance.access_ip_v4, access_ip_v6=instance.access_ip_v6, ) if network_info is not None: fixed_ips = [] for vif in network_info: for ip in vif.fixed_ips(): ip["label"] = vif["network"]["label"] ip["vif_mac"] = vif["address"] fixed_ips.append(ip) instance_info['fixed_ips'] = fixed_ips # add image metadata image_meta_props = image_meta(instance.system_metadata) instance_info["image_meta"] = image_meta_props # add instance metadata instance_info['metadata'] = instance.metadata instance_info.update(kw) return instance_info