02-21-2022 03:15 AM
Hello,
I'm trying to use device templates and applying it to a device from a python Action. How to reproduce the following command using python:
devices device DEV-NAME apply-template template-name TEMP-NAME variable { name VAR-NAME1 value VALUE1 }
variable { name VAR-NAME2 value VALUE2 }
I didn't find any documentation about apply_template action.
Best regards,
Solved! Go to Solution.
02-21-2022 05:47 AM
02-21-2022 05:47 AM
02-21-2022 01:11 PM
Thank you very much for your help Sir.
11-18-2023 09:04 PM
Old thread but I just hit the same problem. NSO6.1.4 and the same code does not work. It shows transaction being processed in devel.log however nothing changes in the CDB in config for the device. My setup uses local NSO instance which has load-merged config from real device but device is never sync-ed. Commit is done with no-networking parameter. What am I doing wrong here ?
try:
with ncs.maapi.single_write_trans(uinfo.username, uinfo.context, ["ncsadmin"]) as t:
root = ncs.maagic.get_root(t)
ztp_config_cdb = ncs.maagic.get_node(t, kp)
app = root.devices.device[ztp_config_cdb.name].apply_template
inp = app.get_input()
inp.template_name = 'day1-smf'
var1 = inp.variable.create('profile_name')
var1.value = '\'JUN2023\''
app(inp)
t.apply(flags=16)
except _ncs.error.Error as e:
self.log.error('Error while applying template on the configuration.')
self.log.error(f'Error: {e}')
11-19-2023 10:30 PM
Do you get any help from the ncs-python-vm log files? Check both the vm and the package specific logs.
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