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.manager Module

Handles all processes relating to instances (guest vms).

The ComputeManager class is a nova.manager.Manager that handles RPC calls relating to creating instances. It is responsible for building a disk image, launching it via the underlying virtualization driver, responding to calls to check its state, attaching persistent storage, and terminating it.

Related Flags

instances_path:Where instances are kept on disk
compute_driver:Name of class that is used to handle virtualization, loaded by nova.utils.import_object()
volume_manager:Name of class that handles persistent storage, loaded by nova.utils.import_object()
class nova.compute.manager.ComputeManager(compute_driver=None, *args, **kwargs)

Bases: nova.manager.SchedulerDependentManager

Manages the running instances from creation to destruction.

add_fixed_ip_to_instance(*args, **kw)

Calls network_api to add new fixed_ip to instance then injects the new network info and resets instance networking.

agent_update(*args, **kw)

Update agent running on an instance on this host.

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

Attach a volume to an instance.

check_shared_storage_test_file(*args, **kw)
Confirms existence of the tmpfile under FLAGS.instances_path.
Cannot confirm tmpfile return False.
Parameters:
  • context – security context
  • filename – confirm existence of FLAGS.instances_path/thisfile
cleanup_shared_storage_test_file(*args, **kw)

Removes existence of the tmpfile under FLAGS.instances_path.

Parameters:
  • context – security context
  • filename – remove existence of FLAGS.instances_path/thisfile
compare_cpu(*args, **kw)

Checks that the host cpu is compatible with a cpu given by xml.

Parameters:
  • context – security context
  • cpu_info – json string obtained from virConnect.getCapabilities
Returns:

See driver.compare_cpu

confirm_resize(*args, **kw)

Destroys the source instance.

create_shared_storage_test_file(*args, **kw)

Makes tmpfile under FLAGS.instance_path.

This method enables compute nodes to recognize that they mounts same shared storage. (create|check|creanup)_shared_storage_test_file() is a pair.

Parameters:context – security context
Returns:tmpfile name(basename)
detach_volume(context, instance_id, volume_id)

Detach a volume from an instance.

finish_resize(*args, **kw)

Completes the migration process.

Sets up the newly transferred disk and turns on the instance at its new host machine.

finish_revert_resize(*args, **kw)

Finishes the second half of reverting a resize.

Power back on the source instance and revert the resized attributes in the database.

get_ajax_console(*args, **kw)

Return connection information for an ajax console.

get_console_output(*args, **kw)

Send the console output for the given instance.

get_console_pool_info(context, console_type)
get_console_topic(context, **kwargs)

Retrieves the console host for a project on this host.

Currently this is just set in the flags for each compute host.

get_diagnostics(*args, **kw)

Retrieve diagnostics for an instance on this host.

get_lock(*args, **kw)

Return the boolean state of the given instance’s lock.

get_vnc_console(*args, **kw)

Return connection information for a vnc console.

host_power_action(*args, **kw)

Reboots, shuts down or powers up the host.

init_host()

Initialization for a standalone compute service.

inject_file(*args, **kw)

Write a file to the specified path in an instance on this host.

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

Inject network info for the given instance.

live_migration(context, instance_id, dest, block_migration=False)

Executing live migration.

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • dest – destination host
  • block_migration – if true, do block migration
lock_instance(*args, **kw)

Lock the given instance.

pause_instance(*args, **kw)

Pause an instance on this host.

periodic_tasks(context=None)

Tasks to be run at a periodic interval.

post_live_migration(ctxt, instance_ref, dest, block_migration=False)

Post operations for live migration.

This method is called from live_migration and mainly updating database record.

Parameters:
  • ctxt – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • dest – destination host
  • block_migration – if true, do block migration
post_live_migration_at_destination(context, instance_id, block_migration=False)

Post operations for live migration .

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • block_migration – block_migration
pre_live_migration(context, instance_id, time=None, block_migration=False, disk=None)

Preparations for live migration at dest host.

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • block_migration – if true, prepare for block migration
prep_resize(*args, **kw)

Initiates the process of moving a running instance to another host.

Possibly changes the RAM and disk size in the process.

reboot_instance(*args, **kw)

Reboot an instance on this host.

rebuild_instance(*args, **kw)

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’.

Parameters:
  • contextnova.RequestContext object
  • instance_id – Instance identifier (integer)
  • injected_files – Files to inject
  • new_pass – password to set on rebuilt instance
refresh_provider_fw_rules(*args, **kw)

This call passes straight through to the virtualization driver.

refresh_security_group_members(*args, **kw)

Tell the virtualization driver to refresh security group members.

Passes straight through to the virtualization driver.

refresh_security_group_rules(*args, **kw)

Tell the virtualization driver to refresh security group rules.

Passes straight through to the virtualization driver.

remove_fixed_ip_from_instance(*args, **kw)

Calls network_api to remove existing fixed_ip from instance by injecting the altered network info and resetting instance networking.

remove_volume(context, volume_id)

Remove volume on compute host.

Parameters:
  • context – security context
  • volume_id – volume ID
rescue_instance(*args, **kw)

Rescue an instance on this host.

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

Reset networking on the given instance.

resize_instance(*args, **kw)

Starts the migration of a running instance to another host.

resume_instance(*args, **kw)

Resume the given suspended instance.

revert_resize(*args, **kw)

Destroys the new instance on the destination machine.

Reverts the model changes, and powers on the old instance on the source machine.

rollback_live_migration(context, instance_ref, dest, block_migration)

Recovers Instance/volume state from migrating -> running.

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • dest – This method is called from live migration src host. This param specifies destination host.
rollback_live_migration_at_destination(context, instance_id)

Cleaning up image directory that is created pre_live_migration.

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
rotate_backups(context, instance_uuid, backup_type, rotation)

Delete excess backups associated to an instance.

Instances are allowed a fixed number of backups (the rotation number); this method deletes the oldest backups that exceed the rotation threshold.

Parameters:
  • context – security context
  • instance_uuid – string representing uuid of instance
  • backup_type – daily | weekly
  • rotation – int representing how many backups to keep around; None if rotation shouldn’t be used (as in the case of snapshots)
run_instance(*args, **kw)
set_admin_password(*args, **kw)

Set the root/admin password for an instance on this host.

This is generally only called by API password resets after an image has been built.

set_host_enabled(*args, **kw)

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

snapshot_instance(*args, **kw)

Snapshot an instance on this host.

Parameters:
  • context – security context
  • instance_id – nova.db.sqlalchemy.models.Instance.Id
  • image_id – glance.db.sqlalchemy.models.Image.Id
  • image_type – snapshot | backup
  • backup_type – daily | weekly
  • rotation – int representing how many backups to keep around; None if rotation shouldn’t be used (as in the case of snapshots)
start_instance(*args, **kw)

Starting an instance on this host.

stop_instance(*args, **kw)

Stopping an instance on this host.

suspend_instance(*args, **kw)

Suspend the given instance.

terminate_instance(*args, **kw)

Terminate an instance on this host.

unlock_instance(*args, **kw)

Unlock the given instance.

unpause_instance(*args, **kw)

Unpause a paused instance on this host.

unrescue_instance(*args, **kw)

Rescue an instance on this host.

update_available_resource(*args, **kw)

See comments update_resource_info.

Parameters:context – security context
Returns:See driver.update_available_resource()
nova.compute.manager.checks_instance_lock(function)

Decorator to prevent action against locked instances for non-admins.

nova.compute.manager.publisher_id(host=None)