# Copyright 2011 Justin Santa Barbara
# All Rights Reserved.
#
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Driver for Solaris Zones (nee Containers):
"""
import base64
import glob
import os
import platform
import shutil
import tempfile
import uuid
default=None,
default=None,
'live migration. If not specified, a common encryption '
'algorithm will be negotiated. Options include: none or '
'the name of a supported OpenSSL cipher algorithm.'),
'Glance image service.'),
'metadata.'),
]
# These should match the strings returned by the zone_state_str()
# function in the (private) libzonecfg library. These values are in turn
# returned in the 'state' string of the Solaris Zones' RAD interface by
# the zonemgr(3RAD) provider.
# Mapping between zone state and Nova power_state.
}
# Solaris Zones brands as defined in brands(5).
# Mapping between supported zone brands and the name of the corresponding
# brand template.
ZONE_BRAND_SOLARIS: 'SYSdefault',
ZONE_BRAND_SOLARIS_KZ: 'SYSsolaris-kz',
}
# Required in order to create a zone VNC console SMF service instance
# The underlying Solaris Zones framework does not expose a specific
# version number, instead relying on feature tests to identify what is
# and what is not supported. A HYPERVISOR_VERSION is defined here for
# Nova's use but it generally should not be changed unless there is a
# incompatible change such as concerning kernel zone live migration.
"""Lookup specified resource from specified Solaris Zone."""
try:
return None
except Exception:
raise
"""Lookup specified property from specified Solaris Zone resource."""
try:
[prop])
return None
except Exception:
raise
"""Lookup specified property with value from specified Solaris Zone
resource. Returns property if matching value is found, else None
"""
try:
return propertee
else:
return None
return None
except Exception:
raise
"""Format the payload from a zonemgr(3RAD) rad.client.ObjectError
exception into a sensible error string that can be logged. Newlines
are converted to a colon-space string to create a single line.
If the exception was something other than rad.client.ObjectError,
just return it as a string.
"""
return result
""" Extending the volume api to support additional cinder sub-commands
"""
availability_zone=None, source_volume=None):
"""Clone the source volume by calling the cinderclient version of
create with a source_volid argument
:param context: the context for the clone
:param size: size of the new volume, must be the same as the source
volume
:param name: display_name of the new volume
:param description: display_description of the new volume
:param snapshot: Snapshot object
:param image_id: image_id to create the volume from
:param volume_type: type of volume
:param metadata: Additional metadata for the volume
:param availability_zone: zone:host where the volume is to be created
:param source_volume: Volume object
Returns a volume object
"""
if snapshot is not None:
else:
snapshot_id = None
if source_volume is not None:
else:
source_volid = None
else:
try:
except cinder_exception.OverLimit:
except (cinder_exception.BadRequest,
"""Update the fields of a volume for example used to rename a volume
via a call to cinderclient
:param context: the context for the update
:param volume_id: the id of the volume to update
"""
"""Extend the size of a cinder volume by calling the cinderclient
:param context: the context for the extend
:param volume: the volume object to extend
:param newsize: the new size of the volume in GB
"""
"""ZoneConfig - context manager for access zone configurations.
Automatically opens the configuration for a zone and commits any changes
before exiting
"""
"""zone is a zonemgr object representing either a kernel zone or
non-global zone.
"""
"""enables the editing of the zone."""
try:
return self
raise
"""looks for any kind of exception before exiting. If one is found,
cancel any configuration changes and reraise the exception. If not,
commit the new configuration.
"""
# We received some kind of exception. Cancel the config and raise.
raise
else:
# commit the config
try:
"instance '%s' via zonemgr(3RAD): %s")
# Last ditch effort to cleanup.
raise
"""sets a property for an existing resource OR creates a new resource
with the given property(s).
"""
# the value is already set
return
try:
if current is None:
else:
"instance '%s' via zonemgr(3RAD): %s")
raise
"""creates a new resource with an optional property list, or set the
property if the resource exists and ignore_exists is true.
:param ignore_exists: If the resource exists, set the property for the
resource.
"""
if props is None:
props = []
try:
if (ignore_exists and
return
"via zonemgr(3RAD): %s")
raise
"""removes resources whose properties include the optional property
list specified in props.
"""
if props is None:
props = []
try:
"zonemgr(3RAD): %s")
raise
"""Clear property values of a given resource
"""
try:
"instance '%s' via zonemgr(3RAD): %s")
raise
"""Solaris Zones Driver using the zonemgr(3RAD) and kstat(3RAD) providers.
The interface to this class talks in terms of 'instances' (Amazon EC2 and
internal Nova terminology), by which we mean 'running virtual machine'
(XenAPI terminology) or domain (Xen or libvirt terminology).
An instance has an ID, which is the identifier chosen by Nova to represent
the instance further up the stack. This is unfortunately also called a
'name' elsewhere. As far as this layer is concerned, 'instance ID' and
'instance name' are synonyms.
Note that the instance ID or name is not human-readable or
customer-controlled -- it's an internal ID chosen by Nova. At the
nova.virt layer, instances do not have human-readable names at all -- such
things are only known higher up the stack.
Most virtualization platforms will also have their own identity schemes,
to uniquely identify a VM or domain. These IDs must stay internal to the
platform-specific layer, and never escape the connection interface. The
platform-specific layer is responsible for keeping track of which instance
ID maps to which platform-specific ID, and vice versa.
Some methods here take an instance of nova.compute.service.Instance. This
is the data structure used by nova.compute to store details regarding an
instance, and pass them into this layer. This layer is responsible for
translating that generic data structure into terms that are specific to the
virtualization platform.
"""
capabilities = {
"has_imagecache": False,
"supports_recreate": True,
}
self._compute_event_callback = None
self._host_stats = {}
self._initiator = None
self._install_engine = None
self._kstat_control = None
self._rad_connection = None
self._zone_manager = None
if self._rad_connection is None:
else:
# taken from rad.connect.RadConnection.__repr__ to look for a
# closed connection
# the RAD connection has been lost. Reconnect to RAD
return self._rad_connection
try:
if (self._zone_manager is None or
return self._zone_manager
try:
if (self._kstat_control is None or
return self._kstat_control
"""Initialize anything that is necessary for the driver to function,
including catching up with currently running VM's on the given host.
"""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Clean up anything that is necessary for the driver gracefully stop,
including ending remote sessions. This is optional.
"""
pass
"""Get Fibre Channel HBA information."""
out = None
try:
except processutils.ProcessExecutionError:
return []
if out is None:
raise RuntimeError(_("Cannot find any Fibre Channel HBAs"))
hbas = []
hba = {}
# Collect the following hba-port data:
# 1: Port WWN
# 2: State (online|offline)
# 3: Node WWN
# New HBA port entry
hba = {}
continue
# Skip Target mode ports
if mode != 'Initiator':
break
continue
continue
hba = {}
"""Get Fibre Channel WWNNs from the system, if any."""
wwnns = []
return wwnns
"""Get Fibre Channel WWPNs from the system, if any."""
wwpns = []
return wwpns
""" Return the iSCSI initiator node name IQN for this host """
'initiator-node')
# Sample first line of command output:
# Initiator node name: iqn.1986-03.com.sun:01:e00000000000.4f757217
return initiator_iqn
"""Return a Solaris Zones object via RAD by name."""
try:
return None
except Exception:
raise
return zone
"""Return the running state, one of the power_state codes."""
"""Convert a number of pages of memory into a total size in KBytes."""
"""Return the maximum memory in KBytes allowed."""
mem_resource = 'swap'
else:
mem_resource = 'physical'
if max_mem is not None:
# If physical property in capped-memory doesn't exist, this may
# represent a non-global zone so just return the system's total
# memory.
"""Return the memory in KBytes used by the domain."""
# There isn't any way of determining this from the hypervisor
# perspective in Solaris, so just return the _get_max_mem() value
# for now.
"""Return the number of virtual CPUs for the domain.
In the case of kernel zones, the number of virtual CPUs a zone
ends up with depends on whether or not there were 'virtual-cpu'
or 'dedicated-cpu' resources in the configuration or whether
there was an assigned pool in the configuration. This algorithm
attempts to emulate what the virtual platform code does to
determine a number of virtual CPUs to use.
"""
# If a 'virtual-cpu' resource exists, use the minimum number of
# CPUs defined there.
if ncpus is not None:
# Otherwise if a 'dedicated-cpu' resource exists, use the maximum
# number of CPUs defined there.
if ncpus is not None:
# Finally if neither resource exists but the zone was assigned a
# pool in the configuration, the number of CPUs would be the size
# of the processor set. Currently there's no way of easily
# determining this so use the system's notion of the total number
# of online CPUs.
"""Return Kstat snapshot data via RAD as a dictionary."""
pattern = {
'class': kstat_class,
'module': module,
'instance': instance,
'name': name
}
try:
"'%s' via kstat(3RAD): %s")
return None
kstat_data = {}
return kstat_data
"""Return the CPU time used in nanoseconds."""
return 0
'sys_zone_aggr')
if kstat_data is None:
return 0
"""Get the current status of an instance, by name (not ID!)
:param instance: nova.objects.instance.Instance object
Returns a InstanceInfo object
"""
# TODO(Vek): Need to pass context in for access to auth_token
if zone is None:
"""Return the total number of virtual machines.
Return the number of virtual machines that the hypervisor knows
about.
.. note::
This implementation works for all drivers, but it is
not particularly efficient. Maintainers of the virt drivers are
encouraged to override this method with something more
efficient.
"""
"""Checks existence of an instance on the host.
:param instance: The instance to lookup
Returns True if an instance with the supplied ID exists on
the host, False otherwise.
.. note::
This implementation works for all drivers, but it is
not particularly efficient. Maintainers of the virt drivers are
encouraged to override this method with something more
efficient.
"""
try:
except NotImplementedError:
"""Estimate the virtualization overhead required to build an instance
of the given flavor.
Defaults to zero, drivers should override if per-instance overhead
calculations are desired.
:returns: Dict of estimated overhead values.
"""
return {'memory_mb': 0}
"""Return a list of all Solaris Zones objects via RAD."""
"""Return the names of all the instances known to the virtualization
layer, as a list.
"""
# TODO(Vek): Need to pass context in for access to auth_token
instances_list = []
return instances_list
"""Return the UUIDS of all the instances known to the virtualization
layer, as a list.
"""
raise NotImplementedError()
root_ci = None
if entry['connection_info'] is None:
continue
continue
if not recreate:
msg = (_("Unable to find the root device for instance '%s'.")
% instance['name'])
return root_ci
attach_block_devices, network_info=None,
"""Destroy and re-make this instance.
A 'rebuild' effectively purges all existing data from the system and
remakes the VM with given 'metadata' and 'personalities'.
This base class method shuts down the VM, detaches all block devices,
then spins up the new VM afterwards. It may be overridden by
hypervisors that need to - e.g. for optimisations, or when the 'VM'
is actually proxied and needs to be held across the shutdown + spin
up steps.
:param context: security context
:param instance: nova.objects.instance.Instance
This function should use the data there to guide
the creation of the new instance.
:param image_meta: image object returned by nova.image.glance that
defines the image from which to boot this instance
:param injected_files: User files to inject into instance.
:param admin_password: Administrator password to set in instance.
:param bdms: block-device-mappings to use for rebuild
:param detach_block_devices: function to detach block devices. See
nova.compute.manager.ComputeManager:_rebuild_default_impl for
usage.
:param attach_block_devices: function to attach block devices. See
nova.compute.manager.ComputeManager:_rebuild_default_impl for
usage.
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param recreate: True if the instance is being recreated on a new
hypervisor - all the cleanup of old state is skipped.
:param block_device_info: Information about block devices to be
attached to the instance.
:param preserve_ephemeral: True if the default ephemeral storage
partition must be preserved on rebuild
"""
if recreate:
if brand == ZONE_BRAND_SOLARIS:
msg = (_("'%s' branded zones do not currently support "
"evacuation.") % brand)
if root_ci is not None:
else:
driver_type = 'local'
# If image_meta is provided then the --on-shared-storage option
# was not used.
if image_meta:
# If not then raise an exception. But if this is a rebuild then
# the local storage is ok.
msg = (_("Root device is on shared storage for instance '%s'.")
% instance['name'])
else:
# So the root device is not expected to be local so we can move
# forward with building the zone.
if driver_type not in shared_storage:
msg = (_("Root device is not on shared storage for instance "
if not recreate:
if root_ci is not None:
if recreate:
root_ci, None)
else:
if zone is None:
if recreate:
if (entry['connection_info'] is None or
continue
if admin_password is not None:
# Because there is no way to make sure a zone is ready upon
# returning from a boot request. We must give the zone a few
# seconds to boot before attempting to set the admin password.
"""Retrieve extra_specs of an instance."""
instance['instance_type_id'])
"""Fetch an image using Glance given the instance's image_ref."""
% instance['image_ref'])
return image
% instance['image_ref'])
try:
raise
return image
"""Validate a glance image for compatibility with the instance."""
# Skip if the image was already checked and confirmed as valid.
return
if self._install_engine is None:
try:
except Exception:
reason = (_("Image query failed. Possibly invalid or corrupt. "
"Log file location: %s:%s")
try:
# Validate the image at this point to ensure:
# - contains one deployable system
reason = (_('Image must contain only 1 deployable system'))
raise exception.ImageUnacceptable(
# - matching architecture
if deployable_arch != compute_arch:
reason = (_('Image architecture "%s" is incompatible with this'
'compute host architecture: "%s"')
% (deployable_arch, compute_arch))
# For some reason we have gotten the wrong architecture image,
# which should have been filtered by the scheduler. One reason
# this could happen is because the images architecture type is
# incorrectly set. Check for this and report a better reason.
glanceapi = glance_api()
"set on the Glance image."))
raise exception.ImageUnacceptable(
# - single root pool only
reason = (_('Image contains more than one zpool: "%s"')
% (stream_pools))
raise exception.ImageUnacceptable(
# - looks like it's OK
finally:
# Clear the reference to the UnifiedArchive object in the engine
# data cache to avoid collision with the next checkpoint execution.
"""Returns a suri(5) formatted string based on connection_info.
Currently supports local ZFS volume, NFS, Fibre Channel and iSCSI
driver types.
"""
if driver_type == 'local':
elif driver_type == 'iscsi':
# suri(5) format:
# iscsi://<host>[:<port>]/target.<IQN>,lun.<LUN>
# Sample iSCSI connection data values:
# target_portal: 192.168.1.244:3260
# target_iqn: iqn.2010-10.org.openstack:volume-a89c.....
# target_lun: 1
data['target_iqn'],
data['target_lun'])
# TODO(npower): need to handle CHAP authentication also
elif driver_type == 'nfs':
suri = (
'nfs://cinder:cinder@%s/%s' %
)
elif driver_type == 'fibre_channel':
# Check for multiple target_wwn values in a list
# Ensure there's a fibre channel HBA.
if not hbas:
"no Fibre Channel HBA initiators were found")
% (target_wwn))
raise exception.InvalidVolume(
reason="No host Fibre Channel initiator found")
# If the volume was exported just a few seconds previously then
# it will probably not be visible to the local adapter yet.
# Invoke 'fcinfo remote-port' on all local HBA ports to trigger
# a refresh.
'-p', wwpn)
# Use suriadm(1M) to generate a Fibre Channel storage URI.
try:
raise
# Use the long form SURI on the second output line.
return suri
"""Set Solaris Zone's global properties if supplied via flavor."""
if zone is None:
# TODO(dcomay): Should figure this out via the brands themselves.
zonecfg_items = [
'bootargs',
'brand',
'hostid'
]
if brand == ZONE_BRAND_SOLARIS:
['file-mac-profile', 'fs-allowed', 'limitpriv'])
# Ignore not-zonecfg-scoped brand properties.
continue
# Ignore the 'brand' property if present.
if prop == 'brand':
continue
# Ignore but warn about unsupported zonecfg-scoped properties.
if prop not in zonecfg_items:
"set on flavor for instance '%s'")
continue
"""Create a (Cinder) volume service backed boot volume"""
try:
instance['root_gb'],
"Boot volume for instance '%s' (%s)"
# creating a new volume, so we do likewise here.
while True:
return volume
raise
"""Connect a (Cinder) volume service backed boot volume"""
# Check connection_info to determine if the provided volume is
# local to this compute node. If it is, then don't use it for
# Solaris branded zones in order to avoid a known ZFS deadlock issue
# when using a zpool within another zpool on the same system.
if brand == ZONE_BRAND_SOLARIS:
if driver_type == 'local':
msg = _("Detected 'local' zvol driver volume type "
"from volume service, which should not be "
"used as a boot device for 'solaris' "
"branded zones.")
elif driver_type == 'iscsi':
# Check for a potential loopback iSCSI situation
# Strip off the port number (eg. 127.0.0.1:3260)
# Strip any enclosing '[' and ']' brackets for
# IPv6 addresses.
# Check if target_host is an IP or hostname matching the
# connector host or IP, which would mean the provisioned
# iSCSI LUN is on the same host as the instance.
msg = _("iSCSI connection info from volume "
"service indicates that the target is a "
"local volume, which should not be used "
"as a boot device for 'solaris' branded "
"zones.")
# Assuming that fibre_channel is non-local
elif driver_type != 'fibre_channel':
# Some other connection type that we don't understand
# Let zone use some local fallback instead.
msg = _("Unsupported volume driver type '%s' can not be used "
"as a boot device for zones." % driver_type)
# Volume looks OK to use. Notify Cinder of the attachment.
return connection_info
"""Set the boot device specified by connection_info"""
if zone is None:
# ZOSS device configuration is different for the solaris-kz brand
if brand == ZONE_BRAND_SOLARIS_KZ:
"device",
else:
"""Set number of VCPUs in a Solaris Zone configuration."""
if zone is None:
# The Solaris Zone brand type is used to specify the type of
# 'cpu' resource set in the Solaris Zone configuration.
if brand == ZONE_BRAND_SOLARIS:
vcpu_resource = 'capped-cpu'
else:
vcpu_resource = 'virtual-cpu'
# TODO(dcomay): Until 17881862 is resolved, this should be turned into
# an appropriate 'rctl' resource for the 'capped-cpu' case.
"""Set memory cap in a Solaris Zone configuration."""
if zone is None:
# The Solaris Zone brand type is used to specify the type of
# 'memory' cap set in the Solaris Zone configuration.
if brand == ZONE_BRAND_SOLARIS:
mem_resource = 'swap'
else:
mem_resource = 'physical'
sc_dir):
"""add networking information to the zone."""
if zone is None:
if not network_info:
if brand == ZONE_BRAND_SOLARIS:
else:
return
tenant_id = None
if tenant_id is None:
nameservers = []
if netid == 0:
else:
'anet',
'false'),
if brand == ZONE_BRAND_SOLARIS:
'linkname', filter)
else:
# create the required sysconfig file (or skip if this is part of a
# resize or evacuate process)
task_states.REBUILD_SPAWNING] or \
if subnet['enable_dhcp']:
else:
ip_version, ip,
if tenant_id is not None:
# set the tenant id
"""Use the instance name to specify the pathname for the suspend image.
"""
if zone is None:
"""verify the SC profile(s) passed in contain an entry for
system/config-user to configure the root account. If an SSH key is
specified, configure root's profile to use it.
"""
encrypted_password = None
# encrypt admin password, using SHA-256 as default
if admin_password is not None:
# find all XML files in sc_dir
# look for config-user properties
# a service element was found for config-user. Verify
# root's password is set, the admin account name is set and
# the admin's password is set
# look for identity properties
# Verify all of the requirements were met. Create the required SMF
# profile(s) if needed.
if admin_password is not None and sshkey is not None:
# store password for horizon retrieval
if encrypted_password is not None or sshkey is not None:
# set up the root account as 'normal' with no expiration,
# an ssh key, and a root password
else:
# sets up root account with expiration if sshkey is None
# and password is none
elif sshkey is not None:
if hostname_needed and name is not None:
sc_dir, admin_password=None):
"""Create a new Solaris Zone configuration."""
# If unspecified, default zone brand is ZONE_BRAND_SOLARIS
# TODO(dcomay): Detect capability via libv12n(3LIB) or virtinfo(1M).
if template is None:
msg = (_("Invalid brand '%s' specified for instance '%s'"
task_states.REBUILD_SPAWNING] or \
if sc_profile is not None:
'sysconfig'))
try:
if connection_info is not None:
raise
"""Create a VNC console SMF service for a Solaris Zone"""
# Basic environment checks first: vncserver and xterm
"compute node. %s is missing. Run 'pkg install "
"x11/server/xvnc'") % VNC_SERVER_PATH)
"compute node. %s is missing. Run 'pkg install "
"terminal/xterm'") % XTERM_PATH)
# TODO(npower): investigate using RAD instead of CLI invocation
try:
"console SMF service for instance '%s'") % name)
return
"'{0}': {1}").format(
raise
"""Delete a VNC console SMF service for a Solaris Zone"""
# TODO(npower): investigate using RAD instead of CLI invocation
try:
"VNC console SMF service for instance '%s'")
% name)
return
"%s")
raise
"""Enable a zone VNC console SMF service"""
# TODO(npower): investigate using RAD instead of CLI invocation
try:
# The console SMF service exits with SMF_TEMP_DISABLE to prevent
# unnecessarily coming online at boot. Tell it to really bring
# it online.
'setprop', 'vnc/nova-enabled=true')
'refresh')
"VNC console SMF service for instance '%s'")
% name)
return
raise
# Allow some time for the console service to come online.
while True:
try:
if state == 'online':
break
"'%s' state. Run 'svcs -x %s' for details.")
# Wait for service state to transition to (hopefully) online
# state or offline/maintenance states.
raise
# TODO(npower): investigate using RAD instead of CLI invocation
try:
# The console SMF service exits with SMF_TEMP_DISABLE to prevent
# unnecessarily coming online at boot. Make that happen.
'setprop', 'vnc/nova-enabled=false')
'refresh')
"zone VNC console SMF service "
raise
"""Disable a zone VNC console SMF service"""
"console SMF service for instance '%s'") % name)
return
# TODO(npower): investigate using RAD instead of CLI invocation
try:
# The console service sets a SMF instance property for the port
# on which the VNC service is listening. The service needs to be
# refreshed to reset the property value
try:
'refresh')
"""Returns state of the instance zone VNC console SMF service"""
"VNC console SMF service for instance '%s'")
% name)
return None
# TODO(npower): investigate using RAD instead of CLI invocation
try:
"SMF service for instance '%s': %s")
raise
"""Returns True if the instance has a zone VNC console SMF service"""
# TODO(npower): investigate using RAD instead of CLI invocation
try:
return True
except Exception:
return False
"""Install a new Solaris Zone root file system."""
if zone is None:
# log the zone's configuration
# the directory isn't empty so pass it along to install
try:
raise
"""Power on a Solaris Zone."""
if zone is None:
bootargs = []
persistent = 'False'
# Get any bootargs already set in the zone
# Get any bootargs set in the instance metadata by the user
if meta_bootargs:
'False'))
# Temporarily clear bootargs in zone config
try:
finally:
# We have consumed the metadata bootargs and
# the user asked for them not to be persistent so
# clear them out now.
if reset_bootargs:
# restore original boot args in zone config
"""Uninstall an existing Solaris Zone root file system."""
if zone is None:
return
try:
raise
"""Delete an existing Solaris Zone configuration."""
try:
raise
Once this successfully completes, the instance should be
running (power_state.RUNNING).
If this fails, any partial instance should be completely
cleaned up, and the virtualization platform should be in the state
that it was before this call began.
:param context: security context
:param instance: nova.objects.instance.Instance
This function should use the data there to guide
the creation of the new instance.
:param image_meta: image object returned by nova.image.glance that
defines the image from which to boot this instance
:param injected_files: User files to inject into instance.
:param admin_password: Administrator password to set in instance.
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: Information about block devices to be
attached to the instance.
"""
# create a new directory for SC profiles
# Attempt to provision a (Cinder) volume service backed boot volume
# c1d0 is the standard dev for for default boot device.
# Irrelevant value for ZFS, but Cinder gets stroppy without it.
mountpoint = "c1d0"
try:
# This Cinder volume is not usable for ZOSS so discard it.
# zonecfg will apply default zonepath dataset configuration
# instead. Carry on
connection_info = None
# Something really bad happened. Don't pass Go.
# remove the sc_profile temp directory
raise
try:
if installed:
if configured:
if connection_info is not None:
raise
finally:
# remove the sc_profile temp directory
if connection_info is not None:
# there's only one bdm for this instance at this point
# update the required attributes
"""Power off a Solaris Zone."""
if zone is None:
try:
if halt_type == 'SOFT':
else:
# 'HARD'
"trying to power off instance '%s' via "
return
"""Reverts the zones configuration to pre-resize config
"""
if old_rvid:
"""Destroy the specified instance from the Hypervisor.
If the instance is not found (for example if networking failed), this
function should still succeed. It's probably a good idea to log a
warning in that case.
:param context: security context
:param instance: Instance object as returned by DB layer.
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: Information about block devices that should
be detached from the instance.
:param destroy_disks: Indicates if disks should be destroyed
:param migrate_data: implementation specific params
"""
return
# A destroy is issued for the original zone for an evac case. If
# the evac fails we need to protect the zone from deletion when
# power comes back on.
return
try:
# These methods log if problems occur so no need to double log
# here. Just catch any stray exceptions and allow destroy to
# proceed.
except Exception:
pass
# If instance cannot be found, just return.
if zone is None:
% name)
return
try:
# One last point of house keeping. If we are deleting the instance
# during a resize operation we want to make sure the cinder volumes are
# properly cleaned up. We need to do this here, because the periodic
# task that comes along and cleans these things up isn't nice enough to
# pass a context in so that we could simply do the work there. But
# because we have access to a context, we can handle the work here and
# let the periodic task simply clean up the left over zone
# configuration that might be left around. Note that the left over
# zone will only show up in zoneadm list, not nova list.
#
# If the task state is RESIZE_REVERTING do not process these because
# the cinder volume cleanup is taken care of in
# finish_revert_migration.
return
if volid:
try:
except Exception:
pass
"""Cleanup the instance resources .
Instance should have been destroyed from the Hypervisor before calling
this method.
:param context: security context
:param instance: Instance object as returned by DB layer.
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: Information about block devices that should
be detached from the instance.
:param destroy_disks: Indicates if disks should be destroyed
:param migrate_data: implementation specific params
"""
raise NotImplementedError()
block_device_info=None, bad_volumes_callback=None):
"""Reboot the specified instance.
After this is called successfully, the instance's state
goes back to power_state.RUNNING. The virtualization
platform should ensure that the reboot action has completed
:param instance: nova.objects.instance.Instance
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param reboot_type: Either a HARD or SOFT reboot
:param block_device_info: Info pertaining to attached volumes
:param bad_volumes_callback: Function to handle any bad volumes
encountered
"""
if zone is None:
return
bootargs = []
persistent = 'False'
# Get any bootargs already set in the zone
# Get any bootargs set in the instance metadata by the user
if meta_bootargs:
'False'))
# Temporarily clear bootargs in zone config
try:
if reboot_type == 'SOFT':
else:
finally:
# We have consumed the metadata bootargs and
# the user asked for them not to be persistent so
# clear them out now.
if reset_bootargs:
# restore original boot args in zone config
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Builds a string containing the console output (capped at
MAX_CONSOLE_BYTES characters) by reassembling the log files
that Solaris Zones framework maintains for each zone.
"""
console_str = ""
# Examine the log files in most-recently modified order, keeping
# track of the size of each file and of how many characters have
# been seen. If there are still characters left to incorporate,
# then the contents of the log file in question are prepended to
# the console string built so far. When the number of characters
# available has run out, the last fragment under consideration
# will likely begin within the middle of a line. As such, the
# start of the fragment up to the next newline is thrown away.
# The remainder constitutes the start of the resulting console
# output which is then prepended to the console string built so
# far and the result returned.
if size == 0:
continue
if avail < 0:
break
fragment = ''
return console_str
"""Get console output for an instance
:param context: security context
:param instance: nova.objects.instance.Instance
"""
"""Get connection info for a vnc console.
:param context: security context
:param instance: nova.objects.instance.Instance
:returns an instance of console.type.ConsoleVNC
"""
# Do not provide console access prematurely. Zone console access is
# exclusive and zones that are still installing require their console.
# Grabbing the zone console will break installation.
"completed installation. Try again later.") % name)
"instance '%s'") % name)
# The console service sets an SMF instance property for the port
# on which the VNC service is listening. The service needs to be
# refreshed to reflect the current property value
# TODO(npower): investigate using RAD instead of CLI invocation
try:
'refresh')
raise
try:
internal_access_path=None)
"console SMF service '%s': %s"
% (console_fmri, reason)))
"""Get connection info for a spice console.
:param context: security context
:param instance: nova.objects.instance.Instance
:returns an instance of console.type.ConsoleSpice
"""
raise NotImplementedError()
"""Get connection info for a rdp console.
:param context: security context
:param instance: nova.objects.instance.Instance
:returns an instance of console.type.ConsoleRDP
"""
raise NotImplementedError()
"""Get connection info for a serial console.
:param context: security context
:param instance: nova.objects.instance.Instance
:returns an instance of console.type.ConsoleSerial
"""
raise NotImplementedError()
"""Return data about Solaris Zone diagnostics."""
return None
diagnostics = {}
if kstat_data is not None:
if kstat_data is not None:
if kstat_data is not None:
'sys_zone_aggr')
if kstat_data is not None:
return diagnostics
"""Return data about VM diagnostics.
:param instance: nova.objects.instance.Instance
"""
# TODO(Vek): Need to pass context in for access to auth_token
if zone is None:
"""Return data about VM diagnostics.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Return bandwidth usage counters for each interface on each
running VM.
:param instances: nova.objects.instance.InstanceList
"""
raise NotImplementedError()
"""Return usage info for volumes attached to vms on
a given host.-
"""
raise NotImplementedError()
"""Retrieves the IP address of the dom0
"""
# TODO(Vek): Need to pass context in for access to auth_token
"""Attach the disk to the instance at mountpoint using info."""
# TODO(npower): Apply mountpoint in a meaningful way to the zone
# For security reasons this is not permitted in a Solaris branded zone.
if zone is None:
if brand != ZONE_BRAND_SOLARIS_KZ:
# Only Solaris kernel zones are currently supported.
reason = (_("'%s' branded zones are not currently supported")
% brand)
raise NotImplementedError(reason)
# apply the configuration to the running zone
try:
suri)])
raise
encryption=None):
"""Detach the disk attached to the instance."""
if zone is None:
if brand != ZONE_BRAND_SOLARIS_KZ:
# Only Solaris kernel zones are currently supported.
reason = (_("'%s' branded zones are not currently supported")
% brand)
raise NotImplementedError(reason)
# Check if the specific property value exists before attempting removal
if not prop:
return
# apply the configuration to the running zone
"""Replace the disk attached to the instance.
:param instance: nova.objects.instance.Instance
:param resize_to: This parameter is used to indicate the new volume
size when the new volume lager than old volume.
And the units is Gigabyte.
"""
raise NotImplementedError()
"""Attach an interface to the instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Detach an interface from the instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Make a best effort at cleaning up the volume that was created to
hold the new root disk
:param volume: new volume created by the call to cinder create
"""
try:
block_device_info=None,
"""Transfers the disk of a running instance in multiple phases, turning
off the instance before the end.
:param instance: nova.objects.instance.Instance
:param timeout: time to wait for GuestOS to shutdown
:param retry_interval: How often to signal guest while
waiting for it to shutdown
"""
if samehost:
reason = (_("'%s' branded zones do not currently support resize "
"to a different host.") % brand)
reason = (_("Unable to change brand of zone during resize."))
msg = (_("Unable to resize to a smaller boot volume."))
disk_info = None
break
else:
# If this is a non-global zone that is on the same host and is
# simply using a dataset, the disk size is purely an OpenStack
# quota. We can continue without doing any disk work.
return disk_info
else:
msg = (_("Cannot find an attached root device."))
else:
if volume_id is None:
msg = (_("Cannot find an attached root device."))
vinfo['display_name'] +
'-resized',
vinfo['display_description'],
# creating a new volume, so we do likewise here.
while True:
break
try:
except Exception:
raise
return disk_info
"""Snapshots the specified instance.
:param context: security context
:param instance: nova.objects.instance.Instance
:param image_id: Reference to a pre-created image that will
hold the snapshot.
"""
# Get original base image info
try:
except exception.ImageNotFound:
base = {}
# Build updated snapshot image metadata
metadata = {
'is_public': False,
'status': 'active',
'properties': {
'image_location': 'snapshot',
'image_state': 'available',
}
}
# Match architecture, hypervisor_type and vm_mode properties to base
# image.
# Set generic container and disk formats initially in case the glance
# service rejects Unified Archives (uar) and ZFS in metadata.
try:
# Upload the archive image to the image service
try:
# Try to update the image metadata container and disk
# formats more suitably for a unified archive if the
# glance server recognises them.
None)
"container and disk formats 'uar' and "
"'zfs'. Using generic values 'ovf' and "
"'raw' as fallbacks."))
finally:
# Delete the snapshot image file source
"""Cleans up any resources left after an interrupted snapshot.
:param context: security context
:param instance: nova.objects.instance.Instance
"""
pass
"""Best effort attempt at cleaning up any additional resources that are
not directly managed by Nova or Cinder so as not to leak these
resources.
"""
if disk_info:
if old_rvid:
if not samehost:
"""Completes a resize.
:param disk_info: the newly transferred disk information
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param image_meta: image object returned by nova.image.glance that
defines the image from which this instance
was created
:param resize_instance: True if the instance is being resized,
False otherwise
:param block_device_info: instance volume block device info
:param power_on: True if the instance should be powered on, False
otherwise
"""
if not resize_instance:
raise NotImplementedError()
if samehost:
if disk_info:
break
try:
if samehost:
# Add the new disk to the volume if the size of the disk
# changed
if disk_info:
root_ci['serial'],
disk_info['id'],
else:
# No need to check disk_info here, because when not on the
# same host a disk_info is always passed in.
mount_dev = 'c1d0'
disk_info['id'],
0, mount_dev,
connection_info, None)
if zone is None:
entry['mount_device'])
if power_on:
if brand == ZONE_BRAND_SOLARIS:
return
# Toggle the autoexpand to extend the size of the rpool.
# We need to sleep for a few seconds to make sure the zone
# is in a state to accept the toggle. Once bugs are fixed
# around the autoexpand and the toggle is no longer needed
# or zone.boot() returns only after the zone is ready we
# can remove this hack.
'autoexpand=off', 'rpool')
'autoexpand=on', 'rpool')
except Exception:
# Attempt to cleanup the new zone and new volume to at least
# give the user a chance to recover without too many hoops
raise
"""Confirms a resize, destroying the source VM.
:param instance: nova.objects.instance.Instance
"""
{'display_name': new_vname})
if not samehost:
else:
"""Handles the zone root volume switch-over or simply
initializing the connection for the new zone if not resizing to the
same host
:param context: the context for the _resize_disk_migration
:param instance: nova.objects.instance.Instance being resized
:param configured: id of the current configured volume
:param replacement: id of the new volume
:param newvolumesz: size of the new volume
:param mountdev: the mount point of the device
:param samehost: is the resize happening on the same host
"""
if samehost:
if zone is None:
# Need to detach the zone and re-attach the zone if this is a
# non-global zone so that the update of the rootzpool resource does
# not fail.
try:
finally:
try:
except Exception:
raise
try:
except Exception:
raise
if not samehost:
return connection_info
"""Finish reverting a resize.
:param context: the context for the finish_revert_migration
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: instance volume block device info
:param power_on: True if the instance should be powered on, False
otherwise
"""
# If this is not a samehost migration then we need to re-attach the
# original volume to the instance. Otherwise we need to update the
# original zone configuration.
if samehost:
if old_rvid:
else:
if new_rvid:
"""Pause the specified instance.
:param instance: nova.objects.instance.Instance
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Unpause paused VM instance.
:param instance: nova.objects.instance.Instance
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""suspend the specified instance.
:param context: the context for the suspend
:param instance: nova.objects.instance.Instance
"""
if zone is None:
# Only Solaris kernel zones are currently supported.
reason = (_("'%s' branded zones do not currently support "
"suspend. Use 'nova reset-state --active %s' "
"to reset instance state back to 'active'.")
try:
# add suspend if not configured
# replace the old suspend resource with the new one
"""resume the specified instance.
:param context: the context for the resume
:param instance: nova.objects.instance.Instance being resumed
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param block_device_info: instance volume block device info
"""
if zone is None:
# Only Solaris kernel zones are currently supported.
reason = (_("'%s' branded zones do not currently support "
# check that the instance is suspended
try:
block_device_info=None):
"""resume guest state when a host is booted.
:param instance: nova.objects.instance.Instance
"""
if zone is None:
# TODO(dcomay): Should reconcile with value of zone's autoboot
# property.
return
"""Rescue the specified instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Unrescue the specified instance.
:param instance: nova.objects.instance.Instance
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Power off the specified instance.
:param instance: nova.objects.instance.Instance
:param timeout: time to wait for GuestOS to shutdown
:param retry_interval: How often to signal guest while
waiting for it to shutdown
"""
block_device_info=None):
"""Power on the specified instance.
:param instance: nova.objects.instance.Instance
"""
"""Soft delete the specified instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Restore the specified instance.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Get the value of property from the zpool."""
try:
value = None
return value
return value
"""Update currently known host stats."""
host_stats = {}
if size is not None:
else:
# Account for any existing processor sets by looking at the the
# number of CPUs not assigned to any processor sets.
if kstat_data is not None:
host_stats['vcpus_used'] = \
else:
# Subtract the number of free pages from the total to get the
# used.
'system_pages')
if kstat_data is not None:
host_stats['memory_mb_used'] = \
else:
if free is not None:
else:
free_disk_gb = 0
host_stats['hypervisor_version'] = \
architecture = 'x86_64'
else:
architecture = 'sparc64'
cpu_info = {
'arch': architecture
}
]
host_stats['supported_instances'] = \
"""Retrieve resource information.
This method is called when nova-compute launches, and
as part of a periodic task that records the results in the DB.
:param nodename:
node which the caller want to get resources from
a driver that manages only one node can safely ignore this
:returns: Dictionary describing resources
"""
resources = {}
return resources
"""Prepare an instance for live migration
:param context: security context
:param instance: nova.objects.instance.Instance object
:param block_device_info: instance block device information
:param network_info: instance network information
:param disk_info: instance disk information
:param migrate_data: implementation specific data dict.
"""
return {}
"""Live migration of a Solaris kernel zone to another host."""
if zone is None:
options = []
if live_migration_cipher is not None:
if dry_run:
migrate_data=None):
"""Live migration of an instance to another host.
:param context: security context
:param instance:
nova.db.sqlalchemy.models.Instance object
instance object that is migrated.
:param dest: destination host
:param post_method:
post operation method.
expected nova.compute.manager._post_live_migration.
:param recover_method:
recovery method when any exception occurs.
expected nova.compute.manager._rollback_live_migration.
:param block_migration: if true, migrate VM disk.
:param migrate_data: implementation specific params.
"""
try:
with excutils.save_and_reraise_exception():
"'%s' via zonemgr(3RAD): %s")
migrate_data=None):
"""Clean up destination node after a failed live migration.
:param context: security context
:param instance: instance object that was being migrated
:param network_info: instance network information
:param block_device_info: instance block device information
:param destroy_disks:
if true, destroy disks at destination during cleanup
:param migrate_data: implementation specific params
"""
pass
migrate_data=None):
"""Post operation of live migration at source host.
:param context: security context
:instance: instance object that was migrated
:block_device_info: instance block device information
:param migrate_data: if not None, it is a dict which has data
"""
try:
# These methods log if problems occur so no need to double log
# here. Just catch any stray exceptions and allow destroy to
# proceed.
except Exception:
pass
# If instance cannot be found, just return.
if zone is None:
% name)
return
try:
raise
"""Unplug VIFs from networks at source.
:param context: security context
:param instance: instance object reference
:param network_info: instance network information
"""
raise NotImplementedError(_("Hypervisor driver does not support "
"post_live_migration_at_source method"))
block_device_info=None):
"""Post operation of live migration at destination host.
:param context: security context
:param instance: instance object that is migrated
:param network_info: instance network information
:param block_migration: if true, post operation of block_migration.
"""
pass
"""Check if instance files located on shared storage.
This runs check on the destination host, and then calls
back to the source host to check the results.
:param context: security context
:param instance: nova.objects.instance.Instance object
"""
raise NotImplementedError()
"""Check if instance files located on shared storage.
:param context: security context
:param data: result of check_instance_shared_storage_local
"""
raise NotImplementedError()
"""Do cleanup on host after check_instance_shared_storage calls
:param context: security context
:param data: result of check_instance_shared_storage_local
"""
pass
"""Check if it is possible to execute live migration.
This runs checks on the destination host, and then calls
back to the source host to check the results.
:param context: security context
:param instance: nova.db.sqlalchemy.models.Instance
:param src_compute_info: Info about the sending machine
:param dst_compute_info: Info about the receiving machine
:param block_migration: if true, prepare for block migration
:param disk_over_commit: if true, allow disk over commit
:returns: a dict containing migration info (hypervisor-dependent)
"""
if src_cpu_arch != dst_cpu_arch:
reason = (_("CPU architectures between source host '%s' (%s) and "
"destination host '%s' (%s) are incompatible.")
dst_compute_info['hypervisor_hostname'],
if brand != ZONE_BRAND_SOLARIS_KZ:
# Only Solaris kernel zones are currently supported.
reason = (_("'%s' branded zones do not currently support live "
"migration.") % brand)
if block_migration:
reason = (_('Block migration is not currently supported.'))
if disk_over_commit:
reason = (_('Disk overcommit is not currently supported.'))
dest_check_data = {
}
return dest_check_data
"""Do required cleanup on dest host after check_can_live_migrate calls
:param context: security context
:param dest_check_data: result of check_can_live_migrate_destination
"""
pass
"""Check if local volumes are attached to the instance."""
if driver_type == 'local':
reason = (_("Instances with attached '%s' volumes are not "
"currently supported.") % driver_type)
dest_check_data, block_device_info=None):
"""Check if it is possible to execute live migration.
This checks if the live migration can succeed, based on the
results from check_can_live_migrate_destination.
:param context: security context
:param instance: nova.db.sqlalchemy.models.Instance
:param dest_check_data: result of check_can_live_migrate_destination
:param block_device_info: result of _get_instance_block_device_info
:returns: a dict containing migration info (hypervisor-dependent)
"""
try:
return dest_check_data
block_device_info=None):
"""Retrieve information about actual disk sizes of an instance.
:param instance: nova.objects.Instance
:param block_device_info:
Optional; Can be used to filter out devices which are
actually volumes.
:return:
json strings with below format::
"[{'path':'disk',
'type':'raw',
'virt_disk_size':'10737418240',
'backing_file':'backing_file',
'disk_size':'83886080'
'over_committed_disk_size':'10737418240'},
...]"
"""
raise NotImplementedError()
"""This method is called after a change to security groups.
All security groups and their associated rules live in the datastore,
and calling this method should apply the updated rules to instances
running the specified security group.
An error should be raised if the operation cannot complete.
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""This method is called when a security group is added to an instance.
This message is sent to the virtualization drivers on hosts that are
running an instance that belongs to a security group that has a rule
that references the security group identified by `security_group_id`.
It is the responsibility of this method to make sure any rules
that authorize traffic flow with members of the security group are
updated and any new members can communicate, and any removed members
cannot.
Scenario:
* we are running on host 'H0' and we have an instance 'i-0'.
* instance 'i-0' is a member of security group 'speaks-b'
* group 'speaks-b' has an ingress rule that authorizes group 'b'
* another host 'H1' runs an instance 'i-1'
* instance 'i-1' is a member of security group 'b'
When 'i-1' launches or terminates we will receive the message
to update members of group 'b', at which time we will make
any changes needed to the rules for instance 'i-0' to allow
or deny traffic coming from 'i-1', depending on if it is being
added or removed from the group.
In this scenario, 'i-1' could just as easily have been running on our
host 'H0' and this method would still have been called. The point was
that this method isn't called on the host where instances of that
group are running (as is the case with
:py:meth:`refresh_security_group_rules`) but is called where references
are made to authorizing those instances.
An error should be raised if the operation cannot complete.
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""This triggers a firewall update based on database changes.
When this is called, rules have either been added or removed from the
datastore. You can retrieve rules with
:py:meth:`nova.db.provider_fw_rule_get_all`.
Provider rules take precedence over security group rules. If an IP
would be allowed by a security group ingress rule, but blocked by
a provider rule, then packets from the IP are dropped. This includes
intra-project traffic in the case of the allow_project_net_traffic
flag for the libvirt-derived classes.
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Refresh security group rules
Gets called when an instance gets added to or removed from
the security group the instance is a member of or if the
group gains or loses a rule.
"""
raise NotImplementedError()
"""reset networking for specified instance."""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Setting up filtering rules and waiting for its completion.
To migrate an instance, filtering rules to hypervisors
and firewalls are inevitable on destination host.
( Waiting only for filtering rules to hypervisor,
since filtering rules to firewall rules can be set faster).
Concretely, the below method must be called.
- setup_basic_filtering (for nova-basic, etc.)
- prepare_instance_filter(for nova-instance-instance-xxx, etc.)
to_xml may have to be called since it defines PROJNET, PROJMASK.
but libvirt migrates those value through migrateToURI(),
so , no need to be called.
Don't use thread for this method since migration should
not be started when setting-up filtering rules operations
are not completed.
:param instance: nova.objects.instance.Instance object
"""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Defer application of IPTables rules."""
pass
"""Turn off deferral of IPTables rules and apply the rules now."""
pass
"""Stop filtering instance."""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Set the root password on the specified instance.
:param instance: nova.objects.instance.Instance
:param new_pass: the new password
"""
if zone is None:
else:
"""Writes a file on the specified instance.
The first parameter is an instance of nova.compute.service.Instance,
and so the instance is being specified as instance.name. The second
parameter is the base64-encoded path to which the file is to be
written on the instance; the third is the contents of the file, also
base64-encoded.
NOTE(russellb) This method is deprecated and will be removed once it
can be removed from nova.compute.manager.
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Applies a diff to the instance metadata.
This is an optional driver method which is used to publish
changes to the instance's metadata to the hypervisor. If the
hypervisor has no means of publishing the instance metadata to
the instance, then this method should not be implemented.
:param context: security context
:param instance: nova.objects.instance.Instance
"""
pass
"""inject network info for specified instance."""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Poll for rebooting instances
:param timeout: the currently configured timeout for considering
rebooting instances to be stuck
:param instances: instances that have been in rebooting state
longer than the configured timeout
"""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Reboots, shuts down or powers up the host."""
raise NotImplementedError()
guest VMs evacuation.
"""
raise NotImplementedError()
"""Sets the specified host's ability to accept new instances."""
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
"""Returns the result of calling "uptime" on the target host."""
# TODO(Vek): Need to pass context in for access to auth_token
"""Plug VIFs into networks.
:param instance: nova.objects.instance.Instance
"""
# TODO(Vek): Need to pass context in for access to auth_token
pass
"""Unplug VIFs from networks.
:param instance: nova.objects.instance.Instance
"""
raise NotImplementedError()
"""Get the currently known host CPU stats.
:returns: a dict containing the CPU stat info, eg:
| {'kernel': kern,
| 'idle': idle,
| 'user': user,
| 'iowait': wait,
| 'frequency': freq},
where kern and user indicate the cumulative CPU time
(nanoseconds) spent by kernel and user processes
respectively, idle indicates the cumulative idle CPU time
(nanoseconds), wait indicates the cumulative I/O wait CPU
time (nanoseconds), since the host is booting up; freq
indicates the current CPU frequency (MHz). All values are
long integers.
"""
raise NotImplementedError()
"""Return performance counters associated with the given disk_id on the
given instance. These are returned as [rd_req, rd_bytes, wr_req,
wr_bytes, errs], where rd indicates read, wr indicates write, req is
the total number of I/O requests made, bytes is the total number of
bytes transferred, and errs is the number of requests held up due to a
full pipeline.
All counters are long integers.
This method is optional. On some platforms (e.g. XenAPI) performance
statistics can be retrieved directly in aggregate form, without Nova
having to do the aggregation. On those platforms, this method is
unused.
Note that this function takes an instance ID.
"""
raise NotImplementedError()
"""Does the driver want networks deallocated on reschedule?"""
return False
"""What MAC addresses must this instance have?
Some hypervisors (such as bare metal) cannot do freeform virtualisation
of MAC addresses. This method allows drivers to return a set of MAC
addresses that the instance is to have. allocate_for_instance will take
this into consideration when provisioning networking for the instance.
Mapping of MAC addresses to actual networks (or permitting them to be
freeform) is up to the network implementation layer. For instance,
with openflow switches, fixed MAC addresses can still be virtualised
onto any L2 domain, with arbitrary VLANs etc, but regular switches
require pre-configured MAC->network mappings that will match the
actual configuration.
Most hypervisors can use the default implementation which returns None.
Hypervisors with MAC limits should return a set of MAC addresses, which
will be supplied to the allocate_for_instance call by the compute
manager, and it is up to that call to ensure that all assigned network
details are compatible with the set of MAC addresses.
This is called during spawn_instance by the compute manager.
:return: None, or a set of MAC ids (e.g. set(['12:34:56:78:90:ab'])).
None means 'no constraints', a set means 'these and only these
MAC addresses'.
"""
return None
"""Get DHCP options for this instance.
Some hypervisors (such as bare metal) require that instances boot from
the network, and manage their own TFTP service. This requires passing
the appropriate options out to the DHCP service. Most hypervisors can
use the default implementation which returns None.
This is called during spawn_instance by the compute manager.
Note that the format of the return value is specific to Quantum
client API.
:return: None, or a set of DHCP options, eg:
| [{'opt_name': 'bootfile-name',
| {'opt_name': 'server-ip-address',
| 'opt_value': '1.2.3.4'},
| {'opt_name': 'tftp-server',
| 'opt_value': '1.2.3.4'}
| ]
"""
return None
"""Manage the driver's local image cache.
Some drivers chose to cache images for instances on disk. This method
is an opportunity to do management of that cache which isn't directly
related to other calls into the driver. The prime example is to clean
the cache and remove images which are no longer of interest.
:param all_instances: nova.objects.instance.InstanceList
"""
pass
"""Add a compute host to an aggregate."""
# NOTE(jogo) Currently only used for XenAPI-Pool
raise NotImplementedError()
"""Remove a compute host from an aggregate."""
raise NotImplementedError()
"""Undo for Resource Pools."""
raise NotImplementedError()
"""Get connector information for the instance for attaching to volumes.
Connector information is a dictionary representing the ip of the
machine that will be making the connection, the name of the iscsi
initiator, the WWPN and WWNN values of the Fibre Channel initiator,
and the hostname of the machine as follows::
{
'ip': ip,
'initiator': initiator,
'wwnns': wwnns,
'wwpns': wwpns,
'host': hostname
}
"""
if not self._initiator:
if self._initiator:
else:
'World Wide Node Names'),
'World Wide Port Names'),
return connector
"""Returns nodenames of all nodes managed by the compute service.
This method is for multi compute-nodes support. If a driver supports
multi compute-nodes, this method returns a list of nodenames managed
by the service. Otherwise, this method should return
[hypervisor_hostname].
"""
return [s['hypervisor_hostname'] for s in stats]
"""Return whether this compute service manages a particular node."""
return True
# Refresh and check again.
"""Get information about instance resource usage.
:returns: dict of nova uuid => dict of usage info
"""
return {}
"""Checks access of instance files on the host.
:param instance: nova.objects.instance.Instance to lookup
Returns True if files of an instance with the supplied ID accessible on
the host, False otherwise.
.. note::
Used in rebuild for HA implementation and required for validation
of access to instance shared disk files
"""
instance['uuid'])
root_ci = None
if entry['connection_info'] is None:
continue
break
if root_ci is None:
msg = (_("Unable to find the root device for instance '%s'.")
% instance['name'])
return driver_type in shared_storage
"""Register a callback to receive events.
Register a callback to receive asynchronous event
notifications from hypervisors. The callback will
be invoked with a single parameter, which will be
an instance of the nova.virt.event.Event class.
"""
"""Dispatches an event to the compute manager.
Invokes the event callback registered by the
compute manager to dispatch the event. This
must only be invoked from a green thread.
"""
if not self._compute_event_callback:
return
raise ValueError(
_("Event must be an instance of nova.virt.event.Event"))
try:
"""Delete any lingering instance files for an instance.
:param instance: nova.objects.instance.Instance
:returns: True if the instance was deleted from disk, False otherwise.
"""
# Delete the zone configuration for the instance using destroy, because
# it will simply take care of the work, and we don't need to duplicate
# the code here.
try:
except Exception:
return False
return True
"""Tell the caller if the driver requires legacy block device info.
Tell the caller whether we expect the legacy format of block
device info to be passed in to methods that expect it.
"""
return True
"""Snapshots volumes attached to a specified instance.
:param context: request context
:param instance: nova.objects.instance.Instance that has the volume
attached
:param volume_id: Volume to be snapshotted
:param create_info: The data needed for nova to be able to attach
to the volume. This is the same data format returned by
Cinder's initialize_connection() API call. In the case of
doing a snapshot, it is the image file Cinder expects to be
used as the active disk after the snapshot operation has
completed. There may be other data included as well that is
needed for creating the snapshot.
"""
raise NotImplementedError()
"""Snapshots volumes attached to a specified instance.
:param context: request context
:param instance: nova.objects.instance.Instance that has the volume
attached
:param volume_id: Attached volume associated with the snapshot
:param snapshot_id: The snapshot to delete.
:param delete_info: Volume backend technology specific data needed to
be able to complete the snapshot. For example, in the case of
qcow2 backed snapshots, this would include the file being
merged, and the file being merged into (if appropriate).
"""
raise NotImplementedError()
"""Provide a default root device name for the driver."""
raise NotImplementedError()
"""Default the missing device names in the block device mapping."""
raise NotImplementedError()
"""Check whether the file format is supported by this driver
:param fs_type: the file system type to be checked,
the validate values are defined at disk API module.
"""
# NOTE(jichenjc): Return False here so that every hypervisor
# need to define their supported file system
# type and implement this function at their
# virt layer.
return False
"""Quiesce the specified instance to prepare for snapshots.
If the specified instance doesn't support quiescing,
InstanceQuiesceNotSupported is raised. When it fails to quiesce by
other errors (e.g. agent timeout), NovaException is raised.
:param context: request context
:param instance: nova.objects.instance.Instance to be quiesced
:param image_meta: image object returned by nova.image.glance that
defines the image from which this instance
was created
"""
raise NotImplementedError()
"""Unquiesce the specified instance after snapshots.
If the specified instance doesn't support quiescing,
InstanceQuiesceNotSupported is raised. When it fails to quiesce by
other errors (e.g. agent timeout), NovaException is raised.
:param context: request context
:param instance: nova.objects.instance.Instance to be unquiesced
:param image_meta: image object returned by nova.image.glance that
defines the image from which this instance
was created
"""
raise NotImplementedError()