01-15-2019 07:51 AM
Is there a simple way to map NSO CLI commands to the equivalent path in JSONRPC? I'm specifically looking to be able to do "devices device compare-config" and "devices sync-to dry-run" through Ansible's nso_actions module, but details on how to map to other commands would also be useful.
Solved! Go to Solution.
01-16-2019 02:47 AM
The path to use in JSONRPC calls is the YANG path. You can either look up your action in the YANG and trace backwards towards the root. Or you could run a CLI show command of the object where the action sits, and pipe the result through | display xpath | display prefixes.
If you have YANG as follows:
prefix abba;
container xyz {
leaf some-leaf { ... }
...
action my-action { ... }
}
The path would be "abba:xyz/my-action". If you don't want to trace that out directly from the YANG, you could see that by running a CLI show command like this:
show running-config xyz | display xpath | display prefixes
/abba:xyz/abba:some-leaf 47
...
More details in the nso_northbound UG, especially in the section "Method run_action".
01-16-2019 02:47 AM
The path to use in JSONRPC calls is the YANG path. You can either look up your action in the YANG and trace backwards towards the root. Or you could run a CLI show command of the object where the action sits, and pipe the result through | display xpath | display prefixes.
If you have YANG as follows:
prefix abba;
container xyz {
leaf some-leaf { ... }
...
action my-action { ... }
}
The path would be "abba:xyz/my-action". If you don't want to trace that out directly from the YANG, you could see that by running a CLI show command like this:
show running-config xyz | display xpath | display prefixes
/abba:xyz/abba:some-leaf 47
...
More details in the nso_northbound UG, especially in the section "Method run_action".
01-17-2019 02:00 AM
From the yang in src/yang/tailf-ncs-devices.yang, I guess the YAML for a sync-to dry-run would be like the below:
- name: Sync to devices hosts: localhost connection: local gather_facts: no tasks: - name: sync-to nso_action: url: "{{ nso.url }}" username: "{{ nso.username }}" password: "{{ nso.password }}" path: /ncs:devices/sync-to input: dry-run: output: native
When I try to run this as an ansible playbook, I get an error:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "NSO run_action returned JSON-RPC error: {u'data': {u'reason': u'no such leaf', u'param': u'/devices/sync-to/dry-run/output'}, u'message': u'Invalid action parameters', u'code': -32000, u'type': u'action.invalid_params'}"}
This same YAML works for a non dry-run if I replace the input with {}. What do I need to change in the YAML to trigger a dry-run?
01-18-2019 08:20 AM
My mistake, just needed to use outformat instead of output and it worked correctly.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide