Open v1gnesh opened 10 years ago
@v1gnesh Im sorry I dont exactly understand this.. Can you provide more details.
For example an exported XML of what? What specifications are you talking about?
If you can provide a bit more clarification I might be able to help you out with a sample.
@michaelrice An exported XML that would contain sysprep (for Windows) information to customize the VM as a part of the deploy-from-template process. Information such as admin account credentials, license, generate unique SID, joining a VM to a domain, and so on.
@v1gnesh ... another rather complex sample request. I feel like this one needs a bit more detail. You can edit your top comment to spell out the steps or write some pseudo code showing what you want to see.
+1 Any update on this? Is it possible to pass in an option to select a pre-defined guest customization template from vCenter? Similar to the Power-CLI sample here?
mmumshad, I think your request is a little more practical compared to the original request. The customization manager documentation is at: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.apiref.doc/vim.CustomizationSpecManager.html
From the service instance (si) you can access it: si.content.customizationSpecManager Regarding the above question about xml export/import, there is: XmlToCustomizationSpecItem(specItemXml) and CustomizationSpecItemToXml(item)
From the VirtualMachine (vm) you can directly use those specs with: vm.Customize(item.spec) Also if you want to validate your spec before trying it, you can do a check call: vm.CheckCustomizationSpec(item.spec) and that will give you a fault with any issue it finds.
So if you don't want to just store these customization's externally you can use the customization spec manager to keep it.
si.content.customizationSpecManager.Create(item) to create it. si.content.customizationSpecManager.Exists(item.info.key) to see if it exists. si.content.customizationSpecManager.Get(item.info.key) to retrieve it si.content.customizationSpecManager.info to iterate the info of what exists (and use Get on their keys)
So bringing this back to the PowerCLI sample, they have: $SourceCustomSpec = Get-OSCustomizationSpec -Name "SOURCE CUSTOMIZATION SPEC IN VCENTER" We'd have: customSpecItem = si.content.customizationSpecManager.Get("SOURCE CUSTOMIZATION SPEC IN VCENTER")
They don't use an explicit customize, but part of the createVm: New-VM -Name $FSVMName -Template $SourceVMTemplate -ResourcePool $TargetCluster -OSCustomizationSpec $SourceCustomSpec I'm not sure if they are just composing multiple calls into 1 function, but the customization part can be done with: from pyVim.task import WaitForTask WaitForTask(vm.Customize(customSpecItem.spec))
@tianhao64 ?
Use an exported XML to build equivalent commands for configuration. Alternatively, a sample showing how to access and setup those specifications.