On Cisco Nexus devices, command-line interfaces (CLIs) are run only on the device. NX-API improves the accessibility of these CLIs by making them available outside of the switch by using HTTP/HTTPS. You can use this extension to the existing Cisco Nexus CLI system on the Cisco Nexus 5000 and 6000 Series devices.
Page 3
Using NX-API The commands, command type, and output type for the Cisco Nexus 5000 and 6000 Series devices are entered using NX-API by encoding the CLIs into the body of a HTTP/HTTPs POST. The response to the request is returned in XML or JSON output format.
Page 4
The NX-API Sandbox is the web-based user interface that you use to enter the commands, command type, and output type for the Cisco Nexus 5000 and 6000 Series device using HTTP/HTTPS. After posting the request, the output response is displayed.
Page 5
• Enable the management interface. switch# conf t switch(config)# interface mgmt 0 switch(config)# ip address 198.51.100.1/24 switch(config)# vrf context managment switch(config)# ip route 203.0.113.1/0 1.2.3.1 • Enable the NX-API nxapi feature. switch# conf t switch(config)# feature nxapi switch(config)# nxapi sandbox •...
Page 6
The following sections describe the commands to manage NX-API and descriptions of the elements of the request and the output response. NX-API Management Commands You can enable and manage NX-API with the CLI commands listed in the following table. Table 1: NX-API Management Commands NX-API Management Command Description feature nxapi...
Page 7
NX-API Request Element Description type Specifies the type of command to be executed. The following types of commands are supported: • cli_show CLI show commands that expect structured output. If the command does not support XML output, an error message is returned. •...
Page 8
Specifies output in JSON format. Note The Cisco Nexus 5000 and 6000 Series CLI supports XML output, which means that the JSON output is converted from XML. The conversion is processed on the switch. To manage the computational overhead, the JSON output is determined by the amount of output.
NX-API Response Element Description Session ID of the response. This element is valid only when the response message is chunked. outputs Tag that encloses all command outputs. When multiple commands are in cli_show or cli_show_ascii, each command output is enclosed by a single output tag. When the message type is cli_conf or bash, there is a single output tag for all the commands because cli_conf and bash commands require context.
Page 10
• cli_show_ascii—This command type returns output in ASCII format with the entire output inside one <body> element. Any command on the switch (including the ones that do not support structured XML output) should work with this command type, although it will be more difficult to parse compared to those commands that return XML. •...
Page 11
This product includes software written by Tim Hudson (tjh@cryptsoft.com). http:// Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: www.cisco.com/go/trademarks .
Page 12
Cisco Systems, Inc. Cisco Systems (USA) Pte. Ltd. Cisco Systems International BV San Jose, CA 95134-1706 Singapore Amsterdam, The Netherlands Cisco has more than 200 offices worldwide. Addresses, phone numbers, and fax numbers are listed on the Cisco Website at www.cisco.com/go/offices.