The nova.virt.hyperv.driver Module

A connection to Hyper-V . Uses Windows Management Instrumentation (WMI) calls to interact with Hyper-V Hyper-V WMI usage:

The Hyper-V object model briefly:

The physical computer and its hosted virtual machines are each represented by the Msvm_ComputerSystem class.

Each virtual machine is associated with a Msvm_VirtualSystemGlobalSettingData (vs_gs_data) instance and one or more Msvm_VirtualSystemSettingData (vmsetting) instances. For each vmsetting there is a series of Msvm_ResourceAllocationSettingData (rasd) objects. The rasd objects describe the settings for each device in a VM. Together, the vs_gs_data, vmsettings and rasds describe the configuration of the virtual machine.

Creating new resources such as disks and nics involves cloning a default rasd object and appropriately modifying the clone and calling the AddVirtualSystemResources WMI method Changing resources such as memory uses the ModifyVirtualSystemResources WMI method

Using the Python WMI library:
Tutorial:
http://timgolden.me.uk/python/wmi/tutorial.html

Hyper-V WMI objects can be retrieved simply by using the class name of the WMI object and optionally specifying a column to filter the result set. More complex filters can be formed using WQL (sql-like) queries. The parameters and return tuples of WMI method calls can gleaned by examining the doc string. For example: >>> vs_man_svc.ModifyVirtualSystemResources.__doc__ ModifyVirtualSystemResources (ComputerSystem, ResourceSettingData[])

=> (Job, ReturnValue)’

When passing setting data (ResourceSettingData) to the WMI method, an XML representation of the data is passed in using GetText_(1). Available methods on a service can be determined using method.keys(): >>> vs_man_svc.methods.keys() vmsettings and rasds for a vm can be retrieved using the ‘associators’ method with the appropriate return class. Long running WMI commands generally return a Job (an instance of Msvm_ConcreteJob) whose state can be polled to determine when it finishes

class HyperVDriver

Bases: nova.virt.driver.ComputeDriver

attach_volume(connection_info, instance_name, mountpoint)

Attach volume storage to VM instance

check_can_live_migrate_destination(ctxt, instance, block_migration, disk_over_commit)
check_can_live_migrate_destination_cleanup(ctxt, dest_check_data)
check_can_live_migrate_source(ctxt, instance, dest_check_data)
compare_cpu(cpu_info)
confirm_migration(migration, instance, network_info)

Confirms a resize, destroying the source VM

destroy(instance, network_info=None, cleanup=True)
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)

Completes a resize, turning on the migrated instance

finish_revert_migration(instance, network_info)

Finish reverting a resize, powering back on the instance

get_console_output(instance)
get_host_stats(refresh=False)

See xenapi_conn.py implementation.

get_info(instance)
get_volume_connector(instance)
host_power_action(host, action)

Reboots, shuts down or powers up the host.

init_host(host)
legacy_nwinfo()
list_instances()
live_migration(context, instance_ref, dest, post_method, recover_method, block_migration=False)
pause(instance)
plug_vifs(instance, network_info)
poll_rescued_instances(timeout)
post_live_migration_at_destination(ctxt, instance_ref, network_info, block_migration)
power_off(instance)
power_on(instance)
pre_live_migration(context, instance, block_device_info, network_info)
reboot(instance, network_info, reboot_type, block_device_info=None)
resume(instance)
set_host_enabled(host, enabled)

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

snapshot(context, instance, name)
spawn(context, instance, image_meta, network_info, block_device_info=None)
suspend(instance)
unfilter_instance(instance, network_info)

Stop filtering instance

unpause(instance)
unplug_vifs(instance, network_info)
update_available_resource(context, host)
update_host_status()

See xenapi_conn.py implementation.

Previous topic

The nova.virt.hyperv.constants Module

Next topic

The nova.virt.hyperv.ioutils Module

This Page