VIP to CNode mapping via REST API

Prev Next

Introduction

In many scenarios, it is useful to know:

  • The list of VIPs on a particular CNode

  • Which CNode is a particular VIP currently on?

To do this, we'll use the REST API.  If you have not already, please review the VAST REST API Overview first.   Additionally, once you have read and experimented with the examples in this article, you can easily convert them to another programming language, such as Python, as shown in the Using Python with the REST API article.

Special note: many of the API calls below contain double underscores ( __ ).  Please make sure that your text editor does not squash them to a single underscore, as the calls will not work.

List all VIPs

curl -u admin:<password> --insecure -X GET "https://$VMSIP/api/vips/" -H "accept: application/json" 

Find all VIPs on  'cnode-202'

The nomenclature here may be a little confusing at first.  Cnode-202 is actually 'the cnode which has an Internal-IP with the last-octet 202'.

  

curl -u admin:<password> --insecure -X GET "https://$VMSIP/api/vips/?cnode__name=cnode-202" -H "accept: application/json" |python -m json.tool

That will result in a response like this:

  [
 {
 "cluster": "se-demo",
 "cnode": "cnode-202",
 "guid": "8dc3ac0d-da03-5214-8425-cc31ed36339f",
 "id": 15,
 "ip": "10.101.127.44",
 "name": null,
 "title": "10.101.127.44",
 "url": "https://10.100.127.201/api/vips/15/",
 "vippool": "vippool-1"
 },
 {
 "cluster": "se-demo",
 "cnode": "cnode-202",
 "guid": "1d53456f-0d23-514e-b585-54e5ee1c4346",
 "id": 16,
 "ip": "10.101.127.46",
 "name": null,
 "title": "10.101.127.46",
 "url": "https://10.100.127.201/api/vips/16/",
 "vippool": "vippool-1"
 },

....

Find all VIPs on CNode-3:

In this case, we will fetch just the VIPS on the CNode with id 3.

curl -u admin:<password> --insecure -X GET "https://$VMSIP/api/vips/?cnode__id=3" -H "accept: application/json" |python -m json.tool

That will result in a response like this:

  {
 "cluster": "se-demo",
 "cnode": "cnode-203",
 "guid": "93718fbe-4156-533e-93ef-99439f564caa",
 "id": 1,
 "ip": "10.101.127.29",
 "name": null,
 "title": "10.101.127.29",
 "url": "https://10.100.127.201/api/vips/1/",
 "vippool": "vippool-1"
 },
 {
 "cluster": "se-demo",
 "cnode": "cnode-203",
 "guid": "4cbddc98-98bd-5a51-94cd-0c63a79f7c97",
 "id": 2,
 "ip": "10.101.127.11",
 "name": null,
 "title": "10.101.127.11",
 "url": "https://10.100.127.201/api/vips/2/",
 "vippool": "vippool-1"
 },
....
 

Find which CNode owns a particular VIP

Note that the example below puts in a specific IP.  You can actually put in a 'portion' of the IP address to match more entries.

curl -u admin:<password> --insecure -X GET "https://$VMSIP/api/vips/?ip__contains=10.101.127.46" -H "accept: application/json" |python -m json.tool

Result:

[
 {
 "cluster": "se-demo",
 "cnode": "cnode-202",
 "guid": "1d53456f-0d23-514e-b585-54e5ee1c4346",
 "id": 16,
 "ip": "10.101.127.46",
 "name": null,
 "title": "10.101.127.46",
 "url": "https://10.100.127.201/api/vips/16/",
 "vippool": "vippool-1"
 }
]