cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
803
Views
0
Helpful
2
Replies

NSO Template

previousqna
Level 5
Level 5

Hello Team,

 

        I have a question about service template in NSO, demo code(python) is as bellow,

 

       @service.create

 

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

 

        try:

 

            vars_prefix = ncs.template.Variables()

 

            template = ncs.template.Template(service)

 

            vars_prefix.add("DEVICE",service.device)

 

            vars_prefix.add("PREFIX_NAME",service.prefix_name)

 

            for value in service.prefix_values:

 

                vars_prefix.add("PREFIX_VALUE",value.prefix_value)

 

                template.apply('uptest-prefix', vars_prefix)

 

         

 

           service_args = ComposeArgs()

 

           peering_generic_info , peering_unique_attr, peering_links_attr,msg_expection = service_args.validate_args(service)

 

          

 

           if msg_expection != ‘’:

 

   raise Exception (“something is wrong”)

 

 

        except Exception as e:

 

self.ilogger.rerror(str(e),2)

 

 

 

 

 

  My question is when I raise Exception, how do I drop applying template ?

1 Accepted Solution

Accepted Solutions

previousqna
Level 5
Level 5

Hi!

 

 

re-throw the exception, then the transaction is aborted and the error message is presented to the user.

View solution in original post

2 Replies 2

previousqna
Level 5
Level 5

Hi!

 

 

re-throw the exception, then the transaction is aborted and the error message is presented to the user.

Thanks , works now.