cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1672
Views
0
Helpful
5
Replies

NSO resource-manager change assigned id

Hi.

 

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:

  • Is changing assigned ID values even possible in resource manager?
  • If yes, what would be the workflow we need to do to achieve this. Deleting the service and created it again it seems like overkill.

Best regards.

 

 

5 Replies 5

vleijon
Cisco Employee
Cisco Employee

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.

Thanks Viktor.

 

This sounds like a valid workaround. I will try it and let you know.

 

 

rogaglia
Cisco Employee
Cisco Employee

Hi,

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:

<config-template xmlns="http://tail-f.com/ns/config/1.0">
<resource-pools xmlns="http://tail-f.com/pkg/resource-allocator">
<id-pool xmlns="http://tail-f.com/pkg/id-allocator" tags="nocreate">
<name>{$POOL}</name>
<allocation tags="merge">
<id>{$ALLOCATIONID}</id>
<username>{$USERNAME}</username>
<allocating-service xmlns:ncs="http://tail-f.com/ns/ncs">{$SERVICE}</allocating-service>
<request>
<id when="{$REQUESTEDID!='-1'}">{$REQUESTEDID}</id>
<sync>{$SYNC}</sync>
</request>
</allocation>
</id-pool>
</resource-pools>
</config-template>

 

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.

Hi,

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!

Roque

 

        if service.vlan_id:
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))
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: