I am creating a service module and have a number of nested lists. I am running into a number of errors with my python code while trying to reference a leaf that is 2 lists deep:
list Configurator {
list IPVPN {
leaf vrf_name {
I have the following python configured to take characters in the middle of the vrf_name leaf and assign them to a variable vrf_serial:
def cb_create(self, tctx, root, service, proplist):
self.log.info('Service create(service=', service._path, ')')
vrf_name = service.IPVPN[vrf_name]
vrf_number=vrf_name[7:12]
vars = ncs.template.Variables()
vars.add('vrf_serial', vrf_number)
template = ncs.template.Template(service)
template.apply('Configurator-template', vars)
When I try to configure the service, I get the following error when viewing the native config:
errors: reason: Python cb_create error. local variable 'vrf_name' referenced before assignment
What am I missing in the python code?