cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
840
Views
10
Helpful
2
Replies

2 service call points in same yang

erdemk
Level 1
Level 1

Dear NSO community,

 

Discussion came within our working group like that : is it possible to handle 2 services ( servicepoint ) within 1 yang file.

 

I have created one --service-skeleton package, created one yang file with 2 "ncs:servicepoint <service name>-servicepoint;"

 

And registered servicepoints each within python , and written a separate class for each registered service point. And it works. So far so good. From all i have seen is that , best practice would be to use separate packages for 2 different service though. 

 

Here the question is, whether this would work as regular, or may there be some abnormalities in some situations. 

 

class ServiceCallbacks(Service):

    @service.create

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

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

 

class ServiceCallbacks2(Service):

    @service.create

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

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

 

class Main(ncs.application.Application):

    def setup(self):

        self.log.info('Main RUNNING')

        self.register_service('<service1>-servicepoint', ServiceCallbacks)

        self.register_service('<service2>-servicepoint', ServiceCallbacks2)

    def teardown(self):

        self.log.info('Main FINISHED')

 

Any idea is appreciated.

 

Thanks and regards.

1 Accepted Solution

Accepted Solutions

yfherzog
Cisco Employee
Cisco Employee

Two questions here as I see it.

First, would it work?

Second, is it maintainable?

 

For maintainability, I'd say it mainly depends on what are those services about (I'd assume there's some sort of interrelations between them, otherwise why should you have them in one package). If you find it more maintainable than having them separately, then I'd say go for it.

 

Would it work? I'd expect the more delicate point here would be the location of the service points in YANG, rather than their callbacks in Python.

As long as the servicepoints locations are disjoint I think you're ok again.

i.e. servicepoint A on list A is not contained within list B which also contains servicepoint B - I'd not recommend this sort of architecture.

View solution in original post

2 Replies 2

yfherzog
Cisco Employee
Cisco Employee

Two questions here as I see it.

First, would it work?

Second, is it maintainable?

 

For maintainability, I'd say it mainly depends on what are those services about (I'd assume there's some sort of interrelations between them, otherwise why should you have them in one package). If you find it more maintainable than having them separately, then I'd say go for it.

 

Would it work? I'd expect the more delicate point here would be the location of the service points in YANG, rather than their callbacks in Python.

As long as the servicepoints locations are disjoint I think you're ok again.

i.e. servicepoint A on list A is not contained within list B which also contains servicepoint B - I'd not recommend this sort of architecture.

Thanks for quick reply yfherzog,

 

Actually , it is as you described. servicepoints are disjoint ie. each is in separate top level list within the yang file, and are using common topology tree which is out of both lists with servicepoints.

 

regards.