cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
921
Views
5
Helpful
4
Replies

Using ansible "nso_action" module to invoke "load-native-config" action

dvulovic
Cisco Employee
Cisco Employee

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

1 Accepted Solution

Accepted Solutions

gmuloche
Cisco Employee
Cisco Employee

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):

https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/modules/network/nso/nso_action.py#L116

 

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

 

View solution in original post

4 Replies 4

gmuloche
Cisco Employee
Cisco Employee

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):

https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/modules/network/nso/nso_action.py#L116

 

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

 

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

There is now a brand new repo for exactly that: https://github.com/CiscoDevNet/ansible-nso (And @gmuloche created an issue for this thread).

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: