How can I (dynamically) create resource pools that assign resources on a per-device basis? Basically, I'd like to generate a pool for every device that assigns an index to some of the device's interfaces.
The following will re-use the same indexes for all devices, which is not what I want:
for interface in service.interface: self.log.info('Working on interface ', interface.ifname) id_allocator.id_request(service, "/sdwan-underlay[device='%s']" % (service.device), tctx.username, 'ifids', interface.ifname, False)
if not ifid: # must start at 1, 0 will drop into this self.log.info("IFID not ready") return self.log.info('IFID = %s' % (ifid)) interface.intfid = ifid
I could of course manually create a pool for every device before I actually add the device, but I'm looking for a way how to handle that in Python. How can I create such a pool when (before) a new device is added? And how could it be deleted when the device disappears again?
pool_name = service.device idpool = root.ralloc__resource_pools.idalloc__id_pool #Check if pool exists, if not, create new one if not pool_name in idpool: idpool.create(pool_name) self.log.info('Generating a new idpool for ', pool_name) idpool[pool_name].range.start = 1 idpool[pool_name].range.end = 128
for interface in service.interface: self.log.info('Working on interface ', interface.ifname) id_allocator.id_request(service, "/sdwan-underlay[device='%s']" % (service.device), tctx.username, pool_name, interface.ifname, False)
One comment, you probably want to skip that if-statement checking if the pool already exists or not. If you have multiple services on the same device you want them all to create the pool. NSO is reference counting which means that if they all have a reference to the pool it won’t be deleted until the last service is deleted.
It is best practice to avoid storing your secrets (e.g., passwords and shared keys) in plain text, either on NSO or on the device. In NSO, we support multiple encrypted data types that are encrypted using a local key. Similarly, many devices such as Cisco...
Cisco Developer Days, September 14-15, 2021
On Tuesday next week, we will open the doors to the 11th Cisco Developer Days!
If you have not registered for the free, virtual event, do it now!
What can you expect?
We have a packed 2-day agen...
In the blog post series called "Unlocking Performance in your NSO System" we talked about the need to measure performance and to profile the performance in order to identify bottlenecks. We didn't go into any details about how to do this. Last year at the...
Finally, as you may have seen in the News & Announcement, we have opened the landing page for the next Developer Days event in September! The September 14/15 event is the first in a series of three virtual events in the three regions (EMEAR/US/Asia Pa...
We are excited to announce that our call for speakers for our upcoming Developer Days events is open!
Automation is a journey in itself and no two journeys are alike. Planning and preparation are a must for any major project. Having an open mind to u...