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

create service package with python and template error while package reload

nso20
Level 1
Level 1

Hello,

with the command: ncs-make-package --service-skeleton python-and-template myservice --augment /ncs:services

I created service package and put some variables in xml template with syntax {/myvar1}, no problems with packages reload.

But when I changed it to {$myvar1} and add it in main.py: vars.add('myvar1', 'test'), the below error appears when package reload:

reload-result {
package myservice
result false
info TabError: inconsistent use of tabs and spaces in indentation

}

 

So the problem is when I try involve one python variable in template, package reload fails. No problem with yang in both cases, make is ok.

 

NSO version: 5.3

 

 

3 Replies 3

yfherzog
Cisco Employee
Cisco Employee

I think the problem is more related to python than to NSO.

NSO is trying to start the python VM for your service package, but the lines that you added to the python code are not using the same indentation as some other lines on the same file, and python reports this as an error

 

Check the indentation on your python code. Make sure that the indentations are uniform across the file (e.g. use either tabs or spaces, use same number of tabs or spaces for each indent).

But I only added: vars.add('myvar1','test'), with the same indentation like already existing vars, this is the only line added in main.py

vars = ncs.template.Variables()
#vars.add('DUMMY', '127.0.0.1')
vars.add('myvar1', 'test')

template = ncs.template.Template(service)
template.apply('myservice-template', vars)

One line is enough if it's not indented in the same way the others are.

The editor you're using might make it easier or harder to get into those corners.

Try deleting your line and editing the line you commented out instead of creating a new line.

 

You can also have a look in your logs directory (under your runtime directory) for the ncs-python-vm.log file and a similar file with your package name for more details, but if indeed you only changed that line (and your editor is not trying to set indentation on its own in a weird way), then that should be the issue.