We are trying to design a simple VPN service that will use resource-manager to handle VPN ID. We created the new package using python-and-template skeleton. We added resource-manager as an additional package and configured resource-pool for our VPN IDs.
In the service callback function for cb_create we implemented allocating VPN_ID using two example python functions if_request and id_read.
Allocating VPN ID for the new service works fine. Allocating specific VPN ID for new service also works fine but we would like to be able to change the VPN ID. This is where it gets complicated. There is no function to return allocated ID to the pool and If I try to allocate new specific ID for the existing service, I always get initial allocated VPND_ID value returned.
So my question is:
The reason for this is that allocation is a three-step process:
1. Write request
2. Allocation is made
3. Read response
Now if you UPDATE a request the response will already be there so you will read the old response rather than the old one. This is very unfortunate, but there are some possible workarounds.
The simplest workaround is to make the key you use in id_request/id_read depend on the input. So that you might today call it vlanid_vpnX or something like that, you could instead call it vlanid_vpnX_static9 (if 9 is your static number) or vlanid_vpnX_dynamic. This will trick the system into making a new fresh allocation.
When you want to change the ID that was allocated, do you want to do it for a fix ID or something also allocated automatically?
- If you want to re-allocate the ID with a fix ID, that is supported in the resource allocation API (via CLI, Python, RESTCONF, etc.). Here is the XML template where value is set in $REQUESTEDID:
<id-pool xmlns="http://tail-f.com/pkg/id-allocator" tags="nocreate">
If you change the value, the service will be re-deployed and will read the new value.
- if you want your ID to be re-assigned from the pool, I guess that means that the old value is not longer valid to be used in this pool. The process then is to exclude the old value from the pool: /ralloc:resource-pols/id-pool/exclude
The resource allocation logic will react by re-allocating a new value (from the pool) and re-deploy the service.
Thanks for the info.
I think I tried something like this but during service change, allocation id tied to this service is not accessible via root object. I can normally see all other allocation but not this one.
What you describe looks like the correct Fastmap behavior.
Now, I am not very sure what you are trying to achieve, maybe something like this inside your create code, where if the vlan_id is assigned by the northbound API, it is used in the request to the resource allocator as a fix value. If no vlan_id is set, a random value from the pool is requested.
I hope this helps!
id = service.vlan_id id_allocator.id_request(service, "/services/colt-vpls:colt-vpls[name='%s']" \ % (service.name), tctx.username, pool_name, alloc_name, False, id) else: id_allocator.id_request(service, "/services/colt-vpls:colt-vpls[name='%s']" \ % (service.name), tctx.username, pool_name, alloc_name, False) id = id_allocator.id_read(tctx.username, root, pool_name, alloc_name) if not id: self.log.info("Alloc not ready") return None self.log.info('id = %s' % (id))