Skip to content

Basic Intersight Queries

Basic queries

To retrieve resources from Intersight, use the isctl get ... commands.

For example, to query all objects of a certain type:

isctl get ntp policy
Output:
------------  -----------------------------  ------------------------  -----------------------------
    Enabled                           Moid                      Name                     NtpServers
------------  -----------------------------  ------------------------  -----------------------------
      False       5ecb069c6275722d3143e668           test-ntp-policy

       True       5ee1aa076275722d3122a944          cg-tf-ntp-test-1       10.10.10.10, 10.10.10.12
------------  -----------------------------  ------------------------  -----------------------------
Notice that all objects are returned in a human-readable table.

You can query a single object based on its MoId:

isctl get ntp policy moid 5ee1aa076275722d3122a944

Or its name:

isctl get ntp policy --name cg-tf-ntp-test-1

Output:

2020/06/25 17:40:04 Single result, falling back to vertical output. NOTE: this is not valid YAML; use --output yaml to get valid YAML.
Enabled: true
Moid: 5ee1aa076275722d3122a944
Name: cg-tf-ntp-test-1
NtpServers:
- 10.10.10.10
- 10.10.10.12
Notice that when displaying a single object, table format is not used.

Filtering results

The Intersight API can filter results before returning them to the client. To specify the filter query, use --filter <filter_expression>. See the Intersight API Guide for details on the <filter_expression> syntax. Some examples are below.

Filter on exact name:

isctl get ntp policy --filter "Name eq 'cg-tf-ntp-test'"

Filter objects where name starts with "cg-":

isctl get ntp policy --filter "startsWith(Name, 'cg-')"

Output customisation

By default, isctl will try to produce human readable output. Typically, this will be a table format with boilerplate attributes (e.g. ClassId, Organization, etc.) hidden for brevity. If the output table would have too many columns, isctl will fall back to a "vertical" output (essentially YAML). If you want to disable this behavior and force the table format (even though it will be very wide), use --output table.

There are a number of other options to customise the output described below.

JSON/YAML

Using --output json or --output yaml will cause the output to use the chosen format and will disable the hiding of any "boilerplate" attributes:

isctl get ntp policy moid 5ee1aa076275722d3122a944 --output json
Output:
{
  "AccountMoid": "123456789012345678901234",
  "Ancestors": [],
  "ClassId": "ntp.Policy",
  "CreateTime": "2020-06-11T03:50:32.062Z",
  "Description": "",
  "DomainGroupMoid": "123456789012345678901234",
  "Enabled": true,
  "ModTime": "2020-06-11T03:50:32.063Z",
  "Moid": "5ee1aa076275722d3122a944",
  "Name": "cg-tf-ntp-test-1",
  "NtpServers": [
    "10.10.10.10",
    "10.10.10.12"
  ],
  "ObjectType": "ntp.Policy",
  "Organization": {
    "ClassId": "mo.MoRef",
    "Moid": "123456789012345678901234",
    "ObjectType": "organization.Organization",
    "link": "https://www.intersight.com/api/v1/organization/Organizations/123456789012345678901234"
  },
  "Owners": [
    "123456789012345678901234"
  ],
  "PermissionResources": [
    {
      "ClassId": "mo.MoRef",
      "Moid": "123456789012345678901234",
      "ObjectType": "organization.Organization",
      "link": "https://www.intersight.com/api/v1/organization/Organizations/123456789012345678901234"
    }
  ],
  "Profiles": [],
  "SharedScope": "",
  "Tags": []
}

This can be useful to feed the structured output to another tool, for example jq:

isctl get ntp policy -o json | jq -r '.[].Name'
Output:
NTP_ESL
CiscoNTP
BA-NTP

JSONPath

You can use JSONPath to filter/transform the returned data. For example, to output just the name attribute of all the returned objects:

isctl get ntp policy -o jsonpath='[*].Name'
Output:
test-ntp-policy
cg-tf-ntp-test-1

Or even to get multiple attributes from the returned objects:

isctl get ntp policy moid 5ee1aa076275722d3122a944 -o jsonpath='$["Name","Enabled"]'
Output:
cg-tf-ntp-test-1
True

Cusom Columns

To customise the table output, "custom-columns" output can be used. The syntax is --output custom-columns=<spec> where <spec> is a comma separated list of <column_title>:<value_path> column specifications. The <value_path> is a simplified JSONPath expression that specifies how to extract the column value from a returned item. For example:

isctl get ntp policy --output custom-columns=NAME:.Name,ENABLED:.Enabled
Output:
-------------  ------------
        NAME       ENABLED
-------------  ------------
     NTP_ESL          True
    CiscoNTP          True
      BA-NTP          True
-------------  ------------

CSV

The output can be formatted as a CSV for easy importing into spreadsheets or other applications. The syntax for CSV output is similar to custom-columns above - --output csv=<spec>. For example:

isctl get ntp policy --output csv=NAME:.Name,ENABLED:.Enabled
Output:
"NAME","ENABLED"
"NTP_ESL","True"
"CiscoNTP","True"
"BA-NTP","True"

A common way to use this with the default spreadsheet application is:

isctl get ntp policy --output csv=NAME:.Name,ENABLED:.Enabled  > /tmp/ntp.csv && open /tmp/ntp.csv

XLSX

The output can be saved as a .xlsx file for easy opening in spreadsheet applications. For example, this command will save the table of NTP policies in out.xlsx:

isctl get ntp policy -o xlsx=out.xlsx

Go Template

The go-template output format allows you to use Go's text/template syntax for flexible output formatting, similar to kubectl. This output format also includes sprig template functions for additional utility.

Basic usage - access a single field:

isctl get ntp policy --name "test-policy" -o go-template='{{.Name}}'
Output:
test-policy

Multiple fields:

isctl get ntp policy --name "test-policy" -o go-template='Name: {{.Name}}, Enabled: {{.Enabled}}'
Output:
Name: test-policy, Enabled: true

Iterate over a list:

isctl get ntp policy -o go-template='{{range .}}{{.Name}}
{{end}}'
Output:
test-ntp-policy
cg-tf-ntp-test-1

Conditional output:

isctl get ntp policy --name "test-policy" -o go-template='{{if .Enabled}}Policy is enabled{{else}}Policy is disabled{{end}}'

Using sprig functions (e.g., upper, lower, trim, join):

isctl get ntp policy --name "test-policy" -o go-template='{{.Name | upper}}'
Output:
TEST-POLICY

YAML Editable

The yaml-editable output format shows only writable properties, filtering out read-only system fields like Moid, ClassId, ObjectType, CreateTime, etc. This is useful for exporting a resource in a format suitable for modification and re-import.

isctl get ntp policy --name "test-policy" -o yaml-editable
Output:
AuthenticatedNtpServers: []
ClassId: ntp.Policy
Description: ""
Enabled: true
Moid: 5ee1aa076275722d3122a944
Name: test-policy
NtpServers:
- 10.10.10.10
- 10.10.10.12
ObjectType: ntp.Policy
Organization: MoRef:organization.Organization[Moid:59c84e4a16267c0001c23428]
Profiles: []
Tags: []
Timezone: Pacific/Niue

Compare this to -o yaml which includes all properties, including read-only ones.

Readable MoRefs

By default, MoRef values in output use opaque Moid hex strings (e.g., MoRef:organization.Organization[Moid:59c84e4a16267c0001c23428]). The --readable-morefs flag replaces these with human-readable identity-based values determined by the class's identity constraints in the Intersight schema:

isctl get ntp policy --name "test-policy" --readable-morefs -o yaml-editable
Output:
AuthenticatedNtpServers: []
ClassId: ntp.Policy
Description: ""
Enabled: true
Moid: 5ee1aa076275722d3122a944
Name: test-policy
NtpServers:
- 10.10.10.10
- 10.10.10.12
ObjectType: ntp.Policy
Organization: MoRef:organization.Organization[Name:default]
Profiles: []
Tags: []
Timezone: Pacific/Niue

The identity fields used depend on the class — for example, organization.Organization uses Name, while fabric.Vlan uses VlanId and EthNetworkPolicy. Classes with no identity constraints fall back to the Moid format.

For classes with multi-field identity, the MoRef includes all identity fields:

EthNetworkPolicy: MoRef:fabric.Vlan[VlanId:100,EthNetworkPolicy:MoRef:fabric.EthNetworkPolicy[Name:my-policy]]

The --readable-morefs flag applies to all output formats (default/table and yaml-editable). The resulting yaml-editable output is round-trippable — it can be passed back to isctl apply without modification.

This option can also be set persistently in the config file:

readable_morefs: true