v3 API primer | Nutanix Community
Skip to main content

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!

 

I tried to Update my VM ip with the above solution for 2 VM but I am getting 404 not found error, Can someone help me with this.

URL:

https://<PRISM-URL>:9440/api/nutanix/v3/vms/14c93d96-cf50-4f59-ad1f-455fdc4fe***/update_ip

Error:

404 not found

Body:

{

  "update_list": "

    {

      "ip": "192.168.199.***",

      "uuid": "e2733d02-5143-473e-8234-0ea05d306***"

    }

  ]

}


I tried to Update my VM ip with the above solution for 2 VM but I am getting 404 not found error, Can someone help me with this.

URL:

https://<PRISM-URL>:9440/api/nutanix/v3/vms/14c93d96-cf50-4f59-ad1f-455fdc4fe***/update_ip

Error:

404 not found

Body:

{

  "update_list": "

    {

      "ip": "192.168.199.***",

      "uuid": "e2733d02-5143-473e-8234-0ea05d306***"

    }

  ]

}

 

Hi -

 

Please ensure you are using the Prism Central IP address, not the Prism Element IP address.  Due to this request making use of the v3 Prism APIs, it should only be submitted to Prism Central.

 

I have tested this just now and confirmed the info provided above does work.  :)


 

Got it, My network was not managed that’s why it wasn’t working.

One question here, are we only allow to set Dynamic IPs while creating VMs. Can’t we set static IP as well? Plz suggest.

Thanks Chris,