10-26-2020 01:47 AM
Hi team,
I'm struggling to use "nso_action" ansible module to invoke "load-native-config" action as I cannot provide the right input arguments.
What I tried so far is:
input:
file: <file>
input:
source:
file: <file>
input:
source: "file <file>"
"
The first one ends with "no parameter file" message prior to JSON RPC call itself, the other ones produce the JSON RPC call but they return error {'type': 'action.invalid_params', 'code': -32000, 'message': 'Invalid action parameters', 'data': {'reason': 'no such leaf', 'param': '/devices/device/load-native-config/source'}}
Does anyone know how it should be done?
Thanks in advance,
Djordje
Solved! Go to Solution.
10-26-2020 06:02 AM - edited 10-26-2020 06:03 AM
Hello a quick look at the yang model shows (NSO 5.3.1.1 but should not be different in other)
tailf:action load-native-config {
tailf:display-when "../device-type/cli or "
+ "../device-type/generic or ../device-type/netconf";
description
"Load configuration data in native format into the transaction.
[...]
it will automatically create one and commit it.";
tailf:info "Load configuration data in native format";
tailf:cli-configure-mode;
tailf:actionpoint ncsinternal {
tailf:internal;
}
input {
choice source {
leaf file {
type string;
[...]
}
leaf data {
type string;
tailf:cli-multi-line-prompt;
[...]
}
mandatory true;
}
[...]
I tried out and the correct JSON RPC is:
{
"jsonrpc":"2.0",
"id":99,
"method":"run_action",
"params": {
"th": 1,
"path": "/ncs:devices/device{f0}/load-native-config",
"params": {"file": "test.xml"}
}
}
I think the problem is in the ansible module not correctly supporting choices as possible inputs (I could not find the module in the branch stable-2.10 so it may have changed):
Here is the line raising your exception "no parameter file" because de facto the code is checking for direct children and only "source" is found but it is a choice node. So the code in the ansible module should be changed to also check one level deeper if the child is a choice.
I think you can open a github issue there or implement a patch for the module and submit a Pull Request.
Best regards,
Guillaume
10-26-2020 06:02 AM - edited 10-26-2020 06:03 AM
Hello a quick look at the yang model shows (NSO 5.3.1.1 but should not be different in other)
tailf:action load-native-config {
tailf:display-when "../device-type/cli or "
+ "../device-type/generic or ../device-type/netconf";
description
"Load configuration data in native format into the transaction.
[...]
it will automatically create one and commit it.";
tailf:info "Load configuration data in native format";
tailf:cli-configure-mode;
tailf:actionpoint ncsinternal {
tailf:internal;
}
input {
choice source {
leaf file {
type string;
[...]
}
leaf data {
type string;
tailf:cli-multi-line-prompt;
[...]
}
mandatory true;
}
[...]
I tried out and the correct JSON RPC is:
{
"jsonrpc":"2.0",
"id":99,
"method":"run_action",
"params": {
"th": 1,
"path": "/ncs:devices/device{f0}/load-native-config",
"params": {"file": "test.xml"}
}
}
I think the problem is in the ansible module not correctly supporting choices as possible inputs (I could not find the module in the branch stable-2.10 so it may have changed):
Here is the line raising your exception "no parameter file" because de facto the code is checking for direct children and only "source" is found but it is a choice node. So the code in the ansible module should be changed to also check one level deeper if the child is a choice.
I think you can open a github issue there or implement a patch for the module and submit a Pull Request.
Best regards,
Guillaume
10-26-2020 06:23 AM
Hi Guillaume,
thanks for the analysis! Actually, I came to similar conclusions that Ansible module must be changed, so I'll try to see what can be done.
Best regards,
Djordje
10-27-2020 01:36 PM
fyi most modules not related to the base Ansible functionality are being moved to ansible-collections in 2.10:
https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_2.10.html
10-27-2020 02:17 PM
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