2

I have been trying to use JunOS pyEZ to provision SRX which needs serial connection for initial configuration. Using the below mentioned code throws I/O exception:

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

......
logging.basicConfig(level=logging.INFO)
dev = Device(user='root', passwd='*****', mode='serial', port='COM4', gather_facts=True)
print(dev.facts)
cu = Config(dev)
cu.load('set system host-name test', format='set', ignore_warning=True)
cu.commit()
.....

Exception:

INFO:jnpr.junos.tty:TTY: connecting to TTY:COM4 ...
INFO:jnpr.junos.tty:TTY: logging in......
INFO:jnpr.junos.tty:TTY: OK.....starting NETCONF
ERROR:jnpr.junos.console:Exception occurred: login:fileno

Traceback (most recent call last):
File "c:/Users/################", line 208, in
main()
File "c:/Users/################", line 178, in main
with Device(user='root', passwd='*******', mode='serial', port='COM4', gather_facts=True, console_has_banner=True) as dev:
File "C:\Python37\lib\site-packages\jnpr\junos\console.py", line 336, in enter
self._conn = self.open()
File "C:\Python37\lib\site-packages\jnpr\junos\console.py", line 222, in open
raise ex
File "C:\Python37\lib\site-packages\jnpr\junos\console.py", line 212, in open
self._tty_login()
File "C:\Python37\lib\site-packages\jnpr\junos\console.py", line 319, in _tty_login
self._tty.login()
File "C:\Python37\lib\site-packages\jnpr\junos\transport\tty.py", line 116, in login
self.nc.open(at_shell=self.at_shell)
File "C:\Python37\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 68, in open
self.hello = self._receive()
File "C:\Python37\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 142, in _receive
raise err
File "C:\Python37\lib\site-packages\jnpr\junos\transport\tty_netconf.py", line 140, in _receive
rd, wt, err = select.select([self._tty._rx], [], [], 0.1)
io.UnsupportedOperation: fileno

Using open() with the above mentioned code gives the same errors. Running a similar code with SSH connection works fine. Running it in WSL gives the same errors. P.S.: Running it on Windows 10 with Python3.7

shivintwrk
  • 21
  • 1

0 Answers0