Strange exception when call .close()
See original GitHub issueHello, folks!
I’m using eznc with SRX240:
from pprint import pprint
from jnpr.junos import Device
dev = Device(host='10.0.x.x', user='view_config', password='xxxxx' )
dev.open()
pprint( dev.facts )
#dev.close()
It works pretty nice with commented out “dev.close”:
{'2RE': False,
'HOME': '/cf/var/home/view_config',
'RE0': {'last_reboot_reason': '0x1:power cycle/failure',
'model': 'RE-SRX240H',
'status': 'OK',
'up_time': '4 days, 13 hours, 7 minutes, 50 seconds'},
'domain': None,
'fqdn': 'selectel-router',
'hostname': 'selectel-router',
'ifd_style': 'CLASSIC',
'model': 'SRX240H',
'personality': 'SRX_BRANCH',
'serialnumber': 'AG3211AA0462',
'srx_cluster': False,
'switch_style': 'VLAN',
'vc_capable': False,
'version': '12.1X46-D35.1',
'version_info': junos.version_info(major=(12, 1), type=X, minor=(46, 'D', 35), build=1)}
But when I uncomment dev.close():
from pprint import pprint
from jnpr.junos import Device
dev = Device(host='10.0.6.1', user='view_config', password='DJb2x92VDIpa99ct' )
dev.open()
pprint( dev.facts )
dev.close()
I still get device information but also get exception about permission denied:
python junos_ez.py
{'2RE': False,
'HOME': '/cf/var/home/view_config',
'RE0': {'last_reboot_reason': '0x1:power cycle/failure',
'model': 'RE-SRX240H',
'status': 'OK',
'up_time': '4 days, 13 hours, 10 minutes, 45 seconds'},
'domain': None,
'fqdn': 'selectel-router',
'hostname': 'selectel-router',
'ifd_style': 'CLASSIC',
'model': 'SRX240H',
'personality': 'SRX_BRANCH',
'serialnumber': 'AG3211AA0462',
'srx_cluster': False,
'switch_style': 'VLAN',
'vc_capable': False,
'version': '12.1X46-D35.1',
'version_info': junos.version_info(major=(12, 1), type=X, minor=(46, 'D', 35), build=1)}
Traceback (most recent call last):
File "junos_ez.py", line 9, in <module>
dev.close()
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 504, in close
self._conn.close_session()
File "/usr/local/lib/python2.7/dist-packages/ncclient/manager.py", line 157, in wrapper
return self.execute(op_cls, *args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/ncclient/manager.py", line 227, in execute
raise_mode=self._raise_mode).request(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/ncclient/operations/session.py", line 28, in request
return self._request(new_ele("close-session"))
File "/usr/local/lib/python2.7/dist-packages/ncclient/operations/rpc.py", line 338, in _request
raise self._reply.error
ncclient.operations.rpc.RPCError: permission denied
Issue Analytics
- State:
- Created 8 years ago
- Comments:6
Top Results From Across the Web
Handling two different connection closing in a try catch
In my scenario I've two catch and two different closing: close() in the normal case and closeStrange() if a StrangeException is thrown. I...
Read more >Ensuring file handle is closed in case of an exception [closed]
Your situation. Use closes the resource at the end of the block (lambda). This means that the stream is closed before returning it....
Read more >Exception Handling in Java - Baeldung
Learn the basics of exception handling in Java as well as some best and worst practices.
Read more >Getting exception while caling API from httpcleint
Getting exception while caling API from httpcleint. I am writing a windows service which is calling a API after each 60 seconds.
Read more >How to catch all exceptions in Python - Stackify
close()function ensures that the file is closed even if an exception happens during the program execution. Advantages of Exception Handling and ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed with:
.*close-session
under allow-commands