Hello,
I am trying to build a workflow that will deploy a VM pre-built template, apply the customization spec via the Customization Manager, then finally customize the VM with additional disks, network, etc...
My current issue is with really understanding the actual terminology/category of the Customization Manager Spec. Inside of there, we have multiple specs for Windows & Linux.
I have this piece of test code that seems to get the correct spec.
//Set SDK connection var vcDatacentreString = vcDatacentre.name; var sdkUrl = "https://vcenter.thenewsgroup.com:443/sdk"; var allSdk = VcPlugin.allSdkConnections; var vcs = []; //Debug if (debugOutput == true) { System.debug("DEBUG_LOG_Module=SetVmFolder: var sdkUrl = " + sdkUrl); System.debug("DEBUG_LOG_Module=SetVmFolder: var allSdk = " + allSdk); } // Validate SDK connection to target vCenter var len = allSdk.length; for (i = 0; i < len; i++) { if (allSdk[i].displayName == sdkUrl) { vcs.push(allSdk[i]); } //Debug if (debugOutput == true) { System.debug("DEBUG_LOG_Module=SetVmFolder: var allSdk[i] = " + allSdk[i]); System.debug("DEBUG_LOG_Module=SetVmFolder: var allSdk[i].displayName = " + allSdk[i].displayName); } } System.log("Target vCenter SDK connection: " + vcs) // Error check if (vcs.length != 1) { System.error("!!!!!!!!!!!!!!!!!!!!!Error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); System.error("Module=SetVmFolder"); System.error("Too many/few vCenters match SDK string"); System.error("!!!!!!!!!!!!!!!!!!!!!Error!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); throw Error(); } var SDKConnection = vcs[0]; //var ip = "10.10.10.233"; //var custspec = new VcCustomizationSpec(); //var custspec = new VcVirtualMachineCloneSpec(); var con = SDKConnection; System.debug("con: " + con); var cms = con.customizationSpecManager; System.debug("cms : " + cms); System.debug("cmsType: " + cms.vimType); var customSpecExists = cms.doesCustomizationSpecExist(specName); System.debug("isda: " + customSpecExists); //Get CustSpec if it exist if (customSpecExists) { var customSpecItem = cms.getCustomizationSpec(specName); System.debug("got custSpecItem: " + customSpecItem); custspec = customSpecItem.spec; System.debug("contents custSpec: " + custspec); System.debug("custspec name: " + customSpecItem.info.name); System.debug("custspec type: " + customSpecItem.info.type); System.debug("custspec description: " + customSpecItem.info.description); } else throw "customspec not found"; /* var oldip = custspec.nicSettingMap[0].adapter.ip; System.debug("oldip: " + oldip); var fixedIp = new VcCustomizationFixedIp(); fixedIp.ipAddress = ip; custspec.nicSettingMap[0].adapter.ip = null; custspec.nicSettingMap[0].adapter.ip = fixedIp; System.debug("new ip in custspec: " + custspec.nicSettingMap[0].adapter.ip); System.debug("new ipAddress in custspec: " + custspec.nicSettingMap[0].adapter.ip.ipAddress); */ var newSpec = custspec;
My confusion comes in with what type of spec is needed to equate the manual template deployment process in vCenter when you select Customization Manager?
I have looked through the API and found:
VcCustomizationSysprep
VcVirtualMachineSpec
VcVirtualMachineCloneSpec
and a few others
If I try to pass this spec to com.vmware.library.vc.vm(cloneVM) = I get the error that the spec is not a VirtualMachineCloneSpec
If I try to pass this spec to com.vmware.library.vc.vm(customizeVM) = it complains the customization cannot happen when the VM is powered on (leading me to believe it thinks this is a device spec config)
Thanks
B