The nova.compute.api Module

Handles all requests relating to compute resources (e.g. guest VMs, networking and storage of VMs, and compute hosts on which they run).

class API(image_api=None, network_api=None, volume_api=None, security_group_api=None, skip_policy_check=False, **kwargs)

Bases: nova.db.base.Base

API for interacting with the compute manager.

add_fixed_ip(context, target, *args, **kwargs)

Add fixed_ip from specified network to given instance.

attach_interface(context, target, *args, **kwargs)

Use hotplug to add an network adapter to an instance.

attach_volume(context, target, *args, **kwargs)

Attach an existing volume to an existing instance.

backup(context, target, *args, **kwargs)
cell_type
confirm_resize(context, target, *args, **kwargs)
create(*args, **kwargs)

Provision instances, sending instance information to the scheduler. The scheduler will determine where the instance(s) go and will handle creating the DB entries.

Returns a tuple of (instances, reservation_id)

create_db_entry_for_new_instance(context, instance_type, image, instance, security_group, block_device_mapping, num_instances, index, shutdown_terminate=False)

Create an entry in the DB for this new instance, including any related table updates (such as security group, etc).

This is called by the scheduler after a location for the instance has been determined.

delete(context, target, *args, **kwargs)
delete_instance_metadata(context, target, *args, **kwargs)

Delete the given metadata item from an instance.

detach_interface(context, target, *args, **kwargs)

Detach an network adapter from an instance.

detach_volume(context, target, *args, **kwargs)

Detach a volume from an instance.

evacuate(context, instance, *args, **kw)

Running evacuate to target host.

Checking vm compute host state, if the host not in expected_state, raising an exception.

Parameters:
  • instance – The instance to evacuate
  • host – Target host. if not set, the scheduler will pick up one
  • on_shared_storage – True if instance files on shared storage
  • admin_password – password to set on rebuilt instance
external_instance_event(context, instances, events)
force_delete(context, target, *args, **kwargs)

Force delete an instance in any vm_state/task_state.

force_stop(context, instance, do_cast=True, clean_shutdown=True)
get(context, instance_id, want_objects=False, expected_attrs=None)

Get a single instance with the given instance_id.

get_all(context, search_opts=None, limit=None, marker=None, want_objects=False, expected_attrs=None, sort_keys=None, sort_dirs=None)

Get all instances filtered by one of the given parameters.

If there is no filter and the context is an admin, it will retrieve all instances in the system.

Deleted instances will be returned by default, unless there is a search option that says otherwise.

The results will be sorted based on the list of sort keys in the ‘sort_keys’ parameter (first value is primary sort key, second value is secondary sort ket, etc.). For each sort key, the associated sort direction is based on the list of sort directions in the ‘sort_dirs’ parameter.

get_all_instance_metadata(context, search_filts)
get_all_system_metadata(context, search_filts)
get_console_output(context, target, *args, **kwargs)

Get console output for an instance.

get_diagnostics(context, target, *args, **kwargs)

Retrieve diagnostics for the given instance.

get_instance_diagnostics(context, target, *args, **kwargs)

Retrieve diagnostics for the given instance.

get_instance_host_status(instance)
get_instance_metadata(context, target, *args, **kwargs)

Get all metadata associated with an instance.

get_instances_host_statuses(instance_list)
get_migration_by_id_and_instance(context, migration_id, instance_uuid)

Get the migration of an instance by id.

get_migrations(context, filters)

Get all migrations for the given filters.

get_migrations_in_progress_by_instance(context, instance_uuid, migration_type=None)

Get all migrations of an instance in progress.

get_mks_console(context, target, *args, **kwargs)

Get a url to a MKS console.

get_rdp_connect_info(context, instance, *args, **kwargs)

Used in a child cell to get console info.

get_rdp_console(context, target, *args, **kwargs)

Get a url to an instance Console.

get_serial_console(context, target, *args, **kwargs)

Get a url to a serial console.

get_serial_console_connect_info(context, instance, *args, **kwargs)

Used in a child cell to get serial console.

get_spice_connect_info(context, instance, *args, **kwargs)

Used in a child cell to get console info.

get_spice_console(context, target, *args, **kwargs)

Get a url to an instance Console.

get_vnc_connect_info(context, instance, *args, **kwargs)

Used in a child cell to get console info.

get_vnc_console(context, target, *args, **kwargs)

Get a url to an instance Console.

inject_network_info(context, target, *args, **kwargs)
is_expected_locked_by(context, instance)
is_volume_backed_instance(context, instance, bdms=None)
live_migrate(context, instance, *args, **kwargs)
live_migrate_abort(context, instance, *args, **kwargs)
live_migrate_force_complete(context, instance, *args, **kwargs)
lock(context, target, *args, **kwargs)

Lock the given instance.

static parse_availability_zone(context, availability_zone)
pause(context, target, *args, **kwargs)
reboot(context, target, *args, **kwargs)

Reboot the given instance.

rebuild(context, target, *args, **kwargs)
remove_fixed_ip(context, target, *args, **kwargs)

Remove fixed_ip from specified network to given instance.

rescue(context, target, *args, **kwargs)

Rescue the given instance.

reset_network(context, target, *args, **kwargs)
resize(context, target, *args, **kwargs)
restore(context, target, *args, **kwargs)

Restore a previously deleted (but not reclaimed) instance.

resume(context, target, *args, **kwargs)
revert_resize(context, target, *args, **kwargs)
set_admin_password(context, target, *args, **kwargs)
shelve(context, target, *args, **kwargs)

Shelve an instance.

Shuts down an instance and frees it up to be removed from the hypervisor.

shelve_offload(context, target, *args, **kwargs)

Remove a shelved instance from the hypervisor.

snapshot(context, target, *args, **kwargs)
snapshot_volume_backed(context, instance, *args, **kw)

Snapshot the given volume-backed instance.

Parameters:
  • instance – nova.objects.instance.Instance object
  • name – name of the backup or snapshot
  • extra_properties – dict of extra image properties to include
Returns:

the new image metadata

soft_delete(context, target, *args, **kwargs)
start(context, instance, *args, **kwargs)
stop(context, instance, *args, **kwargs)
suspend(context, target, *args, **kwargs)
swap_volume(context, target, *args, **kwargs)

Swap volume attached to an instance.

trigger_crash_dump(context, instance, *args, **kwargs)
unlock(context, target, *args, **kwargs)

Unlock the given instance.

unpause(context, target, *args, **kwargs)
unrescue(context, target, *args, **kwargs)

Unrescue the given instance.

unshelve(context, target, *args, **kwargs)

Restore a shelved instance.

update_instance_metadata(context, target, *args, **kwargs)

Updates or creates instance metadata.

If delete is True, metadata items that are not specified in the metadata argument will be deleted.

volume_snapshot_create(context, target, *args, **kwargs)
volume_snapshot_delete(context, target, *args, **kwargs)
class AggregateAPI(**kwargs)

Bases: nova.db.base.Base

Sub-set of the Compute Manager API for managing host aggregates.

add_host_to_aggregate(context, *args, **kw)

Adds the host to an aggregate.

create_aggregate(context, *args, **kw)

Creates the model for the aggregate.

delete_aggregate(context, *args, **kw)

Deletes the aggregate.

get_aggregate(context, aggregate_id)

Get an aggregate by id.

get_aggregate_list(context)

Get all the aggregates.

is_safe_to_update_az(context, metadata, aggregate, hosts=None, action_name='Add')

Determine if updates alter an aggregate’s availability zone.

Parameters:
  • context – local context
  • metadata – Target metadata for updating aggregate
  • aggregate – Aggregate to update
  • hosts (list) – Hosts to check. If None, aggregate.hosts is used
Action_name:

Calling method for logging purposes

remove_host_from_aggregate(context, *args, **kw)

Removes host from the aggregate.

update_aggregate(context, *args, **kw)

Update the properties of an aggregate.

update_aggregate_metadata(context, *args, **kw)

Updates the aggregate metadata.

class HostAPI(rpcapi=None)

Bases: nova.db.base.Base

Sub-set of the Compute Manager API for managing host operations.

compute_node_get(context, compute_id)

Return compute node entry for particular integer ID.

compute_node_get_all(context)
compute_node_search_by_hypervisor(context, hypervisor_match)
compute_node_statistics(context)
get_host_uptime(context, host_name)

Returns the result of calling “uptime” on the target host.

host_power_action(context, *args, **kw)

Reboots, shuts down or powers up the host.

instance_get_all_by_host(context, host_name)

Return all instances on the given host.

service_delete(context, service_id)

Deletes the specified service.

service_get_all(context, filters=None, set_zones=False)

Returns a list of services, optionally filtering the results.

If specified, ‘filters’ should be a dictionary containing services attributes and matching values. Ie, to get a list of services for the ‘compute’ topic, use filters={‘topic’: ‘compute’}.

service_get_by_compute_host(context, host_name)

Get service entry for the given compute hostname.

service_update(context, host_name, binary, params_to_update)

Enable / Disable a service.

For compute services, this stops new builds and migrations going to the host.

set_host_enabled(context, *args, **kw)

Sets the specified host’s ability to accept new instances.

set_host_maintenance(context, *args, **kw)

Start/Stop host maintenance window. On start, it triggers guest VMs evacuation.

task_log_get_all(context, task_name, period_beginning, period_ending, host=None, state=None)

Return the task logs within a given range, optionally filtering by host and/or state.

class InstanceActionAPI(db_driver=None)

Bases: nova.db.base.Base

Sub-set of the Compute Manager API for managing instance actions.

action_events_get(context, instance, action_id)
action_get_by_request_id(context, instance, request_id)
actions_get(context, instance)
class KeypairAPI(db_driver=None)

Bases: nova.db.base.Base

Subset of the Compute Manager API for managing key pairs.

create_key_pair(context, *args, **kw)

Create a new key pair.

delete_key_pair(context, *args, **kw)

Delete a keypair by name.

get_key_pair(context, user_id, key_name)

Get a keypair by name.

get_key_pairs(context, user_id)

List key pairs.

get_notifier = <functools.partial object at 0x7f562832ddb8>
import_key_pair(context, *args, **kw)

Import a key pair using an existing public key.

wrap_exception = <functools.partial object at 0x7f562832de10>
class SecurityGroupAPI(skip_policy_check=False, **kwargs)

Bases: nova.db.base.Base, nova.network.security_group.security_group_base.SecurityGroupBase

Sub-set of the Compute API related to managing security groups and security group rules

add_default_rules(context, vals)
add_rules(context, id, name, vals)

Add security group rule(s) to security group.

Note: the Nova security group API doesn’t support adding multiple security group rules at once but the EC2 one does. Therefore, this function is written to support both.

add_to_instance(context, target, *args, **kwargs)

Add security group to the instance.

create_security_group(context, name, description)
default_rule_exists(context, values)

Indicates whether the specified rule values are already defined in the default security group rules.

destroy(context, security_group)
ensure_default(context)

Ensure that a context has a security group.

Creates a security group for the security context if it does not already exist.

Parameters:context – the security context
get(context, name=None, id=None, map_exception=False)
get_all_default_rules(context)
get_default_rule(context, id)
get_instance_security_groups(context, instance, detailed=False)
get_rule(context, id)
id_is_uuid = False
is_associated_with_server(security_group, instance_uuid)

Check if the security group is already associated with the instance. If Yes, return True.

list(context, names=None, ids=None, project=None, search_opts=None)
populate_security_groups(security_groups)
remove_default_rules(context, rule_ids)
remove_from_instance(context, target, *args, **kwargs)

Remove the security group associated with the instance.

remove_rules(context, security_group, rule_ids)
trigger_members_refresh(context, group_ids)

Called when a security group gains a new or loses a member.

Sends an update request to each compute node for each instance for which this is relevant.

trigger_rules_refresh(context, id)

Called when a rule is added to or removed from a security_group.

update_security_group(context, security_group, name, description)
validate_id(id)
validate_property(value, property, allowed)

Validate given security group property.

Parameters:
  • value – the value to validate, as a string or unicode
  • property – the property, either ‘name’ or ‘description’
  • allowed – the range of characters allowed
check_instance_cell(fn)
check_instance_host(function)
check_instance_lock(function)
check_instance_state(vm_state=None, task_state=(None, ), must_have_launched=True)

Decorator to check VM and/or task state before entry to API functions.

If the instance is in the wrong state, or has not been successfully started at least once the wrapper will raise an exception.

check_policy(context, action, target, scope='compute')
policy_decorator(scope)

Check corresponding policy prior of wrapped method to execution.

wrap_check_policy(func)
wrap_check_security_groups_policy(func)

Previous topic

The nova.common.config Module

Next topic

The nova.compute.arch Module

Project Source

This Page