pythonjuniperpyez

Load Configuration File with Juniper PyEZ


I am trying to load override a config stored on the juniper device (vSRX) with PyEZ. The code looks like this

from jnpr.junos import Device
from jnpr.junos.utils.config import Config

dev = Device(host="x.x.x.x", user='user', password='pass').open()
with Config(dev, mode='private') as cu:  
    cu.load('load override minimal.conf', format='set')
    cu.pdiff()
    if cu.commit_check():
      cu.commit()

When I run the script I get below error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 534, in load
    ignore_warning=ignore_warning)
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 455, in try_load
    raise ConfigLoadError(cmd=err.cmd, rsp=err.rsp, errs=err.errs)
jnpr.junos.exception.ConfigLoadError: ConfigLoadError(severity: error, bad_element: load, message: error: unknown command)

Can't find a solution to my problem. Any help is greatly appreciated!


Solution

  • If you are trying to load config from a local file (on junos device), you should use url option

    Check for url in:

    http://junos-http://junos-pyez.readthedocs.io/en/2.1.8/jnpr.junos.utils.html#jnpr.junos.utils.config.Config.load