Juniper/py-junos-netconify

No such file or directory?

Closed this issue · 4 comments

Hey there, excited to try out this tool, but I seem to be missing something.. any insight?

trusty ~ % uname -a
Linux trusty 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

trusty ~ % python --version
Python 2.7.6

trusty ~ % sudo pip install -U junos-netconify
Requirement already up-to-date: junos-netconify in /usr/local/lib/python2.7/dist-packages
Requirement already up-to-date: pyserial in /usr/local/lib/python2.7/dist-packages (from junos-netconify)
Requirement already up-to-date: lxml in /usr/local/lib/python2.7/dist-packages (from junos-netconify)
Cleaning up...

trusty ~ % locate netconify
/usr/local/bin/netconify

trusty ~ %netconify -/dev/ttyUSB0 -b 9600 -f host.conf
: No such file or directory

trusty ~ % ls | grep host
host.conf

I'm thinking this error is being thrown prior to the script actually executing.

Can you try: netconfiy --help and see if it prints the help message?

Thanks for the reply. Seems you're right..

trusty ~ % netconify --help
: No such file or directory

Ahh I think I got it. So, running it as python directly from the directory lets the command run properly it seems..
trusty ~ % which netconify
/usr/local/bin/netconify
trusty ~ % python /usr/local/bin/netconify
TTY:login:connecting to TTY:/dev/ttyUSB0 ...
ERROR:open_failed:Permission denied

Traceback (most recent call last):
File "/usr/local/bin/netconify", line 6, in
results = nc.run()
File "/usr/local/lib/python2.7/dist-packages/netconify/cmdo.py", line 225, in run
self._hook_exception('login', err)
File "/usr/local/lib/python2.7/dist-packages/netconify/cmdo.py", line 223, in run
self._tty_login()
File "/usr/local/lib/python2.7/dist-packages/netconify/cmdo.py", line 301, in _tty_login
self._tty.login(notify=notify)
File "/usr/local/lib/python2.7/dist-packages/netconify/tty.py", line 97, in login
self._tty_open()
File "/usr/local/lib/python2.7/dist-packages/netconify/tty_serial.py", line 45, in _tty_open
raise RuntimeError("open_failed:{0}".format(err.strerror))
RuntimeError: open_failed:Permission denied

trusty ~ % python /usr/local/bin/netconify -help
usage: netconify [-h] [--version] [-f JUNOS_CONF_FILE] [--merge] [--qfx-node]
[--qfx-switch] [--zeroize] [--shutdown {poweroff,reboot}]
[--facts] [--srx_cluster REQUEST_SRX_CLUSTER]
[--srx_cluster_disable] [-S [SAVEDIR]] [--no-save] [-p PORT]
[-b BAUD] [-t TELNET] [--timeout TIMEOUT] [-u USER]
[-P PASSWD] [-k] [-a ATTEMPTS]
[name]
netconify: error: argument -h/--help: ignored explicit argument 'elp'

trusty ~ % sudo python /usr/local/bin/netconify
TTY:login:connecting to TTY:/dev/ttyUSB0 ...
TTY:login:logging in ...

sudo works.. maybe netconify bin not finding python..?

trusty ~ % cat /usr/local/bin/netconify
#!/usr/bin/env python2.7
import sys
from netconify.cmdo import *
nc = netconifyCmdo()
results = nc.run()
if results['failed'] is True:
print results['errmsg']
sys.exit(1)
trusty ~ % which python
/usr/bin/python
trusty ~ % which python2.7
/usr/bin/python2.7

Any suggestions? Did I break somthing in the install maybe?

Thanks again

You didn't break anything. That file should have standard #!/usr/bin/python.

Try changing that and post back.

This library had a different focus prior to release. It now is primarily focused on use with our Ansible modules.

@shermdog that did it! Thanks for the tip. All is well now (closing issue :) )

trusty ~ % cat /usr/local/bin/netconify
#!/usr/bin/python

import sys
from netconify.cmdo import *

nc = netconifyCmdo()
results = nc.run()

if results['failed'] is True:
print results['errmsg']
sys.exit(1)

trusty ~ % sudo netconify
TTY:login:connecting to TTY:/dev/ttyUSB0 ...
TTY:login:logging in ...