git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9a3af0c
)
- add -s, --session option to specify session key
author
Mark Huang
<mlhuang@cs.princeton.edu>
Fri, 2 Feb 2007 04:39:03 +0000
(
04:39
+0000)
committer
Mark Huang
<mlhuang@cs.princeton.edu>
Fri, 2 Feb 2007 04:39:03 +0000
(
04:39
+0000)
plcsh
patch
|
blob
|
history
diff --git
a/plcsh
b/plcsh
index
605877c
..
936b943
100755
(executable)
--- a/
plcsh
+++ b/
plcsh
@@
-5,11
+5,12
@@
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2005 The Trustees of Princeton University
#
# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2005 The Trustees of Princeton University
#
-# $Id: plcsh,v 1.
3 2007/01/11 20:45:29
mlhuang Exp $
+# $Id: plcsh,v 1.
4 2007/01/17 22:14:38
mlhuang Exp $
#
import os
import sys
#
import os
import sys
+from socket import gethostname
from optparse import OptionParser
from getpass import getpass
from traceback import print_exc
from optparse import OptionParser
from getpass import getpass
from traceback import print_exc
@@
-22,6
+23,7
@@
parser.add_option("-f", "--config", help = "PLC configuration file")
parser.add_option("-h", "--url", help = "API URL")
parser.add_option("-c", "--cacert", help = "API SSL certificate")
parser.add_option("-m", "--method", help = "API authentication method")
parser.add_option("-h", "--url", help = "API URL")
parser.add_option("-c", "--cacert", help = "API SSL certificate")
parser.add_option("-m", "--method", help = "API authentication method")
+parser.add_option("-s", "--session", help = "API session key")
parser.add_option("-u", "--user", help = "API user name")
parser.add_option("-p", "--password", help = "API password")
parser.add_option("-r", "--role", help = "API role")
parser.add_option("-u", "--user", help = "API user name")
parser.add_option("-p", "--password", help = "API password")
parser.add_option("-r", "--role", help = "API role")
@@
-44,7
+46,8
@@
try:
config = options.config,
url = options.url, xmlrpc = options.xmlrpc, cacert = options.cacert,
method = options.method, role = options.role,
config = options.config,
url = options.url, xmlrpc = options.xmlrpc, cacert = options.cacert,
method = options.method, role = options.role,
- user = options.user, password = options.password)
+ user = options.user, password = options.password,
+ session = options.session)
# Register a few more globals for backward compatibility
auth = shell.auth
api = shell.api
# Register a few more globals for backward compatibility
auth = shell.auth
api = shell.api
@@
-69,6
+72,11
@@
else:
elif shell.auth['AuthMethod'] == "anonymous":
prompt = "[anonymous]"
print "Connected anonymously"
elif shell.auth['AuthMethod'] == "anonymous":
prompt = "[anonymous]"
print "Connected anonymously"
+ elif shell.auth['AuthMethod'] == "session":
+ # XXX No way to tell node and user sessions apart from the
+ # client point of view.
+ prompt = "[%s]" % gethostname()
+ print "%s connected using session authentication" % gethostname()
else:
prompt = "[%s]" % shell.auth['Username']
print "%s connected using %s authentication" % \
else:
prompt = "[%s]" % shell.auth['Username']
print "%s connected using %s authentication" % \