diff --git a/confluent_client/bin/nodehealth b/confluent_client/bin/nodehealth index affafc8e..201eb236 100755 --- a/confluent_client/bin/nodehealth +++ b/confluent_client/bin/nodehealth @@ -28,7 +28,11 @@ import confluent.client as client sys.stdout = codecs.getwriter('utf8')(sys.stdout) -noderange = sys.argv[1] +try: + noderange = sys.argv[1] +except IndexError: + sys.stderr.write('Usage: {0} \n'.format(sys.argv[0])) + sys.exit(1) session = client.Command() exitcode = 0 @@ -53,9 +57,11 @@ for health in session.read('/noderange/{0}/health/hardware'.format(noderange)): for sensor in health[node]['sensors']: explanation = sensor['name'] + ':' if sensor['value'] is not None: - explanation += sensor['value'] + explanation += str(sensor['value']) if sensor['units'] is not None: explanation += sensor['units'] + if sensor['states']: + explanation += ',' if sensor['states']: explanation += ','.join(sensor['states']) healthexplanations[node].append(explanation) diff --git a/confluent_client/bin/nodeidentify b/confluent_client/bin/nodeidentify index f8992b32..956827ce 100755 --- a/confluent_client/bin/nodeidentify +++ b/confluent_client/bin/nodeidentify @@ -25,8 +25,12 @@ if path.startswith('/opt'): import confluent.client as client +try: + noderange = sys.argv[1] +except IndexError: + sys.stderr.write('Usage: {0} [on|off]\n'.format(sys.argv[0])) + sys.exit(1) -noderange = sys.argv[1] identifystate = None if len(sys.argv) > 2: identifystate = sys.argv[2] diff --git a/confluent_client/bin/nodepower b/confluent_client/bin/nodepower index a9c3cceb..7dbb8722 100755 --- a/confluent_client/bin/nodepower +++ b/confluent_client/bin/nodepower @@ -26,7 +26,14 @@ if path.startswith('/opt'): import confluent.client as client -noderange = sys.argv[1] +try: + noderange = sys.argv[1] +except IndexError: + sys.stderr.write( + 'Usage: {0} ([status|on|off|shutdown|boot|reset]\n'.format( + sys.argv[0])) + sys.exit(1) + setstate = None if len(sys.argv) > 2: if setstate == 'softoff': diff --git a/confluent_client/bin/nodesensors b/confluent_client/bin/nodesensors index 377d0d89..590321c6 100755 --- a/confluent_client/bin/nodesensors +++ b/confluent_client/bin/nodesensors @@ -54,8 +54,11 @@ if options.numreadings: repeatmode = options.numreadings if options.interval is None: options.interval = 1 - -noderange = args[0] +try: + noderange = args[0] +except IndexError: + argparser.print_usage() + sys.exit(1) sensors = [] for sensorgroup in args[1:]: for sensor in sensorgroup.split(','): diff --git a/confluent_client/bin/nodesetboot b/confluent_client/bin/nodesetboot index 5a770e60..48252047 100755 --- a/confluent_client/bin/nodesetboot +++ b/confluent_client/bin/nodesetboot @@ -26,10 +26,18 @@ if path.startswith('/opt'): import confluent.client as client -noderange = sys.argv[1] +try: + noderange = sys.argv[1] +except IndexError: + sys.stderr.write( + 'Usage: {0} [default|cd|network|setup|hd]\n'.format( + sys.argv[0])) + sys.exit(1) bootdev = None if len(sys.argv) > 2: bootdev = sys.argv[2] + if bootdev in ('net', 'pxe'): + bootdev = 'network' session = client.Command() exitcode = 0 sys.exit( diff --git a/confluent_client/confluent/client.py b/confluent_client/confluent/client.py index d4d0593e..82f1512a 100644 --- a/confluent_client/confluent/client.py +++ b/confluent_client/confluent/client.py @@ -43,7 +43,7 @@ def _parseserver(string): class Command(object): - def __init__(self, server="/var/run/confluent/api.sock"): + def __init__(self, server=None): self.connection = None if server is None: if 'CONFLUENT_HOST' in os.environ: @@ -62,6 +62,10 @@ class Command(object): self.authenticated = True else: self.authenticated = False + if not self.authenticated and 'CONFLUENT_USER' in os.environ: + username = os.environ['CONFLUENT_USER'] + passphrase = os.environ['CONFLUENT_PASSPHRASE'] + self.authenticate(username, passphrase) def authenticate(self, username, password): tlvdata.send(self.connection,