jeudi 9 avril 2015

Modify "ChannelInstanceGuid" of a Network Adapter using WMI

some context:

I'm working on web application (ASP.NET MVC) which uses WMI to manage some hyper-v virtual machines over a local network. Currently I'm trying to implement a cloning feature which exports a virtual machine and then imports it on the same host.


the problem:

I need to be able to change to computer name of the resulted virtual machine. I know I can use the Rename method of Win32_ComputerSystem (root\cimv2), but in order to be able to connect to that namespace I need the ip/dns of the resulted virtual machine. The problem is: after I import the configuration file (resulted after export) and I realize the planned virtual machine, the ip assigned to the new virtual machine is the same as the original machine's.


tried so far:

I've spent some time playing with configuration file and it appears that if I change the following element's value (for the Network Adapter resource tag) with a random GUID, the realized virtual machine gets a new IP.



<ChannelInstanceGuid type="string">{some GUID here}</ChannelInstanceGuid>


This appears to match the VirtualSystemIdentifiers property of the Msvm_SyntheticEthernetPortSettingData class (root\virtualization\v2). The only problem is that the property is read-only. On msdn it says that using the ModifyVirtualSystemResources method of the Msvm_VirtualSystemManagementService class I should be able to change it, but unfortunately it is only supported in the root\virtualization namespace.


Any ideas?


Aucun commentaire:

Enregistrer un commentaire