To enable NX-API CLI, enter the following command:

feature nxapi

The following diagram shows an NX-API call, demonstrating a show clock request.

Request and Response Sequence of NX-OS CLI

Request and Response Sequence of NX-OS CLI

NX-API CLI Developer Sandbox

Cisco has developed a tool to help customers become familiar with the NX-API CLI by creating the NX-API CLI Developer Sandbox. This is a web interface that allows users to make NX-API interface calls, and it can transcode traditional Nexus CLI commands into JSON or XML format.

The NX-API CLI Developer Sandbox is divided into three components:

Post Pane:

This Pane is composed into three major categories:

  • Text Area: This is where the user can enter show, configuration, or bash commands.

  • Message format: XML, or JSON

  • Command Type:

    • cli_show represents the CLI show commands (such as show version or show clock)
    • cli_show_asci represents the CLI show command that expects ASCII output. This aligns with existing scripts that parse ASCII output. Users are able to use existing scripts with minimal changes.
    • cli_conf represents the CLI for the configuration commands
    • bash represents the Bash command
  • Post

Request Pane:

  • Provides a brief description of the request elements that are displayed
  • Includes a Python code output option

Response Pane:

  • The POST response will be displayed in this pane

In order to access the NX-API CLI Developer Sandbox, point your browser to the IP or hostname of a Nexus switch.

https://<<switch ip>>

The authentication page will prompt for a username and password. Once authenticated, the sandbox interface will be displayed:

NX-API CLI Developer Sandbox Web Interface

NX-API CLI Developer Sandbox Web Interface

Screenshot of the "show clock" Example Workflow

Screenshot of the show clock Example Workflow

The user can also leverage the Python function in NX-API CLI Developer Sandbox in order to generate Python code.

Automatic Python Code Generation with NX-API CLI

Automatic Python Code Generation with NX-API CLI

Python code generated by the NX-API CLI Developer Sandbox can be copied into an editor for execution using the Python interpreter.