Automation

last person joined: 8 days ago 

Ask questions and share experiences about Apstra, Paragon, and all things network automation.
  • 1.  PyEZ Entering User Password

    Posted 09-17-2015 02:08

    Hi.
    I am trying to create users with JunOS PyEZ but when I try to enter password I get error. I heard about "user" module but couldn't find a synthax for it. This is what I tried.

     

    Thanks

     

    from jnpr.junos import Device
    from jnpr.junos.utils.config import Config  
    
    dev = Device(host='192.168.56.2', user='root', password='Juniper1')
    dev.open()
    cu=Config(dev)
    #############################

    new_User
    ='set system login user Read class read-only authentication plain-text-password'
    pass_New='Read1234'
    pass_Repeat='Read1234'
    ##############################

    cu
    .load(new_User, format='set')
    cu.load(pass_New,format='set')
    cu.load(pass_Repeat,format='set')

     Here is the error

     

    Traceback (most recent call last):
      File "/home/oscar/PycharmProjects/Junos/HelloWorld.py", line 18, in <module>    cu.load(pass_New,format='set')
      File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 377, in load
        return try_load(rpc_contents, rpc_xattrs)
      File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 343, in try_load
        raise ConfigLoadError(cmd=err.cmd, rsp=err.rsp, errs=err.errs)jnpr.junos.exception.ConfigLoadError: ConfigLoadError(severity: error, bad_element: Read1234, message: unknown command)

     



  • 2.  RE: PyEZ Entering User Password

     
    Posted 09-17-2015 03:58

    Hi,

     

    The first load is valid as it contains a set cli string, however the last two are not valid as they are just text.

     

    The exception explains it;

     

    ConfigLoadError(severity: error, bad_element: Read1234, message: unknown command)

    'unknown command' which has been return from the junos device.

     

    See the API;

     

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

     

    You can either provide the encrypted password within the first load command or create an expect style script to perform the plain text password.

     

    Tim



  • 3.  RE: PyEZ Entering User Password
    Best Answer

    Posted 09-17-2015 11:48

    This isn't valid from a script because it is expecting direct input from the user session:

     

    set system login user Read class read-only authentication plain-text-password 

     Instead, if you really want to input the password in plain text, use the hidden configuration option "plain-text-password-value"

     

    e.g.:

     

    set system login user Read class read-only authentication plain-text-password-value Read1234



  • 4.  RE: PyEZ Entering User Password

    Posted 09-28-2015 06:10

    Thanks you very much this helped me alot