Compute-related Utilities and helpers.
- 
class EventReporter(context, event_name, *instance_uuids)
 
Bases: object
Context manager to report instance action events.
- 
class UnlimitedSemaphore
 
Bases: object
- 
balance
 
- 
add_instance_fault_from_exc(context, instance, fault, exc_info=None, fault_message=None)
 
Adds the specified fault to the database.
- 
default_device_names_for_instance(instance, root_device_name, *block_device_lists)
 
Generate missing device names for an instance.
- 
downsize_quota_delta(context, instance)
 
Calculate deltas required to adjust quota for an instance downsize.
- 
exception_to_dict(fault, message=None)
 
Converts exceptions to a dict for use in notifications.
- 
get_device_name_for_instance(instance, bdms, device)
 
Validates (or generates) a device name for instance.
This method is a wrapper for get_next_device_name that gets the list
of used devices and the root device from a block device mapping.
- 
get_machine_ips()
 
Get the machine’s ip addresses
| Returns: | list of Strings of ip addresses | 
- 
get_next_device_name(instance, device_name_list, root_device_name=None, device=None)
 
Validates (or generates) a device name for instance.
If device is not set, it will generate a unique device appropriate
for the instance. It uses the root_device_name (if provided) and
the list of used devices to find valid device names. If the device
name is valid but applicable to a different backend (for example
/dev/vdc is specified but the backend uses /dev/xvdc), the device
name will be converted to the appropriate format.
- 
get_nw_info_for_instance(instance)
 
- 
get_reboot_type(task_state, current_power_state)
 
Checks if the current instance state requires a HARD reboot.
- 
get_value_from_system_metadata(instance, key, type, default)
 
Get a value of a specified type from image metadata.
@param instance: The instance object
@param key: The name of the property to get
@param type: The python type the value is be returned as
@param default: The value to return if key is not set or not the right type
- 
notify_about_aggregate_update(context, event_suffix, aggregate_payload)
 
Send a notification about aggregate update.
| Parameters: | 
- event_suffix – Event type like “create.start” or “create.end”
 
- aggregate_payload – payload for aggregate update
 
 
 | 
- 
notify_about_host_update(context, event_suffix, host_payload)
 
Send a notification about host update.
| Parameters: | 
- event_suffix – Event type like “create.start” or “create.end”
 
- host_payload – payload for host update. It is a dict and there
should be at least the ‘host_name’ key in this
dict.
 
 
 | 
- 
notify_about_instance_usage(notifier, context, instance, event_suffix, network_info=None, system_metadata=None, extra_usage_info=None, fault=None)
 
Send a notification about an instance.
| Parameters: | 
- notifier – a messaging.Notifier
 
- event_suffix – Event type like “delete.start” or “exists”
 
- network_info – Networking information, if provided.
 
- system_metadata – system_metadata DB entries for the instance,
if provided.
 
- extra_usage_info – Dictionary containing extra values to add or
override in the notification.
 
 
 | 
- 
notify_about_server_group_update(context, event_suffix, sg_payload)
 
Send a notification about server group update.
| Parameters: | 
- event_suffix – Event type like “create.start” or “create.end”
 
- sg_payload – payload for server group update
 
 
 | 
- 
notify_usage_exists(notifier, context, instance_ref, current_period=False, ignore_missing_network_data=True, system_metadata=None, extra_usage_info=None)
 
Generates ‘exists’ notification for an instance for usage auditing
purposes.
| Parameters: | 
- notifier – a messaging.Notifier
 
- current_period – if True, this will generate a usage for the
current usage period; if False, this will generate a usage for the
previous audit period.
 
- ignore_missing_network_data – if True, log any exceptions generated
while getting network info; if False, raise the exception.
 
- system_metadata – system_metadata DB entries for the instance,
if not None.  NOTE: Currently unused here in trunk, but needed for
potential custom modifications.
 
- extra_usage_info – Dictionary containing extra values to add or
override in the notification if not None.
 
 
 | 
- 
refresh_info_cache_for_instance(context, instance)
 
Refresh the info cache for an instance.
| Parameters: | instance – The instance object. | 
- 
remove_shelved_keys_from_system_metadata(instance)
 
- 
reserve_quota_delta(context, deltas, instance)
 
If there are deltas to reserve, construct a Quotas object and
reserve the deltas for the given project.
| Parameters: | 
- context – The nova request context.
 
- deltas – A dictionary of the proposed delta changes.
 
- instance – The instance we’re operating on, so that
quotas can use the correct project_id/user_id.
 
 
 | 
| Returns: | nova.objects.quotas.Quotas 
 | 
- 
resize_quota_delta(context, new_flavor, old_flavor, sense, compare)
 
Calculate any quota adjustment required at a particular point
in the resize cycle.
| Parameters: | 
- context – the request context
 
- new_flavor – the target instance type
 
- old_flavor – the original instance type
 
- sense – the sense of the adjustment, 1 indicates a
forward adjustment, whereas -1 indicates a
reversal of a prior adjustment
 
- compare – the direction of the comparison, 1 indicates
we’re checking for positive deltas, whereas
-1 indicates negative deltas
 
 
 | 
- 
reverse_upsize_quota_delta(context, instance)
 
Calculate deltas required to reverse a prior upsizing
quota adjustment.
- 
upsize_quota_delta(context, new_flavor, old_flavor)
 
Calculate deltas required to adjust quota for an instance upsize.
- 
usage_volume_info(vol_usage)