VMware Cloud Community
lorp
Contributor
Contributor

How to set DHCP_HOSTNAME when cloning a VM in vCenter?

I am writing a python program using the pysphere library, to clone a template in vCenter 5.1.  The VM will be running Linux as the guest OS, and I need to have the DHCP_HOSTNAME variable set in the /etc/sysconfig/network-scripts/ifcfg-eth0 file at boot time.  The template is set up for DHCP and has a suitable ifcfg-eth0 file already, and I just want to customize the hostname and DNS servers.  When the cloned VM boots, the VMware tools are rewriting the ifcfg-eth0 file, and the resulting file does not contain DHCP_HOSTNAME anymore.  Is there some customization setting that will retain it?

I am using CustomizationLinuxPrep to customize the cloned VM.  I have attached CustomizationGlobalIPSettings with dnsServerList and dnsSuffixList.  I also have a CustomizationLinuxPrep with the hostName and domain.  Finally, I have CustomizationDhcpIpGenerator specified for each nic in the clone.

Should I add or remove something, in order to have DHCP_HOSTNAME in the ifcfg-eth0 file? 

Also, the /var/log/vmware-imc/toolsDeployPkg.log file contains this output regarding the ifcfg-eth0 file:

DEBUG: opening file for writing (/etc/sysconfig/network-scripts/ifcfg-eth0).

DEBUG: Command: chmod 644 /etc/sysconfig/network-scripts/ifcfg-eth0

Is there a way to get more details in the log, like what it is writing and why?

Tags (3)
4 Replies
akshunj
Enthusiast
Enthusiast

I see this post is old, but I am also running into the same problem. Any ideas? vCenter 5.0

0 Kudos
aneverov
VMware Employee
VMware Employee

Hi,

We don't support that setting today. You would need to go for some workaround like hooking up some custom script as init.d/service to add the setting yourself. It should work fine given that we issue a mandatory reboot after customization is done.

Thanks,

Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
akshunj
Enthusiast
Enthusiast

Hi,

That's exactly what I ended up doing. I created an init script to check if the parameter is there,and if not, add it, and then bounce the network interface. I noticed there is a KB article to modify VCD to add this setting for guest customization, so I thought it might be possible with vCenter.

Thanks.

0 Kudos
aneverov
VMware Employee
VMware Employee

Yes, VCD supports some feature called "post-customization script" which could be used to apply this workaround instead of hooking up into init.d.

vCenter doesn't have it.

Thanks,

Andrii

/* Please remember to mark answer as 'helpful' or 'correct' such that other users know it can be used and people focusing on ‘unanswered’ questions can skip it. */
0 Kudos