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

service.getchanged matching procedure in python

yongz2
Cisco Employee
Cisco Employee

Hi All,

In the premod samples

service have a procedure of

 List<NavuNode> changedNodes = service.getChanges(true);

 

is there a matching procedure in python library ?

1 Reply 1

gyula.revak
Level 1
Level 1

Hi,

 

I know it is an old question, but maybe will help others in the future. Unfortunately I haven't found any matching procedure, but in maapi you can use a method called diff_iterate:

 

diff_iterate(sock, thandle, iter, flags)

With this method you can iterate through all the changes in the given transaction (which can be a create callback). The key is the iter argument, which is basically the method where you handle the changes. It can be defined this way:

def iter(keypath, operation, oldvalue, newvalue)

It is very similar to subscriber's iterate solution.

 

A code snippet how it looks like in pre-modification (it simply write the changes into log file):

 

class ServiceCallbacks(Service):

def iterate(self, keypath, operation, oldvalue, newvalue):
self.log.info("Pre-mod changes: keypath:{}, operation:{}, oldvalue:{}, newvalue:{}".
format(keypath, operation, oldvalue, newvalue))

@Service.pre_modification
def cb_pre_modification(self, tctx, op, kp, root, proplist):
self.log.info("Pre-mod started")
maapi = Maapi()
maapi.attach(tctx)
maapi.diff_iterate(tctx.th, self.iterate, 0)

You can find further infos in the maapi_doc.c file.

 

 

 

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?