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.

class ComputeManager(compute_driver=None, *args, **kwargs)

Bases: nova.manager.Manager

Manages the running instances from creation to destruction.

SHUTDOWN_RETRY_INTERVAL = 10
add_aggregate_host(context, *args, **kw)

Notify hypervisor of change (for hypervisor pools).

add_fixed_ip_to_instance(context, *args, **kw)

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

attach_interface(context, *args, **kw)

Use hotplug to add an network adapter to an instance.

attach_volume(context, *args, **kw)

Attach a volume to an instance.

backup_instance(context, *args, **kw)

Backup an instance on this host.

Parameters:
  • backup_type – daily | weekly
  • rotation – int representing how many backups to keep around
build_and_run_instance(context, *args, **kw)
change_instance_metadata(context, *args, **kw)

Update the metadata published to the instance.

check_can_live_migrate_destination(context, *args, **kw)

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.

Parameters:
  • context – security context
  • instance – dict of instance data
  • block_migration – if true, prepare for block migration if None, calculate it in driver
  • disk_over_commit – if true, allow disk over commit if None, ignore disk usage checking
Returns:

a dict containing migration info

check_can_live_migrate_source(context, *args, **kw)

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.

Parameters:
  • ctxt – security context
  • instance – dict of instance data
  • dest_check_data – result of check_can_live_migrate_destination
Returns:

a dict containing migration info

check_instance_shared_storage(context, *args, **kw)

Check if the instance files are shared

Parameters:
  • ctxt – security context
  • instance – dict of instance data
  • data – result of driver.check_instance_shared_storage_local

Returns True if instance disks located on shared storage and False otherwise.

cleanup_host()
confirm_resize(context, *args, **kw)
deallocate_sriov_ports_on_reschedule(instance)

Determine if networks are needed to be deallocated before reschedule

Check the cached network info for any assigned SR-IOV ports. SR-IOV ports should be deallocated prior to rescheduling in order to allow new sriov pci devices to be allocated on a new host.

detach_interface(context, *args, **kw)

Detach an network adapter from an instance.

detach_volume(context, *args, **kw)

Detach a volume from an instance.

external_instance_event(context, *args, **kw)
finish_resize(context, *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(context, *args, **kw)

Finishes the second half of reverting a resize.

Bring the original source instance state back (active/shutoff) and revert the resized attributes in the database.

get_console_output(*args, **kwargs)
get_console_pool_info(context, *args, **kw)
get_console_topic(context)

Retrieves the console host for a project on this host.

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

get_diagnostics(context, *args, **kw)

Retrieve diagnostics for an instance on this host.

get_host_uptime(context, *args, **kw)

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

get_instance_diagnostics(context, *args, **kwargs)

Retrieve diagnostics for an instance on this host.

get_mks_console(*args, **kwargs)
get_rdp_console(*args, **kwargs)
get_serial_console(*args, **kwargs)
get_spice_console(*args, **kwargs)
get_vnc_console(*args, **kwargs)
handle_events(event)
handle_lifecycle_event(event)
host_maintenance_mode(context, *args, **kw)

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

host_power_action(context, *args, **kw)

Reboots, shuts down or powers up the host.

init_host()

Initialization for a standalone compute service.

init_virt_events()
inject_file(context, *args, **kw)

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

inject_network_info(context, *args, **kwargs)

Inject network info, but don’t return the info.

live_migration(context, *args, **kw)

Executing live migration.

Parameters:
  • context – security context
  • dest – destination host
  • instance – a nova.objects.instance.Instance object
  • block_migration – if true, prepare for block migration
  • migration – an nova.objects.Migration object
  • migrate_data – implementation specific params
live_migration_abort(context, *args, **kw)

Abort an in-progress live migration.

Parameters:
  • context – Security context
  • instance – The instance that is being migrated
  • migration_id – ID of in-progress live migration
live_migration_force_complete(context, *args, **kw)

Force live migration to complete.

Parameters:
  • context – Security context
  • instance – The instance that is being migrated
  • migration_id – ID of ongoing migration
pause_instance(context, *args, **kw)

Pause an instance on this host.

post_live_migration_at_destination(context, *args, **kw)

Post operations for live migration .

Parameters:
  • context – security context
  • instance – Instance dict
  • block_migration – if true, prepare for block migration
pre_live_migration(context, *args, **kw)

Preparations for live migration at dest host.

Parameters:
  • context – security context
  • instance – dict of instance data
  • block_migration – if true, prepare for block migration
  • migrate_data – if not None, it is a dict which holds data required for live migration without shared storage.
pre_start_hook()

After the service is initialized, but before we fully bring the service up by listening on RPC queues, make sure to update our available resources (and indirectly our available nodes).

prep_resize(context, *args, **kw)

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

Possibly changes the RAM and disk size in the process.

quiesce_instance(*args, **kwargs)
reboot_instance(context, *args, **kw)

Reboot an instance on this host.

rebuild_instance(*args, **kwargs)
refresh_instance_security_rules(context, *args, **kwargs)

Tell the virtualization driver to refresh security rules for an instance.

Passes straight through to the virtualization driver.

Synchronise the call because we may still be in the middle of creating the instance.

refresh_security_group_rules(context, *args, **kw)

Tell the virtualization driver to refresh security group rules.

Passes straight through to the virtualization driver.

remove_aggregate_host(context, *args, **kw)

Removes a host from a physical hypervisor pool.

remove_fixed_ip_from_instance(context, *args, **kw)

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

remove_volume_connection(context, *args, **kw)

Remove a volume connection using the volume api.

rescue_instance(context, *args, **kw)
reserve_block_device_name(context, *args, **kw)
reset()
reset_network(*args, **kwargs)
resize_instance(context, *args, **kw)

Starts the migration of a running instance to another host.

restore_instance(context, *args, **kw)

Restore a soft-deleted instance on this host.

resume_instance(context, *args, **kw)

Resume the given suspended instance.

revert_resize(context, *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_at_destination(context, *args, **kw)

Cleaning up image directory that is created pre_live_migration.

Parameters:
  • context – security context
  • instance – a nova.objects.instance.Instance object sent over rpc
set_admin_password(context, *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.

@param context: Nova auth context. @param instance: Nova instance object. @param new_pass: The admin password for the instance.

set_host_enabled(context, *args, **kw)

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

shelve_instance(context, *args, **kw)

Shelve an instance.

This should be used when you want to take a snapshot of the instance. It also adds system_metadata that can be used by a periodic task to offload the shelved instance after a period of time.

Parameters:
  • context – request context
  • instance – an Instance object
  • image_id – an image id to snapshot to.
  • clean_shutdown – give the GuestOS a chance to stop
shelve_offload_instance(context, *args, **kw)

Remove a shelved instance from the hypervisor.

This frees up those resources for use by other instances, but may lead to slower unshelve times for this instance. This method is used by volume backed instances since restoring them doesn’t involve the potentially large download of an image.

Parameters:
  • context – request context
  • instance – nova.objects.instance.Instance
  • clean_shutdown – give the GuestOS a chance to stop
snapshot_instance(context, *args, **kw)

Snapshot an instance on this host.

Parameters:
  • context – security context
  • instance – a nova.objects.instance.Instance object
  • image_id – glance.db.sqlalchemy.models.Image.Id
soft_delete_instance(context, *args, **kw)

Soft delete an instance on this host.

start_instance(context, *args, **kw)

Starting an instance on this host.

stop_instance(context, *args, **kw)

Stopping an instance on this host.

suspend_instance(context, *args, **kw)

Suspend the given instance.

swap_volume(context, *args, **kw)

Swap volume for an instance.

target = <Target version=4.11>
terminate_instance(context, *args, **kw)

Terminate an instance on this host.

trigger_crash_dump(*args, **kwargs)
unpause_instance(context, *args, **kw)

Unpause a paused instance on this host.

unquiesce_instance(*args, **kwargs)
unrescue_instance(context, *args, **kw)
unshelve_instance(context, *args, **kw)

Unshelve the instance.

Parameters:
  • context – request context
  • instance – a nova.objects.instance.Instance object
  • image – an image to build from. If None we assume a volume backed instance.
  • filter_properties – dict containing limits, retry info etc.
  • node – target compute node
update_available_resource(context)

See driver.get_available_resource()

Periodic process that keeps that the compute host’s understanding of resource availability and usage in sync with the underlying hypervisor.

Parameters:context – security context
validate_console_port(*args, **kwargs)
volume_snapshot_create(*args, **kwargs)
volume_snapshot_delete(*args, **kwargs)
class ComputeVirtAPI(compute)

Bases: nova.virt.virtapi.VirtAPI

wait_for_instance_event(*args, **kwds)

Plan to wait for some events, run some code, then wait.

This context manager will first create plans to wait for the provided event_names, yield, and then wait for all the scheduled events to complete.

Note that this uses an eventlet.timeout.Timeout to bound the operation, so callers should be prepared to catch that failure and handle that situation appropriately.

If the event is not received by the specified timeout deadline, eventlet.timeout.Timeout is raised.

If the event is received but did not have a ‘completed’ status, a NovaException is raised. If an error_callback is provided, instead of raising an exception as detailed above for the failure case, the callback will be called with the event_name and instance, and can return True to continue waiting for the rest of the events, False to stop processing, or raise an exception which will bubble up to the waiter.

Parameters:
  • instance – The instance for which an event is expected
  • event_names – A list of event names. Each element can be a string event name or tuple of strings to indicate (name, tag).
  • deadline – Maximum number of seconds we should wait for all of the specified events to arrive.
  • error_callback – A function to be called if an event arrives
class InstanceEvents

Bases: object

cancel_all_events()
clear_events_for_instance(instance)

Remove all pending events for an instance.

This will remove all events currently pending for an instance and return them (indexed by event name).

Parameters:instance – the instance for which events should be purged
Returns:a dictionary of {event_name: eventlet.event.Event}
pop_instance_event(instance, event)

Remove a pending event from the wait list.

This will remove a pending event from the wait list so that it can be used to signal the waiters to wake up.

Parameters:
  • instance – the instance for which the event was generated
  • event – the nova.objects.external_event.InstanceExternalEvent that describes the event
Returns:

the eventlet.event.Event object on which the waiters are blocked

prepare_for_instance_event(instance, event_name)

Prepare to receive an event for an instance.

This will register an event for the given instance that we will wait on later. This should be called before initiating whatever action will trigger the event. The resulting eventlet.event.Event object should be wait()’d on to ensure completion.

Parameters:
  • instance – the instance for which the event will be generated
  • event_name – the name of the event we’re expecting
Returns:

an event object that should be wait()’d on

delete_image_on_error(f)

Used for snapshot related method to ensure the image created in compute.api is deleted when an error occurs.

errors_out_migration(f)

Decorator to error out migration on failure.

object_compat(function)

Wraps a method that expects a new-world instance

This provides compatibility for callers passing old-style dict instances.

reverts_task_state(f)

Decorator to revert task_state on failure.

wrap_instance_event(f)

Wraps a method to log the event taken on the instance, and result.

This decorator wraps a method to log the start and result of an event, as part of an action taken on an instance.

wrap_instance_fault(f)

Wraps a method to catch exceptions related to instances.

This decorator wraps a method to catch any exceptions having to do with an instance that may get thrown. It then logs an instance fault in the db.

Previous topic

The nova.compute.instance_actions Module

Next topic

The nova.compute.monitors.base Module

Project Source

This Page