As Nutanix is constantly striving to be an API driven company and exposing more of its core functionality via API’s as well as improving integration with tools such as Ansible and Terraform, we hope you have been making the most of it.
Â
For example, did you know how to check the status of NGT and the NGT communication link using API’s?
Â
It is easily obtainable using the v3 REST API exposed from your Prism Central.
Â
Issue a GET request toÂ
https://<PC_IP_address>:9440/api/nutanix/v3/vms/<vm_uuid>
Â
Filter through the response to find a block similar to this.Â
Â
      "guest_tools": {
        "nutanix_guest_tools": {
          "available_version": "1.90.1",
          "ngt_state": "INSTALLED",
          "iso_mount_state": "MOUNTED",
          "state": "ENABLED",
          "version": "1.1.2",
          "enabled_capability_list":
            "VSS_SNAPSHOT"
          ],
          "guest_os_version": "windows:64:WindowsServer2008R2Enterprise",
          "is_reachable": false
        }
      }
     Â
Â
Let’s say after that, you wanted to change the IP address of the VM.
Â
Issue a PUT request to
Â
https://<PC_IP_address>:9440/api/nutanix/v3/vms/<vm_uuid>/update_ip
Â
And send this in the request body (plug in the required IP address and NIC UUID)
Â
{
  "update_list": o
    {
      "ip": "string",
      "uuid": "string"
    }
  ]
}
Â
Now how about if you wanted to send both of the above calls (and more) in one single API call? That is possible by leveraging the batch API.
Â
Issue a POST request to
Â
https://<PC_IP_address>:9440/api/nutanix/v3/batch
Â
And send this in the request body.
Â
{
  "execution_order": "SEQUENTIAL",
  "action_on_failure": "CONTINUE",
  "api_request_list": t
    {
      "operation": "GET",
      "path_and_params": "/api/nutanix/v3/vms/<vm_uuid>"
      "body": {}   Â
    },
    {
      "operation": "PUT",
      "path_and_params": "/api/nutanix/v3/vms/<vm_uuid>/update_ip"
      "body": {
       "update_list": r
         {
           "ip": "string",
           "uuid": "string"
         }
       ]
      }  Â
    }
  ],
  "api_version": "3.1.0"
}
Â
For more examples, please feel free to take a look at our code samples hosted at nutanix.dev.
Â
Let us know your API success stories!
Â