X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=bootauth.py;h=5c9dfa778356ddc1df8b5595fe5dd1fa36fb3a48;hb=570d234b7d7b40416b296de71225f28c826ee991;hp=44f9a8f85b56e022e7dfc774f390035bb132c0db;hpb=9593742301848f6a3e5d95efe7e52071d0f3b4d5;p=nodemanager.git diff --git a/bootauth.py b/bootauth.py index 44f9a8f..5c9dfa7 100755 --- a/bootauth.py +++ b/bootauth.py @@ -1,16 +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. To -# generate a node key for a node, execute: -# -# AdmGenerateNodeConfFile(node_id) +# 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: bootauth.py,v 1.1 2006/10/31 23:19:28 mlhuang Exp $ -# import os, sys import getopt @@ -36,8 +31,9 @@ def main(): # Get options try: - (opts, argv) = getopt.getopt(sys.argv[1:], "n:k:h", - ["node=", "nodeid=", "node-id", "node_id", + (opts, argv) = getopt.getopt(sys.argv[1:], "f:n:k:h", + ["config=", "cfg=", "file=", + "node=", "nodeid=", "node-id", "node_id", "key=", "help"]) except getopt.GetoptError, err: @@ -49,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: