Created
February 12, 2016 09:17
-
-
Save vMarkusK/6ac05ed4796447389eca to your computer and use it in GitHub Desktop.
VMware vRO Scriptable Task for VM Hardening
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var VcVMConfigSpec = new VcVirtualMachineConfigSpec(); | |
var changeValue = new Array(); | |
System.log ("Config From Array:"); | |
for (var i = 0; i < VcVmConfig.length; i++) { | |
System.log ("Name: " + VcVmConfig[i].key + " - " + "Value: " + VcVmConfig[i].value); | |
changeValue[i] = new VcOptionValue(); | |
changeValue[i].key = VcVmConfig[i].key; | |
changeValue[i].value = VcVmConfig[i].value; | |
} | |
VcVMConfigSpec.extraConfig = changeValue; | |
System.log ("Number of VM to Process:" + VcVmS.length); | |
for (var j = 0; j < VcVmS.length; j++) { | |
System.log ("VM to Set Options:" + VcVmS[j].Name); | |
ConfigTask = VcVmS[j].reconfigVM_Task(VcVMConfigSpec); | |
try { | |
var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(ConfigTask,progress,pollrate); | |
System.log("Config performed for VM : " + VcVmS[j].name); | |
Server.log("Config performed for VM : " + VcVmS[j].name); | |
} | |
catch (e) { | |
System.error("Config failed for VM : " + VcVmS[j].name + ". Reason: " + e); | |
Server.error("Config failed for VM : " + VcVmS[j].name + ". Reason: " + e); | |
} | |
MoveTask = VcVmS[j].relocateVM_Task(relocateSpec); | |
try { | |
var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(MoveTask,progress,pollrate); | |
System.log("vMotion/storage vMotion performed for VM : " + VcVmS[j].name); | |
Server.log("vMotion/storage vMotion performed for VM : " + VcVmS[j].name); | |
} | |
catch (e) { | |
System.error("vMotion/storage vMotion failed for VM : " + VcVmS[j].name + ". Reason: " + e); | |
Server.error("vMotion/storage vMotion failed for VM : " + VcVmS[j].name + ". Reason: " + e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment