Bug? error: shared configuration database modified

2,799 views
Skip to first unread message

Ansel Gaddy

unread,
Apr 14, 2016, 2:52:49 PM4/14/16
to Junos Python EZ
I am making config changes to EX switches with pyez. On a number of devices I am running into this error in python:  'NoneType' object has no attribute 'getiterator'

This is being caused by 

user@device> configure private
Users currently editing the configuration:
  ACSwheel (pid 52259) on since 2016-04-14 13:36:58 CDT, idle 00:00:56
error: shared configuration database modified

I have found a way to get around this via CLI, but the pyez program keeps running into the same problem.

Basically going to root shell and then going back to CLI and edit somehow fixes this bug.

user@device> start shell user root
Password:
root@ device:RE:0% cli
{master:0}
user@ device > edit
Entering configuration mode
The configuration has been changed but not committed

{master:0}[edit]
user@ device# sh|compare

{master:0}[edit]
user@ device > configure private
warning: uncommitted changes will be discarded on exit
Entering configuration mode

{master:0}[edit]

But after that the pyez program still cant make the change.

#python
04-14-2016 13:44:18:558816 connected device 10.4.109.20 user user
04-14-2016 13:44:38:865133 loading the configuration changes 10.4.109.20
04-14-2016 13:45:08:866856 unable to load configuration changes 10.4.109.20: 'NoneType' object has no attribute 'getiterator'
04-14-2016 13:45:08:866948 closing connection 10.4.109.20
04-14-2016 13:45:38:982111 failed 10.4.109.20 error

#cli
user@device> configure private
error: shared configuration database modified

{master:0}

This is the pyez code that is loading the config. I think it is more or less standard.


        cu = Config(device)
       
        try:
            cu.unlock()
            print '{0} unlocked config {1}'.format(get_time(),host)
        except UnlockError:
            print '{0} loading the configuration changes {1}'.format(get_time(),host)
        
        try:
            cu.load(cmds,format='set',merge=True)
        except Exception as err:
            print '{0} unable to load configuration changes {1}: {2}'.format(get_time(),host,str(err))

            print '{0} closing connection {1}'.format(get_time(),host)
            device.close()
            return {'host':host,'complete':False,'error':'cant load config','lldp_ints':'none'}
        
        print '{0} committing the configuration {1}'.format(get_time(),host)
        try:
            cu.commit(comment='standardize LLDP lldp_ex.py')
        except CommitError:
            print '{0} error: unable to commit configuration {1}'.format(get_time(),host)
            device.close()
            return {'host':host,'complete':False,'error':'cant commit config','lldp_ints':'none'}
        
        print '{0} completed lldp change {1}'.format(get_time(),host)
        device.close()
        
        return {'host':host,'complete':True,'error':None,'lldp_ints':lldp_ints}
    except Exception as err:
        print '{0} failed {1} error {2}'.format(get_time(),host,err)
        return {'host':host,'complete':False,'error':str(err),'lldp_ints':'none'}

Thanks!
-Ansel

Nitin Kr (Automation)

unread,
Apr 15, 2016, 6:05:09 AM4/15/16
to Ansel Gaddy, Junos Python EZ
Hi Ansel,

Can you share the traceback. Below message printed from the script is not helping me to debug.

Thanks
Nitin Kr

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-...@googlegroups.com.
Visit this group at https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit https://groups.google.com/d/msgid/junos-python-ez/96d891fe-f220-49b9-b8e7-a94686ccf4ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ansel Gaddy

unread,
Apr 15, 2016, 3:24:36 PM4/15/16
to Junos Python EZ, aeg...@gmail.com, nit...@juniper.net
Hey Nitin,

I am still wrapping my head around traceback module. But for now I think this is more informative while I figure that out.

>>> from jnpr.junos import Device
>>> from jnpr.junos import Device
>>> from jnpr.junos.utils.config import Config
>>> from jnpr.junos.exception import *

>>> dev = Device(host='10.4.10.19',user='user',password='pw')
>>> dev.open(gather_facts=False)
Device(10.4.10.19)

>>> dev.probe()
True
>>> dev.connected
True

>>> cu = Config(dev)

>>> try:
...     cu.unlock()
...     print 'unlocked'
... except UnlockError:
...     print 'did not need unlock'
...
did not need unlock

>>> lldp_config='''delete protocols lldp
... delete protocols lldp-med
... set protocols lldp interface all disable
... set protocols lldp-med interface all disable
... set protocols lldp traceoptions file lldp-debug
... set protocols lldp traceoptions file size 1m
... set protocols lldp traceoptions file files 10
... set protocols lldp traceoptions flag all'''

>>> cu.load(lldp_config,format='set',merge=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/jnpr/junos/utils/config.py", line 344, in load
    return try_load(rpc_contents, rpc_xattrs)
  File "/usr/local/lib/python2.7/site-packages/jnpr/junos/utils/config.py", line 310, in try_load
    raise ConfigLoadError(cmd=err.cmd, rsp=err.rsp, errs=err.errs)
  File "/usr/local/lib/python2.7/site-packages/jnpr/junos/exception.py", line 55, in __init__
    self.rpc_error = jxml.rpc_error(rsp)
  File "/usr/local/lib/python2.7/site-packages/jnpr/junos/jxml.py", line 58, in rpc_error
    remove_namespaces(rpc_xml)
  File "/usr/local/lib/python2.7/site-packages/jnpr/junos/jxml.py", line 46, in remove_namespaces
    for elem in xml.getiterator():

Sincerely,
-Ansel
Reply all
Reply to author
Forward
0 new messages