cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
908
Views
5
Helpful
2
Replies

How to segregate between user-defined config and default configs on a device from Java Api in NSO

neetimit
Cisco Employee
Cisco Employee

I am trying to delete all user-defined configuration on a device using NAVU API in action package, but when I traverse the tree, I get all the default leafs as well

for example for nx device these are default configs and not done by operator explicitly: 

leaf path: /ncs:devices/device{rfs1nx}/config/nx:interface/Ethernet{1/25}/mtu leaf value: 1500
leaf path: /ncs:devices/device{rfs1nx}/config/nx:interface/Ethernet{1/25}/delay leaf value: 1

.

.

.

 

Executing live-status action gives me the user-defined config only but then how can I create Xpath for leaf deletion using these config lines? Any suggestions?

 

output of live-status:

 

interface Ethernet1/12

  description NXC

  shutdown

  switchport access vlan 999

  speed 1000

  no snmp trap link-status

 

Appreciate any inputs!!

1 Accepted Solution

Accepted Solutions

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

You can have a look at the flags for your MAAPI session in the doc: "doc/api/java/com/tailf/maapi/MaapiFlag.html". The flags NO_DEFAULT should be able to solve your problem (quoting 5.2 doc):

 

NO_DEFAULTS
public static final MaapiFlag NO_DEFAULTS
This flag specifies that we want to be informed when we read leafs with default values that have not had a value set.
This is indicated by the returned value being of class ConfDefault (type J_DEFAULT) instead of the actual value. The default value for such leafs can be obtained from the Maapi.loadSchemas() tree provided by the library.

You can set the flags at transaction creation or using the setFlags function. I don't have a working example in Java but I have used similar mechanism in python in the past.

 

Regards

View solution in original post

2 Replies 2

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

You can have a look at the flags for your MAAPI session in the doc: "doc/api/java/com/tailf/maapi/MaapiFlag.html". The flags NO_DEFAULT should be able to solve your problem (quoting 5.2 doc):

 

NO_DEFAULTS
public static final MaapiFlag NO_DEFAULTS
This flag specifies that we want to be informed when we read leafs with default values that have not had a value set.
This is indicated by the returned value being of class ConfDefault (type J_DEFAULT) instead of the actual value. The default value for such leafs can be obtained from the Maapi.loadSchemas() tree provided by the library.

You can set the flags at transaction creation or using the setFlags function. I don't have a working example in Java but I have used similar mechanism in python in the past.

 

Regards

@gmuloche  Thanks so much! this worked perfectly.