Renaming Nutanix AHV host and Controller VM
The steps for renaming a Nutanix AHV host and its associated CVM are as follows.
1 - Put host into maintenance mode
Log into a CVM and put the host into maintenance mode using acli using the following command:
acli host.enter_maintenance_mode {:HostIP:} wait=true
You can double-check if your host is in maintenance mode by running
acli host.list
If your host has Schedulable set to false then you are good to go.
2 - Change the name of an AHV host
You can update the name of an AHV host by simply updating the following files using your text editor of choice (personally I use nano)
- /etc/sysconfig/network
- /etc/hostname
- /etc/hosts
Once you are done reboot the host for the change to take affect.
3 - Change the name of a Controller VM
To change the hostname of a CVM (how it is referenced on your network) log into its command line and run the following command:
sudo /usr/local/nutanix/cluster/bin/change_cvm_hostname {:NewCVMHostname:}
Please note: As per this health check your new hostname must start with “NTNX-” and end with “-CVM”
To change how the CVM shows up in Prism to match the new hostname you must change the VM name on the AHV host.
While logged into the CVM shut it down:
cvm_shutdown -h now
Next log into the AHV host and confirm the current CVM name by listing the VMs on that host:
virsh list --all
If you see your Controller VM in the list then you are good to rename it with the following command:
virsh domrename {:OldVMName:} {:NewCVMHostname:}
Next you will want to re-enable autostart for the VM:
virsh autostart {:NewCVMHostname:}
Then you can start the CVM back up:
virsh start {:NewCVMHostname:}
4 - Take host out of maintenance mode
Log into a Nutanix CVM and run the following acli command:
acli host.exit_maintenance_mode {:HostIP:}