Hi,
How would I change a VM's mac address with orchestrator?
I tried using a scriptable task and doing something like this:
var configSpec = new VcVirtualMachineConfigSpec();
var deviceConfigSpecs = new Array();
deviceConfigSpec = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualEthernetCardNetworkConfigSpec( network1, macAddress1 );
configSpec.deviceChange = deviceConfigSpecs;
task = vm.reconfigVM_Task( configSpec );
When i run it, the task starts, and is successful but no change is made to the mac address.
IM sure there is something simple I am missing.
Thanks!
Jason
Hi,
in my opinion, you have to change the mac address additionally...
if ( macAddress != null && macAddress != "" ) {
vNetwork.addressType = "Manual";
vNetwork.macAddress = macAddress;
}
best regards
Christian
Hi!
too late night to give it a try in the lab, but I may saw three possible things:
1. Do you need a
devicespec.operation = VcVirtualDeviceConfigSpecOperation.edit;
to specify that the device should be changed?
it's already in the createVirtualEthernetCardNetworkConfigSpec()-action...
... Do you want to add a new card or change an existing card?
2. Did you run into the known issue:
For example, the following code does not work:
var spec = new VcVirtualMachineConfigSpec();
spec.deviceChange = [];
spec.deviceChange[0] = new VcVirtualDeviceConfigSpec();
System.log(spec.deviceChange[0]);
In the above code, Orchestrator converts the empty spec.deviceChange
JavaScript array into the fixed-size Java array VirtualDeviceConfigSpec[]
before it calls setDeviceChange()
. When calling spec.deviceChange[0] = new VcVirtualDeviceConfigSpec()
, Orchestrator calls getDeviceChange()
and the array remains a fixed, empty Java array. Calling spec.deviceChange.add()
results in the same behavior.
Workaround: Declare the array as a local variable, as follows:
var spec = new VcVirtualMachineConfigSpec();
var deviceSpec = [];
deviceSpec[0] = new VcVirtualDeviceConfigSpec();
spec.deviceChange = deviceSpec;
System.log(spec.deviceChange[0]);
https://vmware.ie/support/orchestrator/doc/vco_411_release_notes.html
3. I miss one line where you put deviceConfigSpec to the array, something like
deviceConfigSpecs.push(deviceConfigSpec);
Regards,
Joerg
Thanks for your input guys.
A lot (almost all) of that sorta went over my head, as I am pretty new to orchestrator, and trying to bumble my way through it.
I will digest what you have told me and see where I land on it tomorrow.
To answer your question, I am trying to EDIT an existing nic cards mac address.
thanks again!
Jason