Changeset 10075 in genesis


Ignore:
Timestamp:
Mar 10, 2012, 1:16:22 PM (13 years ago)
Author:
rick
Message:

Whoops, time to change the password I guess..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/check-batch-cmd

    r10074 r10075  
    1414  pass
    1515
    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" % e
    24 
    2516def check_host(hostname):
    2617  cmd = "cat /etc/board.info"
     
    2819  ssh = paramiko.SSHClient()
    2920  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)
    3122  stdin, stdout, stderr = ssh.exec_command(cmd)
    3223  stdout = stdout.readlines()
     
    3728 
    3829  return dict(map(lambda x: x.strip().split('='),stdout))
     30
     31def 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]
    3941
    4042
     
    5052        try:
    5153          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
    5456        except (socket.timeout, socket.error):
    5557          print "### Conection failed"
Note: See TracChangeset for help on using the changeset viewer.