Changeset 10098 in genesis for tools


Ignore:
Timestamp:
Mar 10, 2012, 9:55:07 PM (13 years ago)
Author:
rick
Message:

Procedure of enabling SNMP seems to work reliable now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/check-batch-cmd

    r10097 r10098  
    88import argparse
    99import gformat
     10import getpass
    1011import netsnmp
    1112import os
     
    1516import time
    1617
    17 try:
    18   SSHPASS = os.environ['SSHPASS']
    19 except KeyError:
    20   SSHPASS = 'SSH_NOT_SET'
    21 
     18SSHPASS = None
    2219netsnmp.verbose = 0
    2320
     
    4946  retval = sess.get(var_list)
    5047  if sess.ErrorInd < 0:
    51     raise CmdError('[%(ErrorInd)s] %(ErrorStr)s (%(DestHost)s)' % vars(sess))
     48    raise CmdError('SNMP Failed -- [%(ErrorInd)s] %(ErrorStr)s (%(DestHost)s)' % vars(sess))
    5249  return filter(None, retval)[0]
    5350
     
    125122  # create the top-level parser
    126123  parser = argparse.ArgumentParser(prog='Various WL management tools')
    127   #parser.add_argument('--foo', action='store_true', help='foo help')
     124  parser.add_argument('--ask-pass', dest="ask_pass", action='store_true', help='Ask password if SSHPASS is not found')
    128125  subparsers = parser.add_subparsers(help='sub-command help')
    129126 
     
    142139  args = parser.parse_args()
    143140
     141  try:
     142    SSHPASS = os.environ['SSHPASS']
     143  except KeyError:
     144    print "#WARN: SSHPASS environ variable not found"
     145    if args.ask_pass:
     146      SSHPASS = getpass.getpass("WL root password: ")
     147
     148
    144149  if args.func == 'keys':
    145150    ubnt_keys(args.host)
Note: See TracChangeset for help on using the changeset viewer.