пятница, 18 апреля 2014 г.

Control Hyper-V with Python

Collection of links for writing Hyper-V script to control Hyper-V from Python

To manage Hyper-V machines there's WMI API (in my case I'll use Python WMI. There's also PowerShell version too, obviously)

When Windows 8 came out two versions of API appeared: root\virtualization and root\virtualization\v2

I think code is the best documentation for API (at least when I wrote my scripts it was much more useful when I found code examples), so without any words, without tl;dr - read code of my scripts.

Hyper-V WMI Provider Version 1

Namespace: root\virtualization
My script:
https://github.com/rrader/hue-build/blob/master/sandbox/hyperv.py

MSDN Documentation: http://msdn.microsoft.com/en-us/library/hh850319%28v=vs.85%29.aspx

Control Hyper-V VMs with Python - http://stackoverflow.com/questions/12970303/control-hyper-v-vms-with-python

Most useful source is Nova (OpenStack) driver for Hyper-V
https://github.com/openstack/nova/tree/master/nova/virt/hyperv
(all files without v2 suffix).

Hyper-V WMI Provider Version 2

Namespace: root\virtualization\v2
My script:
https://github.com/rrader/hue-build/blob/master/sandbox/hypervv2.py

Also, most useful source is Nova (OpenStack) driver for Hyper-V
https://github.com/openstack/nova/tree/master/nova/virt/hyperv
(all files with v2 suffix).

Network operations:
https://github.com/petrutlucian94/nova_dev/blob/master/nova/virt/hyperv/networkutilsv2.py

Attaching a VHD To A VM Using The Hyper-V WMI V2 Namespace - http://blogs.msdn.com/b/taylorb/archive/2013/08/12/attaching-a-vhd-to-a-vm-using-the-hyper-v-wmi-v2-namespace.aspx
1 комментарий
  1. Hi

    I am creating a customized vm using the preconfigure hdd i want to attch hdd to the controller 0 can you help me the code attaching the hdd using the python since I am unable to understand the classes and enumeration ways.

    ОтветитьУдалить