Changeset 10092 in genesis for tools


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

Better output processing and variable checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/check-batch-cmd

    r10089 r10092  
    4141  retval = sess.get(var_list)
    4242  if sess.ErrorInd < 0:
    43     raise CmdError('[%(ErrorInd)s] %(ErrorStr)s' % vars(sess))
     43    raise CmdError('[%(ErrorInd)s] %(ErrorStr)s (%(DestHost)s)' % vars(sess))
    4444  return filter(None, retval)[0]
    4545
    4646
    4747
    48 def main():
     48def main(hostfilter=None):
    4949  for host in gformat.get_hostlist():
     50    if hostfilter and not hostfilter in host:
     51      continue
    5052    print "# Processing host", host
    5153    datadump = gformat.get_yaml(host)
    5254    for iface_key in datadump['autogen_iface_keys']:
    5355      ifacedump = datadump[iface_key]
    54       if ifacedump.has_key('ns_ip'):
     56      if ifacedump.has_key('ns_ip') and ifacedump['ns_ip']:
    5557        addr = ifacedump['ns_ip'].split('/')[0]
    5658        print "## Bridge IP: %s" % addr
     
    5961          bridge_type = get_bridge_type(addr)
    6062          datadump[iface_key]['bridge_type'] = bridge_type
    61         except (socket.timeout, socket.error):
    62           print "### Conection failed"
     63        except (socket.timeout, socket.error) as e:
     64          print "### %s (%s)" % (e, addr)
    6365        except paramiko.AuthenticationException:
    6466          print "### Conection failed (invalid username/password)"
     
    6971
    7072if __name__ == '__main__':
    71   if sys.argv[1:]:
    72     for host in sys.argv[1:]:
    73       print get_bridge_type(host)
     73  if len(sys.argv) == 2:
     74    main(hostfilter=sys.argv[1])
    7475  else:
    7576    main()
Note: See TracChangeset for help on using the changeset viewer.