本文整理汇总了Python中henmanager.HenManager.power方法的典型用法代码示例。如果您正苦于以下问题:Python HenManager.power方法的具体用法?Python HenManager.power怎么用?Python HenManager.power使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类henmanager.HenManager
的用法示例。
在下文中一共展示了HenManager.power方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import power [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 power [as 别名]
###########################################################################################
# Main execution
###########################################################################################
print "Content-Type: text/html"
print ""
print ""
manager = HenManager()
nodes = manager.getNodes("all")
form = cgi.FieldStorage()
if form.has_key("id"):
pass
else:
sys.exit()
nodeid = form["id"].value
for nodeTypeDictionary in nodes.values():
for node in nodeTypeDictionary.values():
if (nodeid == node.getNodeID()):
print "<p>"
print "power status of "
manager.power(nodeid,"status")
print "</p>"
sys.exit()