Monday, November 4, 2013

Python in Action: ssh paramiko client - first release to github

I have been working on the same codes for almost a week from now. I feel that I am more comfortable with the output and I decided to push it over to github and hope that it could help others system engineer who needed to do the automation with a large group of servers/VMs. You can clone the codes from here.


Here is the output that you will be getting.


hiuy@nasilemak ~/ssh-paramiko-client $ ./pyssh.py
Password:
-- Welcome to ssh paramiko --
ssh > help
Usage - pyssh.py
 addhost      - add host with the comma delimitter
 addhostfile  - add host with a absolute path of a file
 rmhost       - remove host with the comma delimitter
 lshost       - list hosts
 ping         - do a ping test to the added host list
 connect      - establish ssh connection to the added host list
 run          - run a specific command on the connected host
 close        - close the ssh connect to the added host list
 quit         - quit the session

ssh > addhost centos64-1, centos64-2
host added: ['centos64-1', 'centos64-2']
ssh > ping
host centos64-1 PING OK
host centos64-2 PING OK
ssh > connect
Connected host: centos64-1
Connected host: centos64-2
Total connected hosts: 2 out of 2
ssh > run uptime
host: centos64-1
     05:49:07 up  4:24,  1 user,  load average: 0.00, 0.10, 0.10
host: centos64-2
     05:49:07 up  4:25,  1 user,  load average: 0.00, 0.00, 0.00
ssh > run uname -a
host: centos64-1
    Linux localhost.localdomain 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
host: centos64-2
    Linux localhost.localdomain 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
ssh > run rpm -qa | grep kernel
host: centos64-1
    kernel-devel-2.6.32-358.el6.x86_64
    kernel-headers-2.6.32-358.23.2.el6.x86_64
    abrt-addon-kerneloops-2.0.8-16.el6.centos.1.x86_64
    dracut-kernel-004-303.el6.noarch
    libreport-plugin-kerneloops-2.0.9-15.el6.centos.1.x86_64
    kernel-firmware-2.6.32-358.23.2.el6.noarch
    kernel-devel-2.6.32-358.23.2.el6.x86_64
    kernel-2.6.32-358.el6.x86_64
    kernel-2.6.32-358.23.2.el6.x86_64
host: centos64-2
    kernel-devel-2.6.32-358.el6.x86_64
    kernel-headers-2.6.32-358.23.2.el6.x86_64
    abrt-addon-kerneloops-2.0.8-16.el6.centos.1.x86_64
    dracut-kernel-004-303.el6.noarch
    libreport-plugin-kerneloops-2.0.9-15.el6.centos.1.x86_64
    kernel-firmware-2.6.32-358.23.2.el6.noarch
    kernel-devel-2.6.32-358.23.2.el6.x86_64
    kernel-2.6.32-358.el6.x86_64
    kernel-2.6.32-358.23.2.el6.x86_64
ssh > close
ssh > quit
hiuy@nasilemak ~/ssh-paramiko-client $


If you are keen to develop and contribute to this codes, please drop me an email, and we can work it out together. All of the new ideas are mostly welcome. Thanks.

No comments: