本文整理汇总了Python中henmanager.HenManager.powerSilent方法的典型用法代码示例。如果您正苦于以下问题:Python HenManager.powerSilent方法的具体用法?Python HenManager.powerSilent怎么用?Python HenManager.powerSilent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类henmanager.HenManager
的用法示例。
在下文中一共展示了HenManager.powerSilent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import powerSilent [as 别名]
def main():
if len(sys.argv) != 2:
print "FAIL: nodeid not provided!"
return -1
nodeid = sys.argv[1]
hm = HenManager()
if (hm.power(sys.argv[1], "poweroff") < 0):
print "FAIL: hm.power(%s, \"poweroff\") failed (cause unknown)!"\
% nodeid
return -1
time.sleep(2)
(sts, output) = hm.powerSilent(sys.argv[1], "status")
if (sts < 0):
print "FAIL: hm.power(%s, \"status\") returned: %s" % (nodeid, output)
return -1
if (output == "on"):
print "FAIL: hm.power(%s, \"status\") says the node is still on!" \
% nodeid
return -1
if (output == "off"):
print "SUCCESS: hm.power(%s, \"poweroff\") succeeded." % nodeid
return 0
print "FAIL: hm.power(%s, \"status\") returned: %s" % (nodeid, output)
return -1
示例2: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import powerSilent [as 别名]
###########################################################################################
# Make sure that the necessary cgi parameters are given and retrieve them
form = cgi.FieldStorage()
if ((not form) or (not form.has_key("numbernodes")) or (not form.has_key("action"))):
sys.exit()
print "Content-Type: text/xml"
print ""
print ""
print '<experiments>'
manager = HenManager()
action = form["action"].value
numberNodes = form["numbernodes"].value
if (action != "status"):
for i in range(0, int(numberNodes)):
nodeID = form["node" + str(i)].value
manager.powerSilent(nodeID, action)
for i in range(0, int(numberNodes)):
nodeID = form["node" + str(i)].value
(returnCode, status) = manager.powerSilent(nodeID, "status")
if (returnCode != 0):
status = "no powerswitch"
print '\t<node id="' + str(nodeID) + '" status="' + str(status) + '" />'
print '</experiments>'
示例3: __init__
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import powerSilent [as 别名]
#.........这里部分代码省略.........
for right in rights:
if (device in right.getDevices()):
foundDevs.append(device)
if (right.getMaxWeeks() < minRightWeeks):
minRightWeeks = right.getMaxWeeks()
if (set(devices) == set(foundDevs)):
return minRightWeeks
return self.__maxNumWeeks
def __listDirectory(self, devices):
dirListing = ""
for device in devices:
dirListing += str(device)+" :\n"
dirListing += commands.getoutput('find ' + self.__symlinksRoot + device + ' -print ')
dirListing += "\n"
return dirListing
def __clearSymLinks(self, devices):
# temp suspend clearing links , adam 12/08/2008
return
for device in devices:
if not self.__debug:
os.system("rm " + self.__symlinksRoot + device + "/*")
else:
print "would run : rm " + self.__symlinksRoot + device + "/*"
def __poweroff(self, devices):
# temp suspend poweroff , adam 12/08/2008
return
for device in devices:
if not self.__debug:
self.__henManager.powerSilent(device, "poweroff")
else:
print "would turn off "+str(device)
def __sendEmailExpired(self, reservation,dirListing=None):
subject = "Your reservation (id = " + str(reservation.getReservationID()) + ") has expired"
body = "The reservation you had made has expired and has been removed from the system. " + \
"If you still wish to use the devices you had reserved you will have to create a new " + \
"reservation by logging on to hen.cs.ucl.ac.uk and running the command 'hm reservation'."
if dirListing != None:
body += "The directory listings for your machines were :\n"
body += dirListing
if not self.__debug:
smtpClient = SMTPClient(self.__smtpServerName)
smtpClient.sendEmail(reservation.getEmail(), self.__daemonEMail, subject, body)
smtpClient.close()
else:
print "would send email."
print "to :"+str(reservation.getEmail())
print "subject :"+subject
print "via :"+self.__smtpServerName
print "body :"+body
def __findHighestID(self):
highestID = 0
for username in self.__reservations.keys():
userReservations = self.__reservations[username]
for userReservation in userReservations:
if (int(userReservation.getReservationID()) > highestID):
highestID = int(userReservation.getReservationID())
return highestID
def __getNextID(self):
示例4: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import powerSilent [as 别名]
manager = HenManager()
manager.initLogging()
switches = manager.getNodes("switch","all")
switch = None
#switch_node = None
for sw in switches.values():
if sw.getNodeID() == "switch5":
#switch_node = sw
switch = sw.getInstance()
while True:
sn = switch.getSensorReadings()
print sn,
print resource.getrusage(resource.RUSAGE_SELF)[2]
try:
pnodeid = switch.getPowerNodeID()
if (pnodeid == "None" or pnodeid == "none"):
pass
(st,msg) = manager.powerSilent(switch.getNodeID(), "status", \
pnodeid)
print "power status[%S], message[%s]" % (st,msg)
except:
pass
gc.collect()
#print resource.getrusage(resource.RUSAGE_SELF)[3]
time.sleep(1)