cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
675
Views
15
Helpful
2
Replies

Python OperSubscriber documentation/example

Diddi
Level 1
Level 1

I'm looking to implement the reactive fastmap pattern by having a vpn service request a vpn id. I understand the high level concept of writing and reading operational data and having a CDB subscriber to re-deploy the service once the id has been allocated. What I'm struggling with is wrapping my head around how to actually implement the CDB subscriber to do this as the documentation seem to lack any clear information, or I'm not looking in the right place.

 

I've mainly looked at the example opercdbsub.py in getting-started/1-dcb-py but the code is difficult to read and understand. Comments refer to a Java project and most methods have variables with no information about what they mean and what I can expect from them (for example "kp", "op", "state" among others). The diff iteration seems to be a core part of the subscriber but I have no clue when or how it's being called, what's passed to it and what I'm supposed to do within it.

 

The Python API docs for OperSubscriber and Subscriber is rather thin on information as well. Constructor parameters aren't explained at all (for example "app", "name" and "subtype") and the docstrings for methods like "run" and "register" simply words the method name differently while not providing much additional information. Is one of them where I would implement the code to allocate my vpn id?

I don't have very deep knowledge with low level CDB and how it operates, is this necessary to create a CDB subscriber?

 

Is there a more simple and explanatory example of a CDB subscriber or some other guide on how to build one in python available?

Thanks

1 Accepted Solution

Accepted Solutions

hniska
Cisco Employee
Cisco Employee

ncs-make-package can actually add an example python subscriber to your code

 

ncs-make-package --help
Usage: ncs-make-package [options] package-name

ncs-make-package --service-skeleton TYPE package-name

 

where TYPE is one of:
python Python based service
python-and-template Python service with template

 

PYTHON specific options:
--subscriber-example

View solution in original post

2 Replies 2

hniska
Cisco Employee
Cisco Employee

ncs-make-package can actually add an example python subscriber to your code

 

ncs-make-package --help
Usage: ncs-make-package [options] package-name

ncs-make-package --service-skeleton TYPE package-name

 

where TYPE is one of:
python Python based service
python-and-template Python service with template

 

PYTHON specific options:
--subscriber-example

hniska
Cisco Employee
Cisco Employee

But a shameless plug (written by me), there is an simple example package on the developer hub that you can use or at least get some ideas from

 

https://github.com/NSO-developer/external-id-allocation