NSX CLI Guide
Copyright © 2014-2022 VMware, Inc. All rights reserved. Copyright and trademark information.
NSX-T Data Center CLI Guide
NSX-T Data Center 4.0.0
Overview
The NSX-T Command-Line Interface Reference describes how to use the NSX-T Command-Line Interface (CLI) and includes examples and command overviews.
Intended Audience
The information in this guide is written for experienced systems and network administrators who are familiar with virtual machine technology and virtual datacenter operations.
VMware Technical Publications Glossary
VMware Technical Publications provides a glossary of terms that might be unfamiliar to you. For definitions of terms as they are used in VMware technical documentation go to http://www.vmware.com/support/pubs.
Document Feedback
VMware welcomes your suggestions for improving our documentation. If you have comments, send your feedback to [email protected].
Introduction to the NSX-T CLI
Each NSX-T virtual appliance contains a command-line interface (CLI). The command syntax and output format of NSX-T commands are not guaranteed to be the same from release to release. If you are automating tasks, please use the API. See the NSX-T API Guide for details.
Logging In and Out of the CLI
Before you can run CLI commands, you must connect to an NSX-T virtual appliance. You can connect to the console or through SSH.
If you did not enable SSH while installing the appliance, you can use the
set service ssh start-on-boot command to enable the SSH service.
To log out, type exit from Basic mode.
CLI Command Modes
The commands available to you at any given time depend on the mode you are currently in.
CLI Command Output Modifiers
You can apply output modifiers on some NSX CLI commands which provides modified command output per usage.
For example, get files | sort, sorts the output of the get files command.
Entering | ? after a command shows applicable output modifiers command supports.
If command does not support any output modifiers, an
% Output modifiers are not supported for this command error message is displayed upon execution.
List of available modifiers:
count: Count number of specified entities
find: Only show lines that contain regex pattern
first: Show first N lines of output
ignore: Ignore lines that contain regex pattern
json: Show output in JSON format
last: Show last N lines of output
more: Show output one page at a time
sort: Sort command output
NOTE: Command Output modifier more is not supported in Windows Physical Server.
Central CLI
Central CLI provides ability to issue command execution from any NSX Manager in cluster on a remote NSX node under same management cluster or fabric node.
For example,
nsxmanager> on ?
| uuid | node-type | hostname |
| 15df7116-7f5d-11eb-a9e3-020057648652 | edg | nsx-edge-1.hostname |
| 4502cf74-7f5d-11eb-af38-0200576945d9 | esx | esx1.hostname |
Central CLI commands can only be issued on NSX manager nodes,
which always starts with on followed by multiple (one or more) remote node uuids.
For example,
nsxmanager> on 15df7116-7f5d-11eb-a9e3-020057648652 4502cf74-7f5d-11eb-af38-0200576945d9 exec get node-uuid
---------------------------------------------------------------------------------------
15df7116-7f5d-11eb-a9e3-020057648652
edg
nsx-edge1.hostname
---------------------------------------------------------------------------------------
uuid: 15df7116-7f5d-11eb-a9e3-020057648652
---------------------------------------------------------------------------------------
4502cf74-7f5d-11eb-af38-0200576945d9
esx
esx1.hostname
---------------------------------------------------------------------------------------
uuid: 4502cf74-7f5d-11eb-af38-0200576945d9
Above command get node-uuid is executed on two remote nodes
(15df7116-7f5d-11eb-a9e3-020057648652 & 4502cf74-7f5d-11eb-af38-0200576945d9) in the order specified.
Session Mode
You can connect to remote session on NSX Manager to any NSX node under same management cluster or fabric node. It launches remote CLI session for a specified node; where available commands on the respective node can be executed.
For example,
nsxmanager1> on 4502cf74-7f5d-11eb-af38-0200576945d9 exec
Entering session mode
SESSION-MODE> get version
----------------------------------------------------------------------------------------
4502cf74-7f5d-11eb-af38-0200576945d9
esx
esx1.hostname
----------------------------------------------------------------------------------------
VMware NSX Software, Version 3.2.0.0.0.44911683
Technical Support: http://www.vmware.com/support.html
.....
or more patents listed at http://www.vmware.com/go/patents.
To exit from session mode issue an exit command under current session context.
CLI Exit Codes
Following are different types of Exit Codes NSX CLI session can return on command execution:
| Return Value | Type | Details |
0 |
CMD_EXECUTED |
Command Executed successfully |
1 |
CMD_UNEXPECTED_ERROR |
Command executed with unexpected error |
2 |
CMD_NOT_EXECUTED |
Unable to execute command |
3 |
CMD_EXECUTED_REQUESTED_EXIT |
Exit command executed successfully |
4 |
CMD_EXECUTED_WITH_ERROR_RESULT |
Command executed with error output |
10 |
CMD_SESSION_TIMEOUT |
CLI Session timed-out |
11 |
CMD_UNEXPECTED_EXCEPTION |
Command executed with unexpected exception |
12 |
CMD_UNSUPPORTED_MODE |
CLI request unsupported |
99 |
CLI_START_ERROR |
Unable to launch CLI |
CLI Command Markers
As per the behaviour or functionality of command it might be marked with one or more icons as represent in legend below:
| Icon | Flag | Details |
| |
Central Cli Unsupported | Specifies whether the given NSX-CLI command is available for remote execution in Management cluster |
| |
Output Modifiers Unsupported | Specifies whether usage of Command Output Modifiers is not supported on particular NSX-CLI command |
| |
Windows Physical Server Unsupported | Specifies that given command or feature is not supported on Windows Physical Server |
| |
Cluster based | Specifies that given functionality of command will impact the settings or configuration applicable for all the nodes under same Management cluster |
Important Note
Starting with NSX-T 2.1, the NSX Manager GUI uses the term N-VDS (NSX managed virtual distributed switch) to refer to what was known as host switch in previous releases. In this document, the term host switch is still used. The two terms are synonyms.