X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bootauth.py;h=3ebe30b13f0b7b18056e52275a1b4825f4906078;hb=48a73b18fd7daed13c645c1adeddb57b560e7a2d;hp=bf845d63ec3b30b2927a093a756513691cd56f1b;hpb=761cada14f2a583c6791d779d68b8a7e5094800d;p=nodemanager.git diff --git a/bootauth.py b/bootauth.py index bf845d6..3ebe30b 100755 --- a/bootauth.py +++ b/bootauth.py @@ -1,13 +1,11 @@ #!/usr/bin/python # -# Test script for obtaining a node session key. Usually, the Boot -# Manager obtains it, then writes it to /etc/planetlab/session. +# Obtaining a node session key. Usually, the Boot +# Manager obtains it, then writes it to /etc/planetlab/session. # # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ -# import os, sys import getopt @@ -23,12 +21,12 @@ def main(): # Help def usage(): - print "Usage: %s [OPTION]..." % sys.argv[0] - print "Options:" - print " -f, --config=FILE PLC configuration file (default: /etc/planetlab/plc_config)" - print " -n, --node-id=FILE Node ID (or file)" - print " -k, --key=FILE Node key (or file)" - print " --help This message" + print("Usage: %s [OPTION]..." % sys.argv[0]) + print("Options:") + print(" -f, --config=FILE PLC configuration file (default: /etc/planetlab/plc_config)") + print(" -n, --node-id=FILE Node ID (or file)") + print(" -k, --key=FILE Node key (or file)") + print(" --help This message") sys.exit(1) # Get options @@ -38,8 +36,8 @@ def main(): "node=", "nodeid=", "node-id", "node_id", "key=", "help"]) - except getopt.GetoptError, err: - print "Error: " + err.msg + except getopt.GetoptError as err: + print("Error: " + err.msg) usage() for (opt, optval) in opts: @@ -47,12 +45,14 @@ def main(): config = Config(optval) elif opt == "-n" or opt == "--node" or opt == "--nodeid" or opt == "--node-id" or opt == "--node_id": if os.path.exists(optval): - node_id = file(optval).read().strip() + with open(optval) as optfile: + node_id = optfile.read().strip() else: node_id = int(optval) elif opt == "-k" or opt == "--key": if os.path.exists(optval): - key = file(optval).read().strip() + with open(optval) as optfile: + key = optfile.read().strip() else: key = optval else: @@ -72,7 +72,7 @@ def main(): plc = PLCAPI(config.plc_api_uri, config.cacert, session) assert session == plc.GetSession() - print session + print(session) if __name__ == '__main__': main()