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.hyperv Module

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

http://msdn.microsoft.com/en-us/library/cc723875%28v=VS.85%29.aspx
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 nova.virt.hyperv.HyperVConnection

Bases: nova.virt.driver.ComputeDriver

attach_volume(instance_name, device_path, mountpoint)
destroy(instance)

Destroy the VM. Also destroy the associated VHD disk files

detach_volume(instance_name, mountpoint)
get_info(instance_id)

Get information about the VM

init_host(host)
list_instances()

Return the names of all the instances known to Hyper-V.

list_instances_detail()
poll_rescued_instances(timeout)
reboot(instance)

Reboot the specified instance.

spawn(instance)

Create a new VM and start it.

update_available_resource(ctxt, host)

This method is supported only by libvirt.

nova.virt.hyperv.get_connection(_)