#Q: CLI (REST) Interface: Command output?

1 messages · Page 1 of 1 (latest)

neat atlas
#

I think I must be missing something here. I've written a simple playbook just to call the version command, as in the documentation "na_ontap_rest_cli_module.html". But when I run it I don't see the typical CLI output. If I try to grab the response in the "info" variable. I get this:
TASK [Run ONTAP CLI command] ****************************************************************************************************
ok: [cluster14]

TASK [Print ONTAP Response] *****************************************************************************************************
ok: [cluster14] =>
msg:
changed: false
failed: false
msg:
num_records: 2
records:
- node: cluster14-01
- node: cluster14-02

#

So, it looks as if it has run succcessfully ... But where's the version info.?

#

(My actual goal is to run network device discovery + lldp over all interfaces and capture the output for comparison with the documented network setup. I just started with "version" as a test :-))

umbral flare
#

my guess would be it's because "version" returns free-form text and not the usual table-like output, that ansible can't capture that properly. try "node image show" (that also shows the version that is currently runnung)

neat atlas
#

Hummm ... Trying "node image show" (and similar) resulted in a different problem 🤬 I get back "API not found" + "Code 3" ... But if I try a dead simple single word command "volume", it works. I get back a list of all the volumes

#

(actually a formatted list of vserver and volume pairs)

umbral owl
#

There are some quirks to this that can be found in the REST API documentation.

#

There are some commands in the CLI that will not work using REST APIs. This includes most show commands that do not support "show -fields" in the CLI. The REST API also does not support CLI commands that create a new shell (like "run" and "vserver context").

#

All fields that you want returned from the GET call must be specified using the fields parameter.

#

Device discovery information can also be found in the native /network/ethernet/ports API. So the na_ontap_rest_info module is probably easier to use.

neat atlas
#

FYI, just to follow up, I switched to using na_ontap_rest_info together with "fields" set to '*' and with that I can get a lot of field information e.g. state, vlan, tag, speed, mtu, etc - great! But there is no sign of any "discovered device" info. i.e. nothing like CDP or LLDP. Maybe searching in the swagger interface will help me find it. Am I right in thinking that it is presenting essentially the same dataset/interface/api?

umbral owl
#

This works for me. Discovered device info is available in REST API since ONTAP 9.11

#

- na_ontap_rest_info: gather_subset: - network/ethernet/ports fields: - discovered_devices.*

neat atlas
#

That worked ... Now I just need to figure out how to parse the output 🤠

tranquil sapphire
#

hi @neat atlas you probably already know this or may be trying to do something that does not match as well, but Harvest can collect the discovered devices

neat atlas
#

Humm, that might work, for this use case. We would hope to have a history of connected (network) devices, so we can track what the network team may have changed. So, to use Harvest/Grafana, we would need to configure an Alert and notification to trigger when a difference is noticed e.g. when a connected switch name or port changes ...