The nova.virt.xenapi.driver Module

A driver for XenServer or Xen Cloud Platform.

Variable Naming Scheme

  • suffix “_ref” for opaque references
  • suffix “_uuid” for UUIDs
  • suffix “_rec” for record objects
class XenAPIDriver(virtapi, read_only=False)

Bases: nova.virt.driver.ComputeDriver

A connection to XenServer or Xen Cloud Platform.

add_to_aggregate(context, aggregate, host, **kwargs)

Add a compute host to an aggregate.

attach_volume(context, connection_info, instance, mountpoint, disk_bus=None, device_type=None, encryption=None)

Attach volume storage to VM instance.

change_instance_metadata(context, instance, diff)

Apply a diff to the instance metadata.

check_can_live_migrate_destination(context, instance, src_compute_info, dst_compute_info, block_migration=False, disk_over_commit=False)

Check if it is possible to execute live migration.

  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance object
  • block_migration – if true, prepare for block migration
  • disk_over_commit – if true, allow disk over commit

a XenapiLiveMigrateData object

check_can_live_migrate_destination_cleanup(context, dest_check_data)

Do required cleanup on dest host after check_can_live_migrate calls

  • context – security context
  • dest_check_data – result of check_can_live_migrate_destination
check_can_live_migrate_source(context, instance, dest_check_data, block_device_info=None)

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.

  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance
  • dest_check_data – result of check_can_live_migrate_destination includes the block_migration flag
  • block_device_info – result of _get_instance_block_device_info

a XenapiLiveMigrateData object

cleanup(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None, destroy_vifs=True)

Cleanup after instance being destroyed by Hypervisor.

confirm_migration(migration, instance, network_info)

Confirms a resize, destroying the source VM.

destroy(context, instance, network_info, block_device_info=None, destroy_disks=True, migrate_data=None)

Destroy VM instance.

detach_volume(connection_info, instance, mountpoint, encryption=None)

Detach volume storage from VM instance.

ensure_filtering_rules_for_instance(instance, network_info)

Get virtualization overhead required to build an instance of the given flavor.

Parameters:instance_info – Instance/flavor to calculate overhead for.
Returns:Overhead memory in MB.
finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance, block_device_info=None, power_on=True)

Completes a resize, turning on the migrated instance.

finish_revert_migration(context, instance, network_info, block_device_info=None, power_on=True)

Finish reverting a resize.


Return bandwidth usage counters for each interface on each running VM.


Retrieve resource information.

This method is called when nova-compute launches, and as part of a periodic task that records the results in the DB.

Parameters:nodename – ignored in this driver
Returns:dictionary describing resources
get_console_output(context, instance)

Return snapshot of console.


Return data about VM diagnostics.


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


Return data about VM instance.


Return data about VM diagnostics.

get_instance_disk_info(instance, block_device_info=None)

Used by libvirt for live migration. We rely on xenapi checks to do this for us.


Get information about instance resource usage.

Returns:dict of nova uuid => dict of usage info
get_vnc_console(context, instance)

Return link to instance’s VNC console.


Return volume connector information.

host_maintenance_mode(host, mode)

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


The only valid values for ‘action’ on XenServer are ‘reboot’ or ‘shutdown’, even though the API also accepts ‘startup’. As this is not technically possible on XenServer, since the host is the same physical machine as the hypervisor, if this is requested, we need to raise an exception.

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, nw_info)

inject network info for specified instance.


Checks existence of an instance on the host.

Parameters:instance – The instance to lookup

Returns True if supplied instance exists on the host, False otherwise.

NOTE(belliott): This is an override of the base method for efficiency.


Get the list of nova instance uuids for VMs found on the hypervisor.


List VM instances.

live_migration(context, instance, dest, post_method, recover_method, block_migration=False, migrate_data=None)

Performs the live migration of the specified instance.

  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance object instance object that is migrated.
  • dest – destination host
  • post_method – post operation method. expected nova.compute.manager._post_live_migration.
  • recover_method – recovery method when any exception occurs. expected nova.compute.manager._rollback_live_migration.
  • block_migration – if true, migrate VM disk.
  • migrate_data – a XenapiLiveMigrateData object
migrate_disk_and_power_off(context, instance, dest, flavor, network_info, block_device_info=None, timeout=0, retry_interval=0)

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


Pause VM instance.

plug_vifs(instance, network_info)

Plug VIFs into networks.

poll_rebooting_instances(timeout, instances)

Poll for rebooting instances.

post_interrupted_snapshot_cleanup(context, instance)

Cleans up any resources left after a failed snapshot.

post_live_migration(context, instance, block_device_info, migrate_data=None)

Post operation of live migration at source host.

  • context – security context
  • migrate_data – a XenapiLiveMigrateData object

instance object that was migrated


instance block device information

post_live_migration_at_destination(context, instance, network_info, block_migration=False, block_device_info=None)

Post operation of live migration at destination host.

  • context – security context
  • instance – nova.db.sqlalchemy.models.Instance object instance object that is migrated.
  • network_info – instance network information
  • block_migration – if true, post operation of block_migration.
power_off(instance, timeout=0, retry_interval=0)

Power off the specified instance.

power_on(context, instance, network_info, block_device_info=None)

Power on the specified instance.

pre_live_migration(context, instance, block_device_info, network_info, disk_info, migrate_data=None)

Preparation live migration.

Parameters:block_device_info – It must be the result of _get_instance_volume_bdms() at compute manager.
Returns:a XenapiLiveMigrateData object
reboot(context, instance, network_info, reboot_type, block_device_info=None, bad_volumes_callback=None)

Reboot VM instance.


Updates security group rules for specified instance.

Invoked when instances are added/removed to a security group or when a rule is added/removed to a security group.


Updates security group rules for all instances associated with a given security group.

Invoked when security group rules are updated.

remove_from_aggregate(context, aggregate, host, **kwargs)

Remove a compute host from an aggregate.

rescue(context, instance, network_info, image_meta, rescue_password)

Rescue the specified instance.


reset networking for specified instance.


Restore the specified instance.

resume(context, instance, network_info, block_device_info=None)

resume the specified instance.

resume_state_on_host_boot(context, instance, network_info, block_device_info=None)

resume guest state when a host is booted.

rollback_live_migration_at_destination(context, instance, network_info, block_device_info, destroy_disks=True, migrate_data=None)

Performs a live migration rollback.

  • context – security context
  • instance – instance object that was being migrated
  • network_info – instance network information
  • block_device_info – instance block device information
  • destroy_disks – if true, destroy disks at destination during cleanup
  • migrate_data – A XenapiLiveMigrateData object
set_admin_password(instance, new_pass)

Set the root/admin password on the VM instance.

set_bootable(instance, is_bootable)

Set the ability to power on/off an instance.


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

snapshot(context, instance, image_id, update_task_state)

Create snapshot from a running VM instance.


Soft delete the specified instance.

spawn(context, instance, image_meta, injected_files, admin_password, network_info=None, block_device_info=None)

Create VM instance.

suspend(context, instance)

suspend the specified instance.

undo_aggregate_operation(context, op, aggregate, host, set_error=True)

Undo aggregate operation when pool error raised.

unfilter_instance(instance, network_info)

Removes security groups configured for an instance.


Unpause paused VM instance.

unplug_vifs(instance, network_info)

Unplug VIFs from networks.

unrescue(instance, network_info)

Unrescue the specified instance.

Previous topic

The nova.virt.xenapi.client.session Module

Next topic

The nova.virt.xenapi.fake Module

Project Source

This Page