cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
507
Views
0
Helpful
2
Replies

ncs.cdb.Subscriber.iterate oldv and newv

Jonathan75466
Level 1
Level 1

The function signature for ncs.cdb.Subscriber.iterate is shown by pydoc as the following:

 

iterate(kp, op, oldv, newv, state) (mandatory)
Called for each change in the change set.

 

When this function is called the values of oldv and newv are None except in the case where op is equal to ncs.MOP_VALUE_SET; In this case oldv and newv are of type _ncs.Value with oldv.confd_type_str returning C_BINARY.

 

How can I get the actual old and versions of the config to which I have subscribed. This would be particularly useful when op is equal to ncs.MOP_DELETED; This would allow me to store external system ids with the config on create and then clean up the external system on delete.

2 Replies 2

snovello
Cisco Employee
Cisco Employee
Hello Jonathan,
This isn’t a direct answer to your question, I have not tried the subscriber API you are using, but I think maybe you don’t need to use that API for your purposes.

A common pattern to deal with actions you have to do on deletion of services is to ensure a copy has been kept of the deleted services, so you keep all the required values, this copy is deleted only after the actions have run. In the development manual there is a chapter ‘Nano Services’, and in particular a section ‘Zombie services’ which explains this in more detail. Nano services provide an infrastructure which amongst other things make it simpler to use that pattern. There is an example of a nano service in your installation under examples.ncs/getting-started/developing-with-ncs/20-nano-services

Hello Jonathan,
I read your question again more carefully and I see what you actually want to clean up is an external id allocation. So keeping a copy of the service is not going to help much at all.

There is a package on github that does external id allocation, and uses the keypath argument of the subscriber to figure out what id it has to release when it sees a deletion

SEE
https://github.com/NSO-developer/external-id-allocation/blob/master/python/external_id_allocation/main.py