Changeset 10075 in genesis
- Timestamp:
- Mar 10, 2012, 1:16:22 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/check-batch-cmd
r10074 r10075 14 14 pass 15 15 16 try:17 raise CmdError("rick")18 except (socket.timeout, socket.error):19 print "### Conection failed"20 except paramiko.AuthenticationException:21 print "### Conection failed (invalid username/password)"22 except CmdError, e:23 print "### Command error: %s" % e24 25 16 def check_host(hostname): 26 17 cmd = "cat /etc/board.info" … … 28 19 ssh = paramiko.SSHClient() 29 20 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 30 ssh.connect(hostname, username='root', password=' p2nn3nk03k',timeout=3)21 ssh.connect(hostname, username='root', password='XXXXXXXXXX',timeout=3) 31 22 stdin, stdout, stderr = ssh.exec_command(cmd) 32 23 stdout = stdout.readlines() … … 37 28 38 29 return dict(map(lambda x: x.strip().split('='),stdout)) 30 31 def get_bridge_type(host): 32 import netsnmp 33 netsnmp.verbose = 0 34 var_list = netsnmp.VarList(netsnmp.Varbind('.1.2.840.10036.3.1.2.1.3.6')) 35 36 sess = netsnmp.Session(Version=1, DestHost=host, Community='public', Timeout=2 * 100000, Retries=0) 37 retval = sess.get(var_list) 38 if sess.ErrorInd < 0: 39 raise CmdError('[%(ErrorInd)s] %(ErrorStr)s' % vars(sess)) 40 return retval[0] 39 41 40 42 … … 50 52 try: 51 53 socket.create_connection((addr,80),2) 52 d = check_host(addr)53 datadump[iface_key]['bridge_type'] = d['board.name']54 bridge_type = get_bridge_type(addr) 55 datadump[iface_key]['bridge_type'] = bridge_type 54 56 except (socket.timeout, socket.error): 55 57 print "### Conection failed"
Note:
See TracChangeset
for help on using the changeset viewer.