Hi,
I've just begun my road to victory with python and pyez. So there might be some basic failure in my understanding on what and how this should be working.
First out, I deployed set vlans config, no issue at all, works just fine.
Then I've added "set interface ge-0/0/5.<XXX> vlan-id <XXX>. This just wont load. If I run it manually on the cli it works fine.
Here is my code snippet!
a_device = Device(host=my_host, gather_facts=False, user=usrname, password=usrpasswd)
a_device.open()
Device(a_device)
cfg = Config(a_device)
cfg.lock()
if set_cmds:
print(set_cmds)
for cmd in set_cmds:
print("Debug... " + cmd)
#cfg.load(cmd, format="set", merge=True) <-- This doesnt work.
#Adding the cfg static, to rule out everything else.
cfg.load("set interface ge-0/0/5 unit 122 vlan-id 122", format="set", merge=True) <-- it breaks here!
print("Did it pass?")
#if it passed, can i do cfg.load with more set-lines?
#cfg.load("set interface ge-0/0/5 unit 11 vlan-id 11", format="set", merge=True)
I can see that the commands in my "set_cmds" list is just fine if i print them. Also the set vlan works with the "set_cmds" list. So thats not the problem.
It says "bad element" when trying to set the interface:
Traceback (most recent call last):
File "set-vlan-MAIN.py", line 150, in <module>
jnpr_vlanarg_ssh_keys(host, buildvlancfg())
File "set-vlan-MAIN.py", line 91, in jnpr_vlanarg_ssh_keys
cfg.load("set interface ge-0/0/5 unit 122 vlan-id 122", format="set", merge=True)
File "/usr/lib/python3.8/site-packages/jnpr/junos/utils/config.py", line 579, in load
return try_load(rpc_contents, rpc_xattrs, ignore_warning=ignore_warning)
File "/usr/lib/python3.8/site-packages/jnpr/junos/utils/config.py", line 496, in try_load
raise ConfigLoadError(cmd=err.cmd, rsp=err.rsp, errs=err.errs)
jnpr.junos.exception.ConfigLoadError: ConfigLoadError(severity: error, bad_element: interface, message: error: syntax error)
Any ideas why?
I've tried to find out in the docs but cant see a clear reason on this matter.
Thanks in advance for any input!
//Rob