cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1048
Views
0
Helpful
1
Replies

Duplicate/copy the config data from a specifc path

pradc
Cisco Employee
Cisco Employee

How to duplicate the config data from path /A/* to path /B/*.

What is the best API to do this programmatically.

 

 

 

1 Reply 1

yfherzog
Cisco Employee
Cisco Employee

There are multiple options.

With the Python API you can use the copy_tree() method.

 

import ncs.maapi as maapi

import ncs.maagic as maagic

m = maapi.Maapi()

m.start_user_session('admin','system')

t = m.start_write_trans()

root = maagic.get_root(t)

for s in root.src__src:
    print 'copy {}'.format(s.my_key)
    d = root.dst__dst.create(s.my_key)
    m.copy_tree(t.th, s._path, d._path)

In this case, src and dst are two lists with similar data structures, and a key leaf called my-key.

The code copies all list entries in src to dst.

Polls
AI-powered tools for network troubleshooting are likely to be part of everyone’s workflow sooner or later. What is the single biggest challenge or concern you see with adopting these tools in your organization?