The nova.virt.xenapi.driver Module

A driver for XenServer or Xen Cloud Platform.

Related Flags

xenapi_connection_url:
 URL for connection to XenServer/Xen Cloud Platform.
xenapi_connection_username:
 Username for connection to XenServer/Xen Cloud Platform (default: root).
xenapi_connection_password:
 Password for connection to XenServer/Xen Cloud Platform.
target_host:the iSCSI Target Host IP address, i.e. the IP address for the nova-volume host
target_port:iSCSI Target Port, 3260 Default
iqn_prefix:IQN Prefix, e.g. ‘iqn.2010-10.org.openstack’

Variable Naming Scheme

  • suffix “_ref” for opaque references
  • suffix “_uuid” for UUIDs
  • suffix “_rec” for record objects
class XenAPIDriver(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(connection_info, instance_name, mountpoint)

Attach volume storage to VM instance

change_instance_metadata(context, instance, diff)

Apply a diff to the instance metadata.

check_can_live_migrate_destination(ctxt, instance_ref, block_migration=False, disk_over_commit=False)

Check if it is possible to execute live migration.

Parameters:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance object
  • block_migration – if true, prepare for block migration
  • disk_over_commit – if true, allow disk over commit
check_can_live_migrate_destination_cleanup(ctxt, dest_check_data)

Do required cleanup on dest host after check_can_live_migrate calls

Parameters:
  • ctxt – security context
  • disk_over_commit – if true, allow disk over commit
check_can_live_migrate_source(ctxt, instance_ref, dest_check_data)

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:
  • context – security context
  • instance_ref – nova.db.sqlalchemy.models.Instance
  • dest_check_data – result of check_can_live_migrate_destination includes the block_migration flag
confirm_migration(migration, instance, network_info)

Confirms a resize, destroying the source VM

destroy(instance, network_info, block_device_info=None)

Destroy VM instance

detach_volume(connection_info, instance_name, mountpoint)

Detach volume storage to VM instance

ensure_filtering_rules_for_instance(instance_ref, network_info)
finish_migration(context, migration, instance, disk_info, network_info, image_meta, resize_instance=False, block_device_info=None)

Completes a resize, turning on the migrated instance

finish_revert_migration(instance, network_info, block_device_info=None)

Finish reverting a resize, powering back on the instance

get_all_bw_usage(instances, start_time, stop_time=None)

Return bandwidth usage info for each interface on each running VM

get_available_resource()

Retrieve resource info.

This method is called when nova-compute launches, and as part of a periodic task.

Returns:dictionary describing resources
get_console_output(instance)

Return snapshot of console

get_console_pool_info(console_type)
get_diagnostics(instance)

Return data about VM diagnostics

static get_host_ip_addr()
get_host_stats(refresh=False)

Return the current state of the host. If ‘refresh’ is True, run the update first.

get_host_uptime(host)

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

get_info(instance)

Return data about VM instance

get_instance_disk_info(instance_name)

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

get_vnc_console(instance)

Return link to instance’s VNC console

get_volume_connector(instance)

Return volume connector information

host_maintenance_mode(host, mode)

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

host_power_action(host, action)

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.

host_state
init_host(host)
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, network_info)

inject network info for specified instance

legacy_nwinfo()

Indicate if the driver requires the legacy network_info format.

list_instances()

List VM instances

live_migration(ctxt, instance_ref, dest, post_method, recover_method, block_migration=False, migrate_data=None)

Performs the live migration of the specified instance.

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.
Params block_migration:
 if true, migrate VM disk.
Params migrate_data:
 implementation specific params
migrate_disk_and_power_off(context, instance, dest, instance_type, network_info, block_device_info=None)

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

pause(instance)

Pause VM instance

plug_vifs(instance_ref, network_info)

Plug VIFs into networks.

poll_rebooting_instances(timeout)

Poll for rebooting instances

poll_rescued_instances(timeout)

Poll for rescued instances

post_live_migration_at_destination(ctxt, instance_ref, network_info, block_migration)

Post operation of live migration at destination host.

Params ctxt:security context
Params instance_ref:
 nova.db.sqlalchemy.models.Instance object instance object that is migrated.
Params network_info:
 instance network infomation

:params : block_migration: if true, post operation of block_migraiton.

power_off(instance)

Power off the specified instance

power_on(instance)

Power on the specified instance

pre_block_migration(ctxt, instance_ref, disk_info_json)

Used by libvirt for live migration. We rely on xenapi checks to do this for us. May be used in the future to populate the vdi/vif maps

pre_live_migration(context, instance_ref, block_device_info, network_info)

Preparation live migration.

Params block_device_info:
 It must be the result of _get_instance_volume_bdms() at compute manager.
reboot(instance, network_info, reboot_type, block_device_info=None)

Reboot VM instance

refresh_instance_security_rules(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

refresh_provider_fw_rules()
refresh_security_group_members(security_group_id)

Updates security group rules for all instances associated with a given security group Invoked when instances are added/removed to a security group

refresh_security_group_rules(security_group_id)

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_network(instance)

reset networking for specified instance

resume(instance)

resume the specified instance

set_admin_password(instance, new_pass)

Set the root/admin password on the VM instance

set_host_enabled(host, enabled)

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

snapshot(context, instance, image_id)

Create snapshot from a running VM instance

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

Create VM instance

suspend(instance)

suspend the specified instance

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

Undo aggregate operation when pool error raised

unfilter_instance(instance_ref, network_info)

Removes security groups configured for an instance.

unpause(instance)

Unpause paused VM instance

unplug_vifs(instance_ref, network_info)

Unplug VIFs from networks.

unrescue(instance, network_info)

Unrescue the specified instance

update_host_status()

Update the status info of the host, and return those values to the calling program.

class XenAPISession(url, user, pw)

Bases: object

The session to invoke XenAPI SDK calls

call_plugin(plugin, fn, args)

Call host.call_plugin on a background thread.

call_plugin_serialized(plugin, fn, *args, **kwargs)
call_xenapi(method, *args)

Call the specified XenAPI method on a background thread.

get_all_refs_and_recs(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.

get_rec(record_type, ref)
get_session_id()

Return a string session_id. Used for vnc consoles.

get_xenapi_host()

Return the xenapi host on which nova-compute runs on.

Previous topic

The nova.virt.xenapi.agent Module

Next topic

The nova.virt.xenapi.fake Module

This Page