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
type
CustomizationSpec
. Set the following properties in the spec:- The
globalIPSettings
property 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. - The
identity
property must be present and must have typeCloudinitPrep
.- The child property
identity.metadata
is required. It contains the entire text of the metadata file, less any final new line character. - The child property
identity.userdata
is optional. If present, it contains the entire text of the userdata file, less any final new line character.
- The child property
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);
Note: ThenicSettingsMap
property, if present, will be ignored for raw data customization. The cloud-init tool accepts network customization only from theidentity.metadata
property. - The
- Invoke the method
VirtualMachine.CustomizeVM_Task
, passing thecustomizationSpec
as 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.