- try:
- if not config.debug:
- api.AdmUpdateSite(auth, siteid[0], {"max_slices" : maxslices})
- except Exception, exc:
- logger.info("API: %s" % exc)
- else:
- logger.debug("Cant find site for %s. Cannot enable creation." % loginbase)
-
-
-
-USAGE = """
-Usage: %s [-u user] [-p password] [-r role] CMD
-
-Options:
--u PLC account username
--p PLC account password
--r PLC account role
--h This message
-""" % sys.argv[0]
+ if not config.debug:
+ logger.info("\tcalling UpdateSite(%s, enabled=True)" % loginbase)
+ api.UpdateSite(auth.auth, loginbase, {'enabled': True})
+ except Exception, exc:
+ print "ERROR: enableSliceCreation: %s" % exc
+ logger.info("ERROR: enableSliceCreation: %s" % exc)
+
+'''
+Removes ability to create slices. Returns previous max_slices
+'''
+def removeSliceCreation(nodename):
+ api = xmlrpclib.Server(XMLRPC_SERVER, verbose=False)
+ try:
+ loginbase = siteId(nodename)
+ #numslices = api.GetSites(auth.auth, {"login_base": loginbase},
+ # ["max_slices"])[0]['max_slices']
+ logger.info("Removing slice creation for site %s" % loginbase)
+ if not config.debug:
+ #api.UpdateSite(auth.auth, loginbase, {'max_slices': 0})
+ api.UpdateSite(auth.auth, loginbase, {'enabled': False})
+ except Exception, exc:
+ logger.info("removeSliceCreation: %s" % exc)
+
+'''
+QED
+'''
+#def enableSliceCreation(nodename, maxslices):
+# api = xmlrpclib.Server(XMLRPC_SERVER, verbose=False)
+# anon = {'AuthMethod': "anonymous"}
+# siteid = api.AnonAdmQuerySite (anon, {"node_hostname": nodename})
+# if len(siteid) == 1:
+# logger.info("Enabling slice creation for site %s" % siteId(nodename))
+# try:
+# if not config.debug:
+# api.AdmUpdateSite(auth.auth, siteid[0], {"max_slices" : maxslices})
+# except Exception, exc:
+# logger.info("API: %s" % exc)
+# else:
+# logger.debug("Cant find site for %s. Cannot enable creation." % nodename)