Previous topic

The nova.compute.aggregate_states Module

Next topic

The nova.compute.instance_types Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

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_service=None, network_api=None, volume_api=None, **kwargs)

Bases: nova.compute.api.BaseAPI

API for interacting with the compute manager.

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

Add fixed_ip from specified network to given instance.

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

Add security group to the instance

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

Makes calls to network_api to associate_floating_ip.

Parameters:address – is a string floating ip address
attach_volume(context, target, *args, **kwargs)

Attach an existing volume to an existing instance.

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

Backup the given instance

Parameters:
  • instance – nova.db.sqlalchemy.models.Instance
  • name – name of the backup or snapshot name = backup_type # daily backups are called ‘daily’
  • rotation – int representing how many backups to keep around; None if rotation shouldn’t be used (as in the case of snapshots)
  • extra_properties – dict of extra image properties to include
confirm_resize(context, target, *args, **kwargs)

Confirms a migration/resize and deletes the ‘old’ instance.

create(context, instance_type, image_href, kernel_id=None, ramdisk_id=None, min_count=None, max_count=None, display_name=None, display_description=None, key_name=None, key_data=None, security_group=None, availability_zone=None, user_data=None, metadata=None, injected_files=None, admin_password=None, block_device_mapping=None, access_ip_v4=None, access_ip_v6=None, requested_networks=None, config_drive=None, auto_disk_config=None, scheduler_hints=None)

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) where instances could be ‘None’ or a list of instance dicts depending on if we waited for information from the scheduler or not.

create_db_entry_for_new_instance(context, instance_type, image, base_options, security_group, block_device_mapping)

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)

Terminate an instance.

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

Delete the given metadata item from an instance.

detach_volume(context, volume_id)

Detach a volume from an instance.

ensure_default_security_group(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
force_delete(context, target, *args, **kwargs)

Force delete a previously deleted (but not reclaimed) instance.

get(context, instance_id)

Get a single instance with the given instance_id.

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

Retrieve actions for the given instance.

get_active_by_window(context, begin, end=None, project_id=None)

Get instances that were continuously active over a window.

get_all(context, search_opts=None, sort_key='created_at', sort_dir='desc')

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 returned sorted in the order specified by the ‘sort_dir’ parameter using the key specified in the ‘sort_key’ parameter.

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

Get console output for an an instance.

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

Retrieve diagnostics for the given instance.

get_instance_faults(context, instances)

Get all faults for a list of instance uuids.

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

Get all metadata associated with an instance.

get_instance_type(context, instance_type_id)

Get an instance type by instance type id.

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

Return the boolean state of given instance’s lock.

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

Get a url to an instance Console.

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

Write a file to the given instance.

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

Inject network info for the instance.

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

Lock the given instance.

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

Pause the given instance.

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

Reboot the given instance.

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

Rebuild the given instance with the provided attributes.

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

Remove fixed_ip from specified network to given instance.

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

Remove the security group associated with the instance

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

Rescue the given instance.

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

Reset networking on the instance.

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

Resize (ie, migrate) a running instance.

If flavor_id is None, the process is considered a migration, keeping the original flavor_id. If flavor_id is not None, the instance should be migrated to a new host and resized to the new flavor_id.

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

Restore a previously deleted (but not reclaimed) instance.

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

Resume the given instance.

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

Reverts a resize, deleting the ‘new’ instance in the process.

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

Set the root/admin password for the given instance.

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

Snapshot the given instance.

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

A dict containing image metadata

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

Terminate an instance.

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

Start an instance.

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

Stop an instance.

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

Suspend the given instance.

trigger_provider_fw_rules_refresh(context)

Called when a rule is added/removed from a provider firewall

trigger_security_group_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 whom this is relevant.

trigger_security_group_rules_refresh(context, security_group_id)

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

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

Unlock the given instance.

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

Unpause the given instance.

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

Unrescue the given instance.

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

Updates the instance in the datastore.

Parameters:
  • context – The security context
  • instance – The instance to update
  • kwargs – All additional keyword args are treated as data fields of the instance to be updated
Returns:

None

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.

class AggregateAPI(**kwargs)

Bases: nova.db.base.Base

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

add_host_to_aggregate(context, aggregate_id, host)

Adds the host to an aggregate.

create_aggregate(context, aggregate_name, availability_zone)

Creates the model for the aggregate.

delete_aggregate(context, aggregate_id)

Deletes the aggregate.

get_aggregate(context, aggregate_id)

Get an aggregate by id.

get_aggregate_list(context)

Get all the aggregates for this zone.

remove_host_from_aggregate(context, aggregate_id, host)

Removes host from the aggregate.

update_aggregate(context, aggregate_id, values)

Update the properties of an aggregate.

update_aggregate_metadata(context, aggregate_id, metadata)

Updates the aggregate metadata.

If a key is set to None, it gets removed from the aggregate metadata.

class BaseAPI(**kwargs)

Bases: nova.db.base.Base

Base API class.

class HostAPI(**kwargs)

Bases: nova.compute.api.BaseAPI

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

host_power_action(context, host, action)

Reboots, shuts down or powers up the host.

set_host_enabled(context, host, enabled)

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

set_host_maintenance(context, host, mode)

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

check_instance_state(vm_state=None, task_state=None)

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

If the instance is in the wrong state, the wrapper will raise an exception.

check_policy(context, action, target)
wrap_check_policy(func)

Check corresponding policy prior of wrapped method to execution