cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1404
Views
2
Helpful
7
Replies

Programatically display device configuration with set format in NSO

sm000x
Level 1
Level 1

Hi,

I can do the following in NSO's ncs_cli:

prompt> show configuration devices device J1 config junos:configuration | display set

I can write shell then in Java program to invoke the shell script:
ncs_cli -u admin << END
show configuration devices device ${DEVNM} config junos:configuration | display set
exit
END

But is there any way to do it programmatically without a shell script?

Thx
sm000x

 

7 Replies 7

Alexander Stevenson
Cisco Employee
Cisco Employee

Please check these repos in the Cisco Code Exchange:

https://developer.cisco.com/codeexchange/search/?products=NSO

They ones using Ansible or the NSO API seem promising.

 

For a complete overview, see this repo as well: 

 

https://developer.cisco.com/codeexchange/github/repo/juliogomez/netdevops/

 

I hope you find what you're looking for.

Nabsch
Spotlight
Spotlight

Hello,

Based on the Python doc , you cannot . You can only get  normal Junos config without the set . 

You can check  the example in the install directory (

$NCS_DIR/examples.ncs/getting-started/developing-with-ncs/24-layered-service-architecture-scaling/lower-nso-1/packages/device-actions/python/device_action.py) that show how to read  CDB config from Python ( the function 
recv_all_and_close and  read_config).
 
You can open a new case and ask if the BU could implement it.
 
 
 

tohagber
Cisco Employee
Cisco Employee

What is the underlying use-case for needing the config in "set"- format?

fracjackmac
Level 1
Level 1

Hello @tohagber,

I'll provide one person's brief view of why the "display set" option is important.

Like the "formal" parameter that's available for IOS XR's "show running-config formal" command, the Junos "display set" option produces output that provides all the configuration components that make up each command submitted to the device.

This level of detail makes it much easier to compare configuration statements and ensure correctness.

The detail also makes it easier to compare configuration statements and determine differences in the configs of different boxes.

atreyulovesyou
Level 1
Level 1

I'd echo 'it'd be nice to be able to "show services my-service-abc | display set"'

why?

I have hundreds of json requests that create nso service instances in various test cases via restconf.

I'd like to be able to generate (and keep up to date) examples for nso operators, many of whom enjoy using set commands via CLI, and are accustomed to reviewing these.

there must be some way to ask nso for this form of output on a service instance get, via RESTConf??

tohagber
Cisco Employee
Cisco Employee

The "show ... | display set" command is implemented in NSO's CLI server, thus when communicating with NSO via restconf or other interfaces the CLI server is not involved hence that pipe command does not exist for other interfaces.

The closest thing (i can think of how atm) is that you could implement an action that takes a path (you want to show) as a parameter
and the action implementation uses maapi.save_config(..) which has support for providing the result back in different formats, like:

MAAPI_CONFIG_XML
The configuration format is XML.
MAAPI_CONFIG_XML_PRETTY
The configuration format is pretty printed XML.
MAAPI_CONFIG_JSON
The configuration is in JSON format.
MAAPI_CONFIG_J
The configuration is in curly bracket Juniper CLI format.
MAAPI_CONFIG_C
The configuration is in Cisco XR style format.
...
To return that back from the action.


 

Hi, Tohagber:

Thank you for this suggestion. I will give it a try.

THX
sm000x