On 21/06/2011 16:13, M Saunders TAS wrote:
> Hi,
>
> I'm trying to use python and the fantastic WMI module to manage Hyper-V 
> virtual machine resources and am having problems trying to modify properties 
> of an instance to pass back via WMI.
>
> The following code in powershell is what I need to emulate in python:
>
> $vmms = gwmi -namespace root\virtualization 
> Msvm_VirtualSystemManagementService
> $hardDisk = gwmi -namespace root\virtualization 
> Msvm_ResourceAllocationSettingData -filter  
> InstanceID='Microsoft:Definition\\353B3BE8-310C-4CF4-839E-4E1B14616136\\Default'"
> $hardDisk.Address = 0
> $vmms.AddVirtualSystemResources($vm,@($hardDisk.GetText(1)))
>
> The equivalent python code below produces a COM error "Provider is not 
> capable of the attempted operation" when trying to change object properties.
>
> import wmi
> c = wmi.WMI(namespace="virtualization", find_classes=False)
> VMMS = c.Msvm_VirtualSystemManagementService()[-1]
> HD =  
> c.Msvm_ResourceAllocationSettingData(InstanceID='Microsoft:Definition\\353B3BE8-310C-4CF4-839E-4E1B14616136\\Default')
> HD.Address = 0
> VMMS.AddVirtualSystemResources([HD.gettext_(1),], VM)
>
> I am sure that it is something simple and obvious that I am doing incorrectly 
> so apologies in advance for my stupidity.
> Any help or suggestions will be gratefully received.
>
> Thanks
>
> Matt
>
>
In the Python call to AddVirtualSystemResources() you've reversed the order of
the parameters.

-- 
Regards,

Graham Bloice

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to