This guide will show you all the administration tools, other than the Prism Central and Prim Element web interfaces, which are:
ncli which can be accessed locally, via SSH on Prism Central and Prism Element.
acli which can be used via SSH on CVMs.
Cmdlets for Powershell.
The REST API from the Prism Central or Prism Element URL.
Warning
OVHcloud provides services for which you are responsible, with regard to their configuration and management. It is therefore your responsibility to ensure that they work properly.
This guide is designed to assist you as much as possible with common tasks. Nevertheless, we recommend contacting a specialist provider if you experience any difficulties or doubts when it comes to managing, using or setting up a service on a server.
Requirements
a Nutanix cluster in your OVHcloud account
access to the
For the REST API, you must have a virtual machine running Linux with a text editor to run the curl and jq commands.
Info
Some commands can only be used if you have SSH access to Prism Central and Prism Element.
Tools overview
ncli command
ncli is located on Prism Central and all CVMs through an SSH connection. You can also install it locally on a Windows or Linux desktop from the Prism Central web interface.
ncli allows you to manage aspects of the Nutanix cluster such as storage, tasks and some actions on virtual machines within the cluster.
acli tool
The acli command is only available on CVMs. It is used for managing VMs, network and snapshot hosts.
Powershell extensions
Powershell is a scripting language developed by Microsoft and based on Net.Framework.
It works in Microsoft, Linux and MacOS environments but is mainly used in a Microsoft environment.
All of the examples below have been run only on this environment.
Nutanix has added extensions that allow cluster and VM administration using Powershell scripts.
API REST administration interface
Through the URL of Prism Central or Prism Element, you can use an API named REST API either in the command line with the curl tool, or through another programming language such as python or php or even with the standard commands of Powershell.
For more information on these commands, see the Go further section of this guide.
Instructions
Examples of ncli use
Connect via SSH with an SSH client on one of the CVMs:
ssh nutanix@oneofcvm
The ncli command is used followed by options, as in this example ``ncli entity action option1=value option2=`value2but it also can be used interactively by running onlyncli```.
Creating a Storage Container named newcontainer in interactive mode
ncli<ncli><ncli> ctr create name="NewContainer" sp-name="default-storage-pool-10728992352041" Id : 0005ce15-3f3c-a8ce-3802-043f72bf18a6::2900908 Uuid : c3db4020-2a98-4636-b9eb-8ebf10a1b351 Name : Moncontainer Storage Pool Id : 0005ce15-3f3c-a8ce-3802-043f72bf18a6::9 Storage Pool Uuid : 111d4e91-10df-4f6c-a774-b79b53077131 Free Space (Logical) : 37.69 TiB (41,445,056,716,652 bytes) Used Space (Logical) : 0 bytes Allowed Max Capacity : 37.69 TiB (41,445,056,716,652 bytes) Used by other Containers : 260.86 GiB (280,096,141,312 bytes) Explicit Reservation : 0 bytes Thick Provisioned : 0 bytes Replication Factor : 2 Oplog Replication Factor : 2 NFS Whitelist Inherited : true Container NFS Whitelist : 192.168.0.77/255.255.255.255 VStore Name(s) : Moncontainer Random I/O Pri Order : SSD-PCIe, SSD-SATA, DAS-SATA Sequential I/O Pri Order : SSD-PCIe, SSD-SATA, DAS-SATA Compression : off Fingerprint On Write : off On-Disk Dedup : off Erasure Code : off Software Encryption : off<ncli>
Deleting the Storage Container
Run the following command to delete the Storage Container without confirmation:
ncli ctr remove name="Newcontainer"
Examples of using the acli command
Connect via SSH with an SSH client on one of the CVMs:
ssh nutanix@oneofcvmipaddress
The acli command is used followed by options, such as acli entities.action for-which option1="value1" option2="value2", but it also can be used interactively by running only acli from a CVM
If acli is used followed by a sequence of orders, a confirmation request will always be offered if a choice is made.
To automate the task and make a default choice, use this syntax instead acli -y entities.action for-which option1="value" option2="value2"
Download and install the installer that corresponds to your version of Windows, in 32 bits or more generally in 64 bits.
Launch the Powershell 7 command prompt in administrator mode.
PS C:\Users\Administrator> Install-Module Nutanix.CliUntrusted repositoryYou are installing the modules from an untrusted repository. If you trust this repository, change itsInstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from'PSGallery'?[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):APS C:\Users\Administrator> Install-module Nutanix.Prism.PS.CmdsPS C:\Users\Administrator> Install-module Nutanix.Prism.Common
Command examples with Powershell for Nutanix
Import modules for Powershell from the PowerShell 7 console:
Log in to Prism Central by executing the command below and edit these items:
< PRISM CENTRAL IP > replace this item with the IP address or FQDN of Prism Central
< PRISM CENTRAL USERNAME > replace this item with the Prism Central user name
PS C:\Users\Administrator> Connect-NTNXPrismCentral <PRISM CENTRAL IP> -UserName < PRISM CENTRAL USERNAME > -AcceptInvalidSSLCertsPassword: *****************[Warning]: This Prism Central version[pc.2022.1] might not be compatible.This might cause some cmdlets to not function correctly.Please consider upgrading to pc.2020.7 or later Do you still want to continue [Y/N]?:YServer : ipprismcentralVersion : pc.2022.1UserName : < PRISM CENTRAL IP >AcceptInvalidSSLCerts : TrueForcedConnection : False
Run the command below to see a list of all virtual machines:
All of the examples shown below must be run on a virtual machine running Linux with the curl tool.
Some commands need other tools that are available in most Linux distributions.
Display all API options from Central Prism
You can get the list of REST API options from Prism Central.
In the top right-hand corner of the Prism Central interface, click Username, then REST API Explorer.
The list of command groups is displayed on the left.
Click List operations to the right of one of the command groups to display all possible commands in that group.
Click Expand operations to list the syntax for a particular command.
Various simple examples
Connect via SSH to a Linux VM in the cluster that has the curl and jq commands installed.
For these examples to work, replace:
< PRISMCENTRAL IP > by the IP address or FQDN of Prism Central.
< PRISM CENTRAL USER > by the Prism Central user.
< PRISM CENTRAL PASSWORD > by the Prism Central user password.
View the list of ISO and QCOW2 images installed on Prism Central
curl -k -X POST --header "Content-Type: application/json" --header "Accept: application/json" -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" -d {} "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/images/list" | jq
This command generated a file in a readable json format using the jq command, which contains the list of images and the information needed for other REST API commands.
Run this command to display the list of virtual machines:
curl -k -X POST --header "Content-Type: application/json" --header "Accept: application/json" -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" -d {} "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/vms/list" | jq
The result is always in json format.
Below is a part of the generated file, containing the virtual machine UUID.
There is a UUID for each element of the Nutanix clusters (VM, Vdisks, images, etc..). This number is unique.
"kind:" "vm" corresponds to the type of the object.
Run the following command by replacing < VM UID > with the UUID of a previously listed virtual machine:
curl -k -X GET --header "Accept: application/json" - u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/vms/< VM UUID >" | jq
Viewing the Network List
Run this command to display the list of networks in Nutanix:
curl -k -X POST --header "Content-Type: application/json" --header "Accept: application/json" -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" -d {} "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/subnets/list" | jq
Viewing Information about Administered Clusters in the Prism Central Console
Run the following command to display information about the clusters administered by Prism Central:
curl -k --request POST --url "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/clusters/list" -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" --header 'Content-Type: application/json' --data '{ }' | jq
Advanced examples
In addition to displaying information, you can act on the Nutanix cluster to create or modify elements of a cluster.
We will see how to create two virtual machines in an automated way, one in a Linux environment, the other on Windows.
Creating a virtual machine on Linux
You can install Linux from pre-installed images, and you can customise the configuration with cloud-init, which uses the yaml file format. To import images into a Nutanix cluster, you can refer to our guide on importing ISO images.
Follow these instructions to create a virtual machine from a Ubuntu cloud-init customisable image.
On Linux, create a password in SHA-512 format with the command mkpasswd:
curl -k -H Accept:application/json -H Content-Type:application/json -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" -X POST "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/vms" -d @vmlinux.json | jq .
The new virtual machine will then appear in Prism Central with NGINX installed and updates performed.
Creating a virtual machine on Windows
You can install virtual machines on Windows from a prepared image using the Windows-integrated sysprep command and apply a customisation file to it.
The image can be imported directly from a virtual machine in the cluster.
The configuration file is an XML file. You can create this file using the Windows ADK tools that you can download from the Microsoft site via this link and use Windows system image manager to create a suitable XML file.
Below is an example XML file for Windows 2019 that creates an admin user and changes the password for the admin and Administrator account to P@ssw0rd:
Copy the XML file to a Linux VM in the cluster and transform it into MIME64 format, as below, to integrate it into the VM configuration file in json format:
curl -k -H Accept:application/json -H Content-Type:application/json -u "< PRISM CENTRAL USER >:< PRISM CENTRAL PASSWORD >" -X POST "https://< PRISM CENTRAL IP >:9440/api/nutanix/v3/vms" -d @vmwindows.json | jq .
The new virtual machine will appear in Prism Central, it is then started with the response file options.
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for assisting you on your specific use case of your project.