Text Size
Friday, May 18, 2012
Articles Learn VCO Force a VM to boot from several devices
User Rating: / 0
PoorBest 

One thing vCO users and administrators always ask for is changing the boot order for virtual machines. The bad news is: It is part of the BIOS of the virtual machine (.nvram). But based on this community discussion and the solutions in PowerShell, I decided to test it with the vCenter Orchestrator and I was surprised how easy it is!

var changedValue = new Array();
changedValue[0] = new VcOptionValue();
changedValue[0].key = "bios.bootDeviceClasses";
changedValue[0].value = "allow:"+device;

var ConfigSpec = new VcVirtualMachineConfigSpec();
ConfigSpec.extraConfig = changedValue;

task = vm.reconfigVM_Task(ConfigSpec);

With this little code you are able to set the VcOptionValue for the virtual machine. I used 2 input parameters: the vm(VC:VirtualMachine) and device(string) for defining which device should be used (cd, net, hd). Based on the selected device the VM is reconfigured and starts only from this device. Please keep in mind to change it back!

To review the settings I use a second simple workflow:

System.log(vm.config.extraConfig.length);
for(i in vm.config.extraConfig){
  System.log("Key: " + vm.config.extraConfig[i].key);
  System.log("Value: " + vm.config.extraConfig[i].value);
}

which shows all keys and values of the virtual machine .extraConfig definition. So, as you can see, really simple thing :)