To manage Hyper-V machines there's WMI API (in my case I'll use Python WMI. There's also PowerShell version too, obviously)
- Python 2.7 x64 bit
- pywin32 - build 218 was latest on publication date
- WMI package - https://pypi.python.org/pypi/WMI/
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\virtualizationMy 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\v2My 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
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.