1 November 2021

Nutanix Cheat Sheet

Hopefully, this helps you as much as it helps me. This is by no means a comprehensive list. It’s just a place for me to jot down the various commands I use as I get to know Nutanix more intimately.

Run all NCC Health Checks

ncc health_checks run_all

Shutdown CVM

cvm_shutdown -P now

Check status of CVM metadata ring, see if all CVMs are ‘UP’

nodetool -h 0 ring

Check Cluster Status on CVM

Cluster status

Check if CVM processes are in UP state

cluster status | grep -v UP

Check CVM Metadata store status

ncli host ls | egrep "Meta[Id]Name"

Verify data resiliency

ncli cluster get-domain-fault-tolerance-status type=node

Check which CVM is the Minerva Leader

afs info.get_leader

Check which CVM is the Prism Leader

afs info.prism_leader

Check which CVM is the LCM Leader

lcm_leader

Start cluster

Cluster start

Restart prism on CVM

genesis restart

Prism/CVM Status

genesis status

Check if CVM is in Maintenance Mode
Note: Only the Scavenger, Genesis, and Zeus processes must be running (process ID is displayed next to the process name).

genesis status | grep -v "\[\]"

Cluster/Host Hardware Info (RAM, DIMMs, CPUs, etc…) from CVM

ncc hardware_info show_hardware_info

Migrate VM to a different storage container (AOS >= 5.19)

acli vm.update_container vm-name container=target-container wait=false

Change AHV host name (AOS >= 5.20)

change_ahv_hostname --host_ip=HOST_IP --host_name=NEW-AHV-HOSTNAME

Get all CVM IPs within the cluster

svmips

Get all Host IPs within the cluster

hostips

Get all IPMI IPs within the cluster

ipmiips

Get Cluster Info

ncli cluster info

Get all Hosts Info

acli host.info
ncli host ls

Verify the state of Host
-Entered Maintenace: node_state equals to kEnteredMaintenanceMode and schedulable equals to False.
-Exited Maintenace: node_state equals to kAcropolisNormal and schedulable equals to True.

acli host.get host-ip

Put a CVM in maintenance mode

ncli host edit id=HOST_ID enable-maintenance-mode=true

Exit a CVM from maintenance mode

ncli host edit id=HOST_ID enable-maintenance-mode=false

Put an AHV host in maintenance mode
Note: “wait=true” allows the host to migrate VMs to other hosts before it enters maintenance mode.

acli host.enter_maintenance_mode HOST_IP wait=true

Exit an AHV host from maintenance mode

acli host.exit_maintenance_mode HOST_IP

Check if AHV host is Schedulable

acli host.list

Check AOS version on all CVMs

allssh 'cat /etc/nutanix/release_version'

Check AHV version on all nodes

hostssh 'cat /etc/nutanix-release'

List all VMs on a cluster

acli vm.list

List all VMs on a host

acli host.list_vms host

List VMs in a powered ON state

acli vm.list power_state=on

List VMs in a powered OFF state

acli vm.list power_state=off

Power off all VMs running on the cluster

for vm_name in `acli vm.list power_state=on | grep -v ^'VM
name' | awk '{print $1}'`; do acli vm.force_off $vm_name; done

Power on all VMs running on the cluster

for vm_name in `acli vm.list power_state=off | grep -v ^'VM
name' | awk '{print $1}'`; do acli vm.on $vm_name; done
Category: Nutanix | LEAVE A COMMENT
6 August 2021

Nutanix password change

If you leave the default passwords on your Nutanix cluster you’ll start to see alerts in Prism that the default password is still in use. It will alert you about it for both the CVM and the physical hosts. This alert is very easy to clear by just updating the password. Here’s how…


To run just the default password health check from your CVM you can use the following command:

nutanix@cvm$ ncc health_checks system_checks default_password_check

Or you can also run the complete set of NCC health checks:

nutanix@cvm$ ncc health_checks run_all

If the health check passes, you’ll see this line in the output:

/health_checks/system_checks/default_password_check              [ PASS ]

If the health check fails you’ll see this in the output and it will tell you which host(s) alerted:

/health_checks/system_checks/default_password_check              [ INFO ]
------------------------------------------------------------------------+
Detailed information for default_password_check:
Node x.x.x.x:

Nutanix Controller VM (CVM) password change

Running this command will prompt you for your new desired password for the ‘nutanix’ user on the CVM:
nutanix@cvm$ sudo passwd nutanix

Once you change the CVM’s password it will replicate to all of the CVMs in your cluster, thus changing the password on all of your CVMs at once.

Hypervisor password change

  • AHV
    To change the local “admin” account password for all AHV hypervisors in the Nutanix cluster, you can run this command from any CVM in the cluster.
    nutanix@cvm$ echo -e "CHANGING ALL AHV HOST ADMIN PASSWORDS. Note - This script cannot be used for passwords that contain special characters ( $ \ { } ^ &)\nPlease input new password: "; read -s password1; echo "Confirm new password: "; read -s password2; if [ "$password1" == "$password2" ] && [[ ! "$password1" =~ [\{\$\^}\&] ]]; then hostssh "echo -e \"admin:${password1}\" | chpasswd"; else echo "The passwords do not match or contain invalid characters (\ $ { } ^ &)"; fi
    To change the local “nutanix” account password for all AHV hypervisors in the Nutanix cluster, you can run this command from any CVM in the cluster.
    nutanix@cvm$ echo -e "CHANGING ALL AHV HOST NUTANIX PASSWORDS. Note - This script cannot be used for passwords that contain special characters ( $ \ { } ^ &)\nPlease input new password: "; read -s password1; echo "Confirm new password: "; read -s password2; if [ "$password1" == "$password2" ] && [[ ! "$password1" =~ [\{\$\^}\&] ]]; then hostssh "echo -e \"nutanix:${password1}\" | chpasswd"; else echo "The passwords do not match or contain invalid characters (\ $ { } ^ &)"; fi

  • VMware ESXi 
    To change the local root password for all ESXi hosts in the cluster, you can run this command from any CVM in the cluster.
    nutanix@cvm$ echo -e "CHANGING ALL ESXi HOST PASSWORDS. Note - This script cannot be used for passwords that contain special characters ( $ \ { }  ^ &)\nPlease input new password: "; read -s password1; echo "Confirm new password: "; read -s password2; if [ "$password1" == "$password2" ] && [[ ! "$password1" =~ [\\\{\$\^\}\&] ]]; then hostssh "echo -e \"${password1}\" | passwd root --stdin"; else echo "The passwords do not match or contain invalid characters (\ $ { } ^ &)"; fi

  • Microsoft Hyper-V 
    To change the local administrator password for all Hyper-V hosts in the cluster, you can run this command from any CVM in the cluster.
    nutanix@cvm$ echo -e "CHANGING ALL HYPER-V HOST PASSWORDS. Note - This script cannot be used for passwords that contain special characters ( $ \ { }  ^)\nPlease input new password: "; read -s password1; echo "Confirm new password: "; read -s password2; if [ "$password1" == "$password2" ] && [[ ! "$password1" =~ [\ \"\'\\\{\$\^\}] ]]; then hostssh "net user administrator $password1"; echo "Updating Host and ManagementServer Entries..."; ncli host ls | grep -i id | grep -Eo "::[0-9]*" | cut -c 3- | while read hID; do ncli host edit id=$hID hypervisor-password=$password1;done  > /dev/null; ncli host ls | grep "Hypervisor Address" | awk '{print $4}' | while read hIP; do ncli managementserver edit name=$hIP password=$password1;done > /dev/null;  else echo "The passwords do not match or contain invalid characters (\ $ { } ^)"; fi

Further info can be found in the following Nutanix KB.

Category: Nutanix | LEAVE A COMMENT