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:
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
------------ ----------------------------- ------------------------ -----------------------------
You can query a single object based on its MoId:
Or its name:
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
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:
Filter objects where name starts with "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:
{
"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:
JSONPath
You can use JSONPath to filter/transform the returned data. For example, to output just the name attribute of all the returned objects:
Output:Or even to get multiple attributes from the returned objects:
Output: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:
------------- ------------
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:
A common way to use this with the default spreadsheet application is:
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:
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:
Output:Multiple fields:
Output:Iterate over a list:
Output: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):
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.
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:
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: