From defcd6524e34a69454d017cf599e56cdb3125c5b Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Thu, 22 Feb 2007 17:09:33 +0000 Subject: [PATCH] - set API URL to www.planet-lab.org - add authCheck method --- plc.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/plc.py b/plc.py index 4f7894c..c2b22b7 100644 --- a/plc.py +++ b/plc.py @@ -5,7 +5,7 @@ # Faiyaz Ahmed # Copyright (C) 2006, 2007 The Trustees of Princeton University # -# $Id: plc.py,v 1.10 2007/02/12 19:59:00 mef Exp $ +# $Id: plc.py,v 1.11 2007/02/19 17:42:21 mef Exp $ # from emailTxt import * @@ -17,7 +17,7 @@ import getpass, getopt import sys logger = logging.getLogger("monitor") -XMLRPC_SERVER = 'https://www2.planet-lab.org/PLCAPI/' +XMLRPC_SERVER = 'https://www.planet-lab.org/PLCAPI/' api = xmlrpclib.Server(XMLRPC_SERVER, verbose=False, allow_none = True) auth = None @@ -284,6 +284,30 @@ def setSliceMax(argv): logger.info("_SetSliceMax: %s" % exc) +def authCheck(arg): + """Enable suspended slice.""" + global api, auth + if auth is None: + printUsage("requires admin privs") + sys.exit(1) + + if len(arg) != 2: + printUsage("incorrect arguments") + sys.exit(1) + user= arg[0] + pwd = arg[1] + + check = {} + check['Username'] = user + check['AuthMethod'] = "password" + check['AuthString'] = pwd + for role in ['user','tech','pi','admin']: + check['Role'] = role + res = api.AdmAuthCheck(check) + print "%s -> %s %d" % (user,role,res) + + + USAGE = """ Usage: %s [-u user] [-p password] [-r role] CMD @@ -367,6 +391,7 @@ funclist = (("nodesDbg",nodesDbg), ("freezeSlices", suspendSlices), ("unfreezeSlices", enableSlices), ("setSliceMax", setSliceMax), + ("authCheck", authCheck), ("renewAllSlices", renewAllSlices)) functbl = {} -- 2.43.0