取消
显示结果 
搜索替代 
您的意思是: 
cancel
752
查看次数
5
有帮助
2
回复

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 个已接受解答

已接受的解答

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

在原帖中查看解决方案

2 条回复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

neetimit
Cisco Employee
Cisco Employee

@gmuloche  Thanks so much! this worked perfectly.