Lets first understand how guest customization on ESX works.
When we do the customization of ESX on Linux, we can customize or update the ESX Host name or the IP address. Set the IP address settings such as in file /etc/sysconfig/network-interfaces/ifcfg-eth files. Setting the gateway, subnet mask, DNS IP addresses, setting timezone etc.
While when we do the customization of the windows guest we do things such as generating new SID, modifying computer name, entering product key etc. Also we update some things such as IP settings, timezone, domain/workgroup, admin login password etc.
Guest Customization on ESX using vSphere SDK.
To customize guest OS we need CustomizationSpec object, which contains information required to customize a virtual machine when deploying it or migrating it to a new host.
CustomizationSpec spec = new CustomizationSpec();
Next important object we need to create is CustomizationAdapterMapping which maps a virtual network adapter with its IP settings. It contains information about IP settings and MAC address. MAC address is optional and cannot be modified. In following code we have created an array of CustomizationAdapterMapping with number of network adapters.
CustomizationAdapterMapping nicSettingMap = new CustomizationAdapterMapping[len];
Then we can create the CustomizationIPSettings object which will have the information of IP address such as dnsDomain, dnsServerList, gateway, IP address …
For IP address CustomizationIpGenerator is used to obtain a unique IP address for this virtual network adapter. To obtain IP address you can use CustomizationCustomIpGenerator, CustomizationDhcpIpGenerator, CustomizationFixedIp, CustomizationUnknownIpGenerator methods to create custom IP address , DHCP address, fixed IP or unknown IP.
You can specify Virtual Machine Name using CustomizationFixedName.
As in this example we are customizing a Linux guest, we need to use CustomizationLinuxPrep, which is counter part of the Windows Sysprep object. CustomizationLinuxPrep contains machine-wide settings that identify a Linux machine such as domain, hostname, timezone…
This way using these objects you can customize guest on ESX.