Filtering DCLI Command Output

You can filter command output to trim unnecessary information or use custom formatting.

DCLI supports output filtering by using JMESPath expressions. JMESPath is a standard query language for JSON. For more information about JMESPath, see http://jmespath.org/.

In the following example, you retrieve the NSX-T URL from an SDDC and connect to the NSX-T server in interactive mode.

dcli +vmc com vmware vmc orgs sddcs get --org <orgId> --sddc <sddcId> +filter resource_config.nsx_api_public_endpoint
<sddc_nsx_endpoint_url>
dcli +nsx <sddc_nsx_endpoint_url> +skip +i

After establishing a connection, you can print out the names and IDs of all VMware Cloud on AWS SDDCs in an organization as a table. You can give custom names to the output columns.

dcli +vmc com vmware vmc orgs sddcs list --org <orgId> +filter '[].{"Organization ID": id, "Organization Name": name}' +formatter table
|----------------|-----------------|
|Orgаnization ID |Organization Name|
|----------------|-----------------|
|<orgId>         |<orgName>        |
|----------------|-----------------|

You can modify JMESPath expressions by using the jpterm program. To use jpterm, you must install the JMESPath Terminal by running the following command.

pip install jmespath-terminal

The jpterm program requires command output in JSON format. The following example converts the output to JSON format before sending it to jpterm.

dcli +vmc com vmware vmc orgs list +formatter json | jpterm