Table Of Contents

Previous topic

Xen Storage Manager Volume Driver

Next topic

Networking

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.

Virtualization

Compute

Documentation for the compute manager and related files. For reading about a specific virtualization backend, read Drivers.

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()
class ComputeManager(compute_driver=None, *args, **kwargs)

Bases: nova.manager.SchedulerDependentManager

Manages the running instances from creation to destruction.

ComputeManager.add_aggregate_host(*args, **kw)

Adds a host to a physical hypervisor pool.

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

ComputeManager.add_instance_fault_from_exc(context, instance_uuid, fault, exc_info=None)

Adds the specified fault to the database.

ComputeManager.agent_update(*args, **kw)

Update agent running on an instance on this host.

ComputeManager.attach_volume(*args, **kw)

Attach a volume to an instance.

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

ComputeManager.confirm_resize(*args, **kw)

Destroys the source instance.

ComputeManager.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)
ComputeManager.detach_volume(*args, **kw)

Detach a volume from an instance.

ComputeManager.error_out_instance_on_exception(*args, **kwds)
ComputeManager.finish_resize(*args, **kw)

Completes the migration process.

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

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

ComputeManager.get_console_output(*args, **kw)

Send the console output for the given instance.

ComputeManager.get_console_pool_info(context, console_type)
ComputeManager.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.

ComputeManager.get_diagnostics(*args, **kw)

Retrieve diagnostics for an instance on this host.

ComputeManager.get_instance_disk_info(context, instance_name)

Getting infomation of instance’s current disk.

Implementation nova.virt.libvirt.connection.

Parameters:
  • context – security context
  • instance_name – instance name
ComputeManager.get_lock(*args, **kw)

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

ComputeManager.get_vnc_console(*args, **kw)

Return connection information for a vnc console.

ComputeManager.host_maintenance_mode(*args, **kw)

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

ComputeManager.host_power_action(*args, **kw)

Reboots, shuts down or powers up the host.

ComputeManager.init_host()

Initialization for a standalone compute service.

ComputeManager.inject_file(*args, **kw)

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

ComputeManager.inject_network_info(context, instance_uuid, *args, **kwargs)

Inject network info for the given instance.

ComputeManager.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, prepare for block migration
ComputeManager.lock_instance(*args, **kw)

Lock the given instance.

ComputeManager.pause_instance(*args, **kw)

Pause an instance on this host.

ComputeManager.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, prepare for block migration
ComputeManager.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 – if true, prepare for block migration
ComputeManager.power_off_instance(*args, **kw)

Power off an instance on this host.

ComputeManager.power_on_instance(*args, **kw)

Power on an instance on this host.

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

ComputeManager.reboot_instance(*args, **kw)

Reboot an instance on this host.

ComputeManager.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_uuid – Instance Identifier (UUID)
  • injected_files – Files to inject
  • new_pass – password to set on rebuilt instance
ComputeManager.refresh_provider_fw_rules(*args, **kw)

This call passes straight through to the virtualization driver.

ComputeManager.refresh_security_group_members(*args, **kw)

Tell the virtualization driver to refresh security group members.

Passes straight through to the virtualization driver.

ComputeManager.refresh_security_group_rules(*args, **kw)

Tell the virtualization driver to refresh security group rules.

Passes straight through to the virtualization driver.

ComputeManager.remove_aggregate_host(*args, **kw)

Removes a host from a physical hypervisor pool.

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

ComputeManager.remove_volume_connection(*args, **kw)

Remove a volume connection using the volume api

ComputeManager.rescue_instance(*args, **kw)

Rescue an instance on this host. :param rescue_password: password to set on rescue instance

ComputeManager.reset_network(context, instance_uuid, *args, **kwargs)

Reset networking on the given instance.

ComputeManager.resize_instance(*args, **kw)

Starts the migration of a running instance to another host.

ComputeManager.resume_instance(*args, **kw)

Resume the given suspended instance.

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

ComputeManager.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.
  • block_migration – if true, prepare for block migration
ComputeManager.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
ComputeManager.rotate_backups(context, instance_uuid, *args, **kwargs)

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)
ComputeManager.run_instance(*args, **kw)
ComputeManager.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.

ComputeManager.set_host_enabled(*args, **kw)

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

ComputeManager.snapshot_instance(*args, **kw)

Snapshot an instance on this host.

Parameters:
  • context – security context
  • instance_uuid – nova.db.sqlalchemy.models.Instance.Uuid
  • 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)
ComputeManager.start_instance(*args, **kw)
ComputeManager.stop_instance(*args, **kw)

Stopping an instance on this host.

ComputeManager.suspend_instance(*args, **kw)

Suspend the given instance.

ComputeManager.terminate_instance(*args, **kw)

Terminate an instance on this host.

ComputeManager.unlock_instance(*args, **kw)

Unlock the given instance.

ComputeManager.unpause_instance(*args, **kw)

Unpause a paused instance on this host.

ComputeManager.unrescue_instance(*args, **kw)

Rescue an instance on this host.

ComputeManager.update_available_resource(context)

See driver.update_available_resource()

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

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

publisher_id(host=None)
wrap_instance_fault(function)

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.

The nova.virt.connection Module

Abstraction of the underlying virtualization API.

FLAGS = <nova.flags.NovaConfigOpts object at 0xaa9dc2c>

In case of baremetal (FLAGS.connection_type), specific driver is set by FLAGS.baremetal_driver

get_connection(read_only=False)

Returns an object representing the connection to a virtualization platform.

This could be nova.virt.fake.FakeConnection in test mode, a connection to KVM, QEMU, or UML via libvirt_conn, or a connection to XenServer or Xen Cloud Platform via xenapi.

Any object returned here must conform to the interface documented by FakeConnection.

Related flags

Connection_type :
 

A string literal that falls through a if/elif structure to determine what virtualization mechanism to use. Values may be

  • fake
  • libvirt
  • xenapi
  • vmwareapi

The nova.compute.disk Module

The nova.virt.images Module

Handling of VM disk images.

fetch(context, image_href, path, _user_id, _project_id)
fetch_to_raw(context, image_href, path, user_id, project_id)

The nova.compute.instance_types Module

Built-in instance properties.

create(name, memory, vcpus, root_gb, ephemeral_gb, flavorid, swap=None, rxtx_factor=None)

Creates instance types.

destroy(name)

Marks instance types as deleted.

get_all_flavors(inactive=0, filters=None)

Get all non-deleted instance_types.

Pass true as argument if you want deleted instance types returned also.

get_all_types(inactive=0, filters=None)

Get all non-deleted instance_types.

Pass true as argument if you want deleted instance types returned also.

get_default_instance_type()

Get the default instance type.

get_instance_type(instance_type_id)

Retrieves single instance type by id.

get_instance_type_by_flavor_id(flavorid)

Retrieve instance type by flavorid.

Raises :FlavorNotFound
get_instance_type_by_name(name)

Retrieves single instance type by name.

The nova.compute.power_state Module

The various power states that a VM can be in.

name(code)
valid_states()

Drivers

The nova.virt.libvirt_conn Driver

The nova.virt.xenapi Driver

xenapi – Nova support for XenServer and XCP through XenAPI

class HelperBase

Bases: object

The base for helper classes. This adds the XenAPI class attribute

HelperBase.XenAPI = None
classmethod HelperBase.get_all_refs_and_recs(session, record_type)

Retrieve all refs and recs for a Xen record type.

Handles race-conditions where the record may be deleted between the get_all call and the get_record call.

classmethod HelperBase.get_rec(session, record_type, ref)

The nova.virt.fake Driver

A fake (in-memory) hypervisor+api.

Allows nova testing w/o a hypervisor. This module also documents the semantics of real hypervisor connections.

class FakeConnection

Bases: nova.virt.driver.ComputeDriver

Fake hypervisor driver

FakeConnection.agent_update(instance, url, md5hash)
FakeConnection.attach_volume(connection_info, instance_name, mountpoint)

Attach the disk to the instance at mountpoint using info

FakeConnection.block_stats(instance_name, disk_id)
FakeConnection.compare_cpu(xml)

This method is supported only by libvirt.

FakeConnection.confirm_migration(migration, instance, network_info)
FakeConnection.destroy(instance, network_info, block_device_info=None)
FakeConnection.detach_volume(connection_info, instance_name, mountpoint)

Detach the disk attached to the instance

FakeConnection.ensure_filtering_rules_for_instance(instance_ref, network_info)

This method is supported only by libvirt.

FakeConnection.finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance)
FakeConnection.finish_revert_migration(instance, network_info)
FakeConnection.get_all_bw_usage(start_time, stop_time=None)

Return bandwidth usage info for each interface on each running VM

FakeConnection.get_console_output(instance)
FakeConnection.get_console_pool_info(console_type)
FakeConnection.get_diagnostics(instance_name)
FakeConnection.get_disk_available_least()
static FakeConnection.get_host_ip_addr()
FakeConnection.get_host_stats(refresh=False)

Return fake Host Status of ram, disk, network.

FakeConnection.get_info(instance)
FakeConnection.get_instance_disk_info(instance_name)

This method is supported only by libvirt.

FakeConnection.get_vnc_console(instance)
FakeConnection.get_volume_connector(instance)
FakeConnection.host_maintenance_mode(host, mode)

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

FakeConnection.host_power_action(host, action)

Reboots, shuts down or powers up the host.

FakeConnection.init_host(host)
FakeConnection.inject_file(instance, b64_path, b64_contents)
classmethod FakeConnection.instance()
FakeConnection.interface_stats(instance_name, iface_id)
FakeConnection.list_disks(instance_name)
FakeConnection.list_instances()
FakeConnection.list_instances_detail()
FakeConnection.list_interfaces(instance_name)
FakeConnection.live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False)

This method is supported only by libvirt.

FakeConnection.migrate_disk_and_power_off(context, instance, dest, instance_type, network_info)
FakeConnection.pause(instance)
FakeConnection.plug_vifs(instance, network_info)

Plug VIFs into networks.

FakeConnection.poll_rebooting_instances(timeout)
FakeConnection.poll_rescued_instances(timeout)
FakeConnection.poll_unconfirmed_resizes(resize_confirm_window)
FakeConnection.pre_live_migration(block_device_info)

This method is supported only by libvirt.

FakeConnection.reboot(instance, network_info, reboot_type)
FakeConnection.refresh_provider_fw_rules()
FakeConnection.refresh_security_group_members(security_group_id)
FakeConnection.refresh_security_group_rules(security_group_id)
FakeConnection.rescue(context, instance, network_info, image_meta)
FakeConnection.resize(instance, flavor)
FakeConnection.resume(instance)
FakeConnection.set_admin_password(instance, new_pass)
FakeConnection.set_host_enabled(host, enabled)

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

FakeConnection.snapshot(context, instance, name)
FakeConnection.spawn(context, instance, image_meta, network_info=None, block_device_info=None)
FakeConnection.suspend(instance)
FakeConnection.test_remove_vm(instance_name)

Removes the named VM, as if it crashed. For testing

FakeConnection.unfilter_instance(instance_ref, network_info)

This method is supported only by libvirt.

FakeConnection.unpause(instance)
FakeConnection.unplug_vifs(instance, network_info)

Unplug VIFs from networks.

FakeConnection.unrescue(instance, network_info)
FakeConnection.update_available_resource(ctxt, host)

Updates compute manager resource info on ComputeNode table.

Since we don’t have a real hypervisor, pretend we have lots of disk and ram.

FakeConnection.update_host_status()

Return fake Host Status of ram, disk, network.

class FakeInstance(name, state)

Bases: object

get_connection(_read_only)

Tests

The compute_unittest Module

The virt_unittest Module