Juniper / py-junos-netconify

Junos console/bootstrap automation Python module
Apache License 2.0
67 stars 30 forks source link

ssh support #30

Open mhite opened 9 years ago

mhite commented 9 years ago

Would be great if netconify could initiate connections to a console server via ssh rather than just telnet. Our entire console server infrastructure relies on ssh to reach console ports rather than telnet.

Thanks for your consideration.

r2600r commented 9 years ago

I just added the ssh support. It is in first stages and needs little finishing touches and then I'll request merge to this official library. For time being, you can pull mine on you own risk.

pbk@pbk-mbp15 [~]netconify --facts -s "146.180.226.36,4011,," -u test-user --passwd "pasword1" CMD:TTY:login:connecting to TTY:146.180.226.36:4011:test-user:password1 ... CMD:TTY:login:logging to device ... CMD:TTY:login: OK ... starting NETCONF CMD:facts:retrieving device facts... CMD:facts:saving: ./cfwj-lab1-0011a-facts.json CMD:inventory:saving: ./cfwj-lab1-0011a-inventory.xml CMD:TTY:logout:logging out ...

I omitted ssh console user and pass, since they're same for device authentication, but if they are different, you can specify them.

pbk@pbk-mbp15 [~]netconify --facts -s "146.180.226.36,4011,console-user,console-password" -u test-user --passwd "pasword1" CMD:TTY:login:connecting to TTY:146.180.226.36:4011:console-user:console-password ... CMD:TTY:login:logging to device ...

tomehb commented 8 years ago

r2600,, I get the following:

`MAC:~$netconify --facts --ssh=10.0.0.8,3020,terminalUsername,terminalPassword -u username --passwd "junosPassword?" TTY:connecting to TTY:10.0.0.8:3020: terminalUsername: terminalPassword ... TTY:logging in ... ERROR:login:global name 'time' is not defined

Traceback (most recent call last): File "/usr/local/bin/netconify", line 7, in results = nc.run() File "/usr/local/lib/python2.7/site-packages/netconify/cmdo.py", line 253, in run self._hook_exception('login', err) File "/usr/local/lib/python2.7/site-packages/netconify/cmdo.py", line 251, in run self._tty_login() File "/usr/local/lib/python2.7/site-packages/netconify/cmdo.py", line 337, in _tty_login self._tty.login(notify=notify) File "/usr/local/lib/python2.7/site-packages/netconify/tty.py", line 109, in login self._login_state_machine() File "/usr/local/lib/python2.7/site-packages/netconify/tty.py", line 166, in _login_state_machine prompt, found = self.read_prompt() File "/usr/local/lib/python2.7/site-packages/netconify/tty_ssh.py", line 97, in read_prompt delta = time.time() - start NameError: global name 'time' is not defined

`

jeffbrl commented 8 years ago

I noted some problems with tty_ssh.py in issue #50. Trying cloning my fork.

sudo pip install git+https://github.com/jeffbrl/py-junos-netconify.git@issue-50-fix

gsram369 commented 8 years ago

jeffbri i tried cloning your fork unfortunately it didnt work

jeffbrl commented 8 years ago

Not sure what error you encountered. Try cloning my fork with 'git clone' and then switching to the issue-50-fix branch. Run 'python setup.py install'.

r2600r commented 8 years ago

Jeff, The issue with #50 is purely decorative, allot does is negate timeout that wasn't in netconify before and was added to actually timeout. Thanks for noticing calling incorrect variable but this simple loop can be done 100 different ways to achieve same result. It was written quickly to satisfy customer request. I'll pick up work on netconify this summer and add more features users require.