This Page

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

The nova.virt.driver Module

Driver base-classes:

(Beginning of) the contract that compute drivers must follow, and shared types that support that contract
class nova.virt.driver.ComputeDriver

Bases: object

Base class for compute drivers.

Lots of documentation is currently on fake.py.

attach_volume(context, instance_id, volume_id, mountpoint)
compare_cpu(context, cpu_info)
destroy(instance, cleanup=True)

Destroy (shutdown and delete) the specified instance.

The given parameter is an instance of nova.compute.service.Instance, and so the instance is being specified as instance.name.

The work will be done asynchronously. This function returns a task that allows the caller to detect when it is complete.

If the instance is not found (for example if networking failed), this function should still succeed. It’s probably a good idea to log a warning in that case.

detach_volume(context, instance_id, volume_id)
ensure_filtering_rules_for_instance(instance_ref)

Setting up filtering rules and waiting for its completion.

To migrate an instance, filtering rules to hypervisors and firewalls are inevitable on destination host. ( Waiting only for filtering rules to hypervisor, since filtering rules to firewall rules can be set faster).

Concretely, the below method must be called. - setup_basic_filtering (for nova-basic, etc.) - prepare_instance_filter(for nova-instance-instance-xxx, etc.)

to_xml may have to be called since it defines PROJNET, PROJMASK. but libvirt migrates those value through migrateToURI(), so , no need to be called.

Don’t use thread for this method since migration should not be started when setting-up filtering rules operations are not completed.

Params instance_ref:
 nova.db.sqlalchemy.models.Instance object
finish_resize(instance, disk_info)

Completes a resize, turning on the migrated instance

get_ajax_console(instance)
get_console_output(instance)
get_console_pool_info(console_type)
get_diagnostics(instance)

Return data about VM diagnostics

get_host_ip_addr()
get_info(instance_name)

Get the current status of an instance, by name (not ID!)

Returns a dict containing: :state: the running state, one of the power_state codes :max_mem: (int) the maximum memory in KBytes allowed :mem: (int) the memory in KBytes used by the domain :num_cpu: (int) the number of virtual CPUs for the domain :cpu_time: (int) the CPU time used in nanoseconds

init_host(host)

Adopt existing VM’s running here

inject_file(instance, b64_path, b64_contents)

Create a file on the VM instance. The file path and contents should be base64-encoded.

inject_network_info(instance)

inject network info for specified instance

list_instances()
list_instances_detail()

Return a list of InstanceInfo for all registered VMs

live_migration(ctxt, instance_ref, dest, post_method, recover_method)

Spawning live_migration operation for distributing high-load.

Params ctxt:security context
Params instance_ref:
 nova.db.sqlalchemy.models.Instance object instance object that is migrated.
Params dest:destination host
Params post_method:
 post operation method. expected nova.compute.manager.post_live_migration.
Params recover_method:
 recovery method when any exception occurs. expected nova.compute.manager.recover_live_migration.
migrate_disk_and_power_off(instance, dest)

Transfers the VHD of a running instance to another host, then shuts off the instance copies over the COW disk

pause(instance, callback)

Pause VM instance

poll_rescued_instances(timeout)

Poll for rescued instances

reboot(instance)

Reboot specified VM

refresh_security_group_members(security_group_id)
refresh_security_group_rules(security_group_id)
rescue(instance, callback)

Rescue the specified instance

reset_network(instance)

reset networking for specified instance

resume(instance, callback)

resume the specified instance

revert_resize(instance)

Reverts a resize, powering back on the instance

set_admin_password(context, instance_id, new_pass=None)

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

snapshot(instance, image_id)

Create snapshot from a running VM instance.

snapshot_instance(context, instance_id, image_id)
spawn(instance, network_info=None)

Launch a VM for the specified instance

suspend(instance, callback)

suspend the specified instance

unfilter_instance(instance)

Stop filtering instance

unpause(instance, callback)

Unpause paused VM instance

unrescue(instance, callback)

Unrescue the specified instance

update_available_resource(ctxt, host)

Updates compute manager resource info on ComputeNode table.

This method is called when nova-compute launches, and whenever admin executes “nova-manage service update_resource”.

Parameters:
  • ctxt – security context
  • host – hostname that compute manager is currently running
class nova.virt.driver.InstanceInfo(name, state)

Bases: object