VMware {code} Community
menyh
Contributor
Contributor

Setting Manual MAC address after Link Clone

Hi,

I am attempting to create a link clone of a virtual machine but have the Cloned Virtual Machine keep the old Virtual Machine's MAC address of all NICs (Both machines will not work at the same time, ever).

I have tried saving the nic MAC addresses before creating the clone and then using Reconfig_task in order to change the the Cloned machine's Mac address to match the old ones - but that did not seem to work (Even though VSphere shows that a reconfiguration is in progress).

VirtualMachineConfigSpec machineSpec = new VirtualMachineConfigSpec();

VirtualDeviceConfigSpec nicSpec  = new VirtualDeviceConfigSpec();

nicSpec.operation = VirtualDeviceConfigSpecOperation.edit;

nicSpec.device = currDevice;

((VirtualE1000)nicSpec.device).addressType = "manual";

((VirtualE1000)nicSpec.device).macAddress ="00:50:56:bb:72:bd";  (just put some mac valid address here - that doesnt work either).

((VirtualE1000)nicSpec.device).wakeOnLanEnabled = true ;

_webSvcApiUtil.Connection.Service.ReconfigVM_Task(clonedMachine, machineSpec);

(ignore the syntax - i just copy pasted the relevant parts).

The above code did not change the new machine's mac address at all.

As i stated above - the machine's MAC did not even change if i put any valid mac address .

Any idea what might be wrong??? and if not - is there any way to show a log of what was reconfigured?? ( to see the invalid parameters that caused the VCenter to ignore my request)

Thanks in advance!

Reply
0 Kudos
1 Reply
stripeyfish
Contributor
Contributor

I have found that sometimes it is better if you get VirtualMachineConfigSpec from existing machine and update it as opposed to creating a new VirtualMachineConfigSpec with just the changes you need set. I.e. get configspec from your first VM, update the MAC, then use this to reconfigure the new VM; or maybe just get VirtualDeviceConfigSpec part from current VM, update the MAC bit, set this in the new VirtualMachineConfigSpec and reconfigure the new VM.

There is usually one bit you have forgotten to set that is required which means the change you are trying to make just wont apply

Reply
0 Kudos