Examples

Viewing the Role of Switches

The roles API enables you to view the roles of switches. You can input one or more serial numbers of switches with the GET request to view the role of all (or) specific switches.

  1. Log in to your Cisco DCNM Web GUI and go to https://DCNM-IP/api-docs.
  2. Navigate to Control – Switches.
  3. Click GET > /control/switches/roles.
  4. In the serialNumber field, enter the serial number of the switch. If you want to specify the serial numbers for more than one switch, enter comma-separated serial numbers. Note:If you want to list the roles of all the switches, then leave the serialNumber field empty.
  5. Click Try it out!.

This example reads information about the role of switches in JSON format:

Curl

curl -X GET --header 'Accept: application/json'
'https://10.197.67.35/rest/control/switches/roles?serialNumber=SAL1925HFLT'

Request URL

https://<dcnm-ip>/rest/control/switches/roles?serialNumber=SAL1925HFLT

Response Body

[
{
"serialNumber": "SAL1925HFLT",
"role": "leaf"
}
]

Note: If you enter serialNumber in lower case, then REST API used to set the role of the switch would fail and therefore ensure that the serialNumber is entered in uppercase.

Assigning Roles to Switches

You need to send a POST request with the serial number and switch role to set role to switches.

  1. Log in to your Cisco DCNM Web GUI and go to https://DCNM-IP/api-docs.
  2. Navigate to Control – Switches.
  3. Click POST > /control/switches/roles.
  4. In the body field, enter the serial number of the switch and the role that you want to set.
  5. Click Try it out!.

You can assign the following roles to switches:

  • Spine
  • Leaf
  • Border
  • Border Spine
  • Border Gateway
  • Border Gateway Spine

This example shows how to set role for a switch in JSON format:

[
{
"serialNumber": " SAL1925HFLT",
"role": "leaf"
}
]

Note: If you enter the switch role in upper case, then REST API used to set the role of the switch would fail and therefore ensure that the role parameter is entered in lower case.

Accepting Invalid Format in Body and not giving error/exceptions

For some invalid formats provided to set the role of the switch REST API works. For example, the below value detects invalid format but it executes it for the first switch and gives the response 200. The response body also shows the response success for first switch.

[
{
"serialNumber": "FDO22411PGV",
"role": "leaf"
}
],
[
{
"serialNumber": "FDO224226YX",
"role": "leaf"
}
]