当前位置: 首页>>代码示例>>Python>>正文


Python HenManager.powerSilent方法代码示例

本文整理汇总了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
开发者ID:benroeder,项目名称:HEN,代码行数:27,代码来源:emergencypowerdown.py

示例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>'
开发者ID:benroeder,项目名称:HEN,代码行数:32,代码来源:powercgi.py

示例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):
开发者ID:benroeder,项目名称:HEN,代码行数:70,代码来源:reservationdaemon.py

示例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)    
    
    
开发者ID:benroeder,项目名称:HEN,代码行数:30,代码来源:memory_leak_check.py


注:本文中的henmanager.HenManager.powerSilent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。