APIs

CLIs - nCLI and aCLI

Based on: PC 2023.1.0.1 | AOS 6.6

» Download this section as PDF (opens in a new tab/window)

aCLI

The Acropolis CLI (aCLI) is the CLI for managing the Acropolis and AHV portion of the Nutanix product for tasks like AHV host, network, and VM management. These capabilities were enabled in releases after AOS 4.1.2 and are available on Nutanix AHV cluster CVMs only. aCLI is not supported on Prism Central.

The current aCLI command reference can be found on the Nutanix Portal.

Enter aCLI Shell

Description: Enter aCLI shell.

acli

OR

Description: Execute aCLI command via Linux shell

acli <command>

Output aCLI Response in JSON Format

Description: Enter aCLI shell. Any responses to commands will be in JSON format.

acli –o json

List AHV Hosts

Description: Lists AHV nodes in the cluster.

host.list

This screenshot shows the output from ‘host.list’ in both tabulated and JSON format. The obfuscated information are cluster specific serial numbers and IP address details.

Tabulated vs JSON output from aCLI

Create Network

Description: Create network based on VLAN

net.create NAME TYPE.ID[.VSWITCH] ip_config=A.B.C.D/NN vlan="VLAN"

Example:

net.create vlan.133 ip_config=10.1.1.1/24 vlan="133"

List Networks

Description: List networks

net.list

Create DHCP Scope

Description: Create dhcp scope

net.add_dhcp_pool NET NAME start=START IP A.B.C.D end=END IP W.X.Y.Z

Note: The last usable IP address in the network range is selected for the Acropolis DHCP server if an address for the DHCP server wasn’t set during network creation.

Example:

net.add_dhcp_pool vlan.100 start=10.1.1.100 end=10.1.1.200 vlan="100"

Get Existing Network Details

Description: Get a network’s VMs and details including VM name / UUID, MAC address and IP

net.list_vms NETNAME

Example:

net.list_vms vlan.133

Configure DHCP DNS Servers for Network

Description: Set DHCP DNS

net.update_dhcp_dns NETNAME servers=COMMA SEPARATED DNS IPs domains=COMMA SEPARATED DOMAINS

Example:

net.update_dhcp_dns vlan.100 servers=10.1.1.1,10.1.1.2 domains=ntnxlab.local

Create Virtual Machine

Description: Create VM

vm.create COMMA SEPARATED VM NAMES memory=NUM MEM MB num_vcpus=NUM VCPU num_cores_per_vcpu=NUM CORES ha_priority=PRIORITY INT

Example:

vm.create testVM memory=2G num_vcpus=2

Bulk Create Virtual Machines

Description: Create bulk VMs

vm.create CLONEPREFIX[STARTING INT..END INT] memory=NUM MEM MB num_vcpus=NUM VCPU num_cores_per_vcpu=NUM CORES ha_priority=PRIORITY INT

Example:

vm.create testVM[000..999] memory=2G num_vcpus=2

Clone VM from Existing

Description: Create clone of existing VM

vm.clone CLONE NAME(S) clone_from_vm=SOURCE VM NAME

Example:

vm.clone testClone clone_from_vm=MYBASEVM

Bulk Clone VMs from Existing VM

Description: Create bulk clones of existing VM

vm.clone CLONEPREFIX[STARTING INT..END INT] clone_from_vm=SOURCE VM NAME

Example:

vm.clone testClone[001..999] clone_from_vm=MYBASEVM

Create Disk and Add to VM

Description: Create disk for OS

vm.disk_create VM NAME create_size=Size and qualifier, e.g. 500G container=CONTAINER NAME

Example:

vm.disk_create testVM create_size=500G container=default

Add NIC to VM

Description: Create and add NIC

vm.nic_create VM NAME network=NETWORK NAME model=MODEL

Example:

vm.nic_create testVM network=vlan.100

Set VM Boot Device to Disk

Description: Set a VM boot device

Set to boot from specific disk id

vm.update_boot_device VM NAME disk_addr=DISK BUS

Example:

vm.update_boot_device testVM disk_addr=scsi.0

Add CD-ROM to VM

vm.disk_create VM NAME cdrom="true" empty="true"

Example:

vm.disk_create testVM cdrom="true" empty="true"

Set VM Boot Device to CD-ROM

Set to boot from CD-ROM

vm.update_boot_device VM NAME disk_addr=CD-ROM BUS

Example:

vm.update_boot_device testVM disk_addr=ide.0

Mount ISO to CD-ROM

Description: Mount ISO to VM CD-ROM

Steps:

  1. Upload ISOs to container
  2. Enable whitelist for client IPs
  3. Upload ISOs to share

Create CD-ROM with ISO

vm.disk_create VM NAME clone_from_afsf_file=/CONTAINER/ISO CD-ROM=true

Example:

vm.disk_create testVM clone_from_adfs_file=/default/myfile.iso CD-ROM=true

Detach ISO from CD-ROM

Description: Remove ISO from CD-ROM

vm.disk_update VM NAME CD-ROM BUS empty=true

Power On VM(s)

Description: Power on VM(s)

vm.on VM NAME(S)

Example:

vm.on testVM

Power on all VMs.

Example:

vm.on *

Power on all VMs matching a prefix.

Example:

vm.on testVM*

Power on range of VMs.

Example:

vm.on testVM[0-9][0-9]

nCLI

The current nCLI command reference can be found on the Nutanix Portal.

The Nutanix Command Line Interface (nCLI) allows you to run system administration commands against the Nutanix cluster. In contrast to aCLI, nCLI can be installed on your local machine. See the Nutanix Portal link above for installation details.

Display Nutanix Version

Description: Displays the current version of the Nutanix software

ncli cluster version

This screenshot shows the output from ‘ncli version’ as both a single-line command and from within an ncli “session”.

ncli command usage options

Add Subnet to NFS whitelist

Description: Adds a particular subnet to the NFS whitelist

ncli cluster add-to-nfs-whitelist ip-subnet-masks=10.2.0.0/255.255.0.0

List Storage Pools

Description: Displays the existing storage pools

ncli sp ls

Note: This example shows the use of shortened commands. “storagepool” becomes “sp”, “list” becomes “ls”.

List Storage Containers

Description: Displays the existing containers

ncli ctr ls

Create Storage Container

Description: Creates a new container

ncli ctr create name=NAME sp-name=SP NAME

List VMs

Description: Displays the existing VMs

ncli vm ls

List Public Keys

Description: Displays the existing public keys

ncli cluster list-public-keys

Add Public Key

Description: Adds a public key for cluster access

SCP public key to CVM

Add public key to cluster

ncli cluster add-public-key name=myPK file-path=~/mykey.pub

Remove Public Key

Description: Removes a public key for cluster access

ncli cluster remove-public-keys name=myPK

Create Protection Domain

Description: Creates a protection domain

ncli pd create name=NAME

Create Remote Site

Description: Create a remote site for replication

ncli remote-site create name=NAME address-list=Remote Cluster IP

Create Protection Domain For All VMs In Storage Container

Description: Protect all VMs in the specified container

ncli pd protect name=PD NAME ctr-id=Container ID cg-name=NAME

Create Protection Domain With Specified VMs

Description: Protect the VMs specified

ncli pd protect name=PD NAME vm-names=VM Name(s) cg-name=NAME

Create Protection Domain for AOS files (aka vDisk)

Description: Protect the DSF Files specified

ncli pd protect name=PD NAME files=File Name(s) cg-name=NAME

Create Protection Domain Snapshot

Description: Create a one-time snapshot of the protection domain

ncli pd add-one-time-snapshot name=PD NAME retention-time=seconds

Create Snapshot and Replication Schedule to Remote Site

Description: Create a recurring snapshot schedule and replication to n remote sites

ncli pd set-schedule name=PD NAME interval=seconds retention-policy=POLICY remote-sites=REMOTE SITE NAME

List Replication Status

Description: Monitor replication status

ncli pd list-replication-status

Migrate Protection Domain to Remote Site

Description: Fail-over a protection domain to a remote site

ncli pd migrate name=PD NAME remote-site=REMOTE SITE NAME

Activate Protection Domain

Description: Activate a protection domain at a remote site

ncli pd activate name=PD NAME

Check Cluster Resiliency Status

# Node status 
ncli cluster get-domain-fault-tolerance-status type=node
# Block status
ncli cluster get-domain-fault-tolerance-status type=rackable_unit