cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
895
Views
0
Helpful
3
Replies

IP resource pool python

eubebe
Cisco Employee
Cisco Employee

We need to manage IP resource pools for a DHCP service using NSO. Please can anyone with experience using NSO to manage an IP resource pool, please share codes used for this ?

Python codes will be great, but we can also look codes written in other language.

Thanks

1 Accepted Solution

Accepted Solutions

frjansso
Cisco Employee
Cisco Employee

I'm assuming you're using the ipaddress-allocator and resource-manager packages.

If so, you can allocate networks (or addresses) like this:

class LoopService(Service):

    @Service.create

    def cb_create(self, tctx, root, service, proplist):

        self.log.info('Service create(service=', service._path, ')')

        pool_name = service.pool

        alloc_name = service.name

        self.log.info('CIDR length = ', service.cidr_length)

        ip_allocator.net_request(service,

                                 "/services/vl:loop-python[name='%s']" % (service.name),

                                 tctx.username,

                                 pool_name,

                                 alloc_name,

                                 service.cidr_length)

        net = ip_allocator.net_read(tctx.username, root,

                                    pool_name, alloc_name)

        if not net:

            self.log.info("Alloc not ready")

            return

        self.log.info('net = %s' % (net))

View solution in original post

3 Replies 3

frjansso
Cisco Employee
Cisco Employee

I'm assuming you're using the ipaddress-allocator and resource-manager packages.

If so, you can allocate networks (or addresses) like this:

class LoopService(Service):

    @Service.create

    def cb_create(self, tctx, root, service, proplist):

        self.log.info('Service create(service=', service._path, ')')

        pool_name = service.pool

        alloc_name = service.name

        self.log.info('CIDR length = ', service.cidr_length)

        ip_allocator.net_request(service,

                                 "/services/vl:loop-python[name='%s']" % (service.name),

                                 tctx.username,

                                 pool_name,

                                 alloc_name,

                                 service.cidr_length)

        net = ip_allocator.net_read(tctx.username, root,

                                    pool_name, alloc_name)

        if not net:

            self.log.info("Alloc not ready")

            return

        self.log.info('net = %s' % (net))

Thanks Fedrick for sharing this. Very helpful

We are have NSO 4.4.1 installed but looking at the tailf download site we dont seem to have ipaddress-allocator and resource-manager packages for 4.4.1 release, with the last version release

being 4.2.1.2/

Does anyone know if the ipaddress-allocator , resource-manager, packages and nso-util for 4.2.1.2 is compatible with NSO 4.4.1 ?

Is there plans to have these ncs packages updated?

That should be fine, download the latest version from NSO Software, here on the Hub, please let me know if you don't have access.


Recompile it for your NSO (e.g make clean all -C packages/resource-manager/src).