05-17-2020 05:25 AM
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
05-17-2020 06:02 AM
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).
05-17-2020 08:33 AM - edited 05-17-2020 01:51 PM
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)
05-17-2020 11:26 PM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide