Initiate Raw Data cloud-init Customization
with the vSphere Web Services API
Use the following steps to initiate customization with raw cloud-init data by using
the vSphere Web Services API.
- Build a customization specification of typeCustomizationSpec. Set the following properties in the spec:
- TheglobalIPSettingsproperty must be present but need not contain its optional child properties. If the child properties are present, they will be ignored during the method call.
- Theidentityproperty must be present and must have typeCloudinitPrep.
- The child propertyidentity.metadatais required. It contains the entire text of the metadata file, less any final new line character.
- The child propertyidentity.userdatais optional. If present, it contains the entire text of the userdata file, less any final new line character.
Example:CloudinitPrep cloudinit = new CloudinitPrep(); cloudinit.setMetadata(metadataText); cloudinit.setUserdata(userdataText); CustomizationGlobalIPSettings ipSettings = new CustomizationGlobalIPSettings(); CustomizationSpec custSpec = new CustomizationSpec(); custSpec.setIdentity(cloudinit); custSpec.setGlobalIPSettings(ipSettings);ThenicSettingsMapproperty, if present, will be ignored for raw data customization. The cloud-init tool accepts network customization only from theidentity.metadataproperty. - Invoke the methodVirtualMachine.CustomizeVM_Task, passing thecustomizationSpecas parameter. The method returns a Task object that you can use to monitor completion of the customization steps.Example:ManagedObjectReference custTask = service.CustomizeVM_Task(vmRef, custSpec);
- Power on the virtual machine. As it boots, cloud-init applies the metadata configuration settings to the guest operating system. After the guest finishes booting and before it opens a shell window, cloud-init applies the userdata configuration.