- newexp = int(time.mktime(time.strptime(newexp,"%B %d %Y")))
- except ValueError, e:
- errormsg = """Expecting date to be in Month Day Year
- e.g., April 7 2007
- new expiration date provided %s""" % newexp
- printUsage(errormsg)
- sys.exit(1)
-
- slices = api.GetSlices(auth)
- for slice in slices:
- name = slice['name']
- exp = int(slice['expires'])
- olddate = time.asctime(time.localtime(exp))
- slice_attributes = api.GetSliceAttributes(auth,slice['slice_attribute_ids'])
- for slice_attribute in slice_attributes:
- if slice_attribute['name'] == "enabled":
- print "%s is suspended" % name
- if exp < newexp:
- newdate = time.asctime(time.localtime(newexp))
- ret = api.SliceRenew(auth,name,newexp)
- if ret == 0:
- print "failed to renew %s" %name
-
-def nodeBootState(argv):
- """Sets boot state of a node."""
-
- global api, auth
- if len(argv) < 1:
- printUsage("not enough arguments")
- sys.exit(1)
-
- if len(argv) >=1:
- nodename = argv[0]
- if len(argv) >=2:
- state = argv[1]
-
- if auth is None:
- printUsage("requires admin privs")
- sys.exit(1)
-
- node = api.GetNodes(auth, [nodename], ['node_id','boot_state'])
- if len(node) == 1:
- node = node[0]
- try:
- logger.info("%s boot_state=%s" %(nodename, node['boot_state']))
- if len(argv) >=2 and not config.debug:
- logger.info("Setting node %s boot_state=%s" %(nodename, state))
- node_id = node['node_id']
- api.UpdateNode(auth, node_id, {'boot_state': state})
- except Exception, exc:
- logger.info("nodeBootState: %s" % exc)
- else:
- logger.info("Cant find node %s to toggle boot state" % nodename)
-
-
-def nodePOD(argv):
- """Sends Ping Of Death to node."""
-
- global api, auth
- if len(argv) < 1:
- printUsage("not enough arguments")
- sys.exit(1)
-
- nodename = argv[0]
- if auth is None:
- printUsage("requires admin privs")
- sys.exit(1)
-
- node = api.GetNodes(auth, [nodename], ['node_id'])
- if len(node) == 1:
- node = node[0]
- logger.info("Sending POD to %s" % nodename)
- try:
- if not config.debug:
- api.RebootNode(auth, node['node_id'])
- except Exception, exc:
+ return api.UpdateNode(auth.auth, nodename, {'key': key})
+ except Exception, exc:
+ logger.info("updateNodeKey: %s" % exc)
+
+'''
+Sends Ping Of Death to node.
+'''
+def nodePOD(nodename):
+ api = xmlrpclib.Server(auth.server, verbose=False)
+ logger.info("Sending POD to %s" % nodename)
+ try:
+ if not debug:
+ return api.RebootNode(auth.auth, nodename)
+ except Exception, exc: