Commit 0612de16 authored by Gary Wong's avatar Gary Wong

Allow the user to specify their own SSH key file.

parent 77a7a4cf
......@@ -36,6 +36,8 @@ def Usage():
-f file, --certificate=file read SSL certificate from file
[default: ~/.ssl/encrypted.pem]
-h, --help show options and usage
-k keyfile, --keys=keyfile read SSH keys from file
[default: query from SA]
-n name, --slicename=name specify human-readable name of slice
[default: mytestslice]
-p file, --passphrase=file read passphrase from file
......@@ -53,6 +55,19 @@ for arg in sys.argv[:]:
sys.argv.remove( arg )
update = True
# Gah. This case is even uglier, since we need to remove both the
# option and its mandator parameter. Don't bother addressing the
# case where the user specifies -k more than once: they are being silly.
keyfile = ""
for i in range( len( sys.argv ) ):
if sys.argv[ i ] == "-k" or ( len( sys.argv[ i ] ) >= 3 and "--key".find( sys.argv[ i ] ) == 0 ):
if i + 1 >= len( sys.argv ):
Usage()
sys.exit( 1 )
keyfile = sys.argv[ i + 1 ]
sys.argv[ i : i + 2 ] = [];
break
execfile( "test-common.py" )
if len( args ) > 1:
......@@ -84,11 +99,20 @@ print "Got my SA credential"
#
params = {}
params["credential"] = mycredential
rval,response = do_method("sa", "GetKeys", params)
if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
if keyfile == "":
rval,response = do_method("sa", "GetKeys", params)
if rval:
Fatal("Could not get my keys")
pass
mykeys = response["value"]
else:
mykeys = []
f = open( keyfile )
for keyline in f:
if re.match( r"\s*#", keyline ):
continue
mykeys.append( { 'type' : 'ssh', 'key' : keyline } )
f.close()
if debug: print str(mykeys)
#
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment