當前位置: 首頁>>代碼示例>>Python>>正文


Python henmanager.HenManager類代碼示例

本文整理匯總了Python中henmanager.HenManager的典型用法代碼示例。如果您正苦於以下問題:Python HenManager類的具體用法?Python HenManager怎麽用?Python HenManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HenManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

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,代碼行數:25,代碼來源:emergencypowerdown.py

示例2: interfaceid_to_mac

def interfaceid_to_mac(node_str,interface_str):
    manager = HenManager()
    manager.initLogging()
    nodes = manager.getNodes("all","all")
    for nt in nodes:
        for nn in nodes[nt]:
            if nodes[nt][nn].getNodeID().upper() == str(node_str).upper():
                mac = getmac_from_interface(nodes[nt][nn],interface_str)
                return mac
    return None
開發者ID:benroeder,項目名稱:HEN,代碼行數:10,代碼來源:interfaceid_to_mac.py

示例3: writeDHCPConfig

    def writeDHCPConfig(self):
        """\brief Writes the dhcp config file
        """
        dnsServer = self.getDHCPConfigInfo().getDomainNameServers()
        self.__outputFile = open(self.__outputFilename, "w")
        manager = HenManager()
        nodes = manager.getNodes("all","all")
#        if (not self.__parser):
#            print "error: parser is null"
#            return
#        self.__parser.parseAll()
#        nodes = self.__parser.getNodes("all", "all")

        # write initial block
	self.__writeStartingBlock()

        # process each subnet
        subnetInfoList = self.getDHCPConfigInfo().getSubnetInfoList()
        
        for subnetInfo in subnetInfoList:
            
            self.__writeSubnetBlock(subnetInfo)
            if (subnetInfo.getSubnetType() == "experimental"):
                for nodeType in nodes.keys():
                    for node in nodes[nodeType].values():
                        interfacesList = node.getInterfaces("management")
                        if (interfacesList != None):
                            for interface in interfacesList:
                                self.__writeNode(node.getNodeID(), interface, node.getNetbootable(), dnsServer, node.getNodeType(), subnetInfo.getDomainName())
            elif (subnetInfo.getSubnetType() == "infrastructure"):
                for nodeType in nodes.keys():
                    for node in nodes[nodeType].values():
                        interfacesList = node.getInterfaces("infrastructure")
                        if (interfacesList != None):
                            for interface in interfacesList:
                                self.__writeNode(node.getNodeID(), interface, node.getNetbootable(), dnsServer, node.getNodeType(), subnetInfo.getDomainName())
            elif (subnetInfo.getSubnetType() == "virtual"):
                for nodeType in nodes.keys():
                    for node in nodes[nodeType].values():
                        interfacesList = node.getInterfaces("virtual")
                        
                        if (interfacesList != None):
                            for interface in interfacesList:
                                self.__writeNode(node.getNodeID(), interface, node.getNetbootable(), dnsServer, node.getNodeType(), subnetInfo.getDomainName())

            self.__writeEndingBlock()

        self. __closeFile()
        return 0
開發者ID:benroeder,項目名稱:HEN,代碼行數:49,代碼來源:dhcp.py

示例4: __init__

class FileNodeManager:

    def __init__(self):
        self.__manager = HenManager()

    def fileNodeCreate(self, fileNodeType, owner, path, architecture, osType, version, mustClone, description, attributes, username, password):

        return self.__manager.fileNodeCreate(fileNodeType, owner, path, architecture, osType, version, mustClone, description, attributes, username, password)
    
    def elementEdit(self, elementID, parameters, attributes):
        return self.__manager. elementEdit(elementID, parameters, attributes)

    def elementDelete(self, elementID):
        # Send a non-manager delete command
        return self.__manager.elementDelete(elementID, False)
開發者ID:benroeder,項目名稱:HEN,代碼行數:15,代碼來源:filed.py

示例5: check_port

def check_port(computer_str,interface_str):
	print computer_str,interface_str,
	switch_str = ""
        port_str = ""

        computer = None
        interface = None
        switch = None
        port = None

        switch_obj = None
        
        manager = HenManager()
        manager.initLogging()
        nodes = manager.getNodes("all")
        
        for node_type in nodes:
            for node in nodes[node_type]:
                if nodes[node_type][node].getNodeID() == computer_str:
                    computer = nodes[node_type][node]
                    break
                
        if computer != None:
            interfaces = computer.getInterfaces()
            for interface_type in interfaces:
                for iface in interfaces[interface_type]:
                    if iface.getInterfaceID() == interface_str:
                        switch_str = iface.getSwitch()
                        port_str = iface.getPort()

        for node_type in nodes:
            for node in nodes[node_type]:
                #print node,switch_str
                if nodes[node_type][node].getNodeID() == switch_str:
                    switch = nodes[node_type][node]
                    break

        if switch != None:
            switch_obj = switch.getInstance()
        
        if switch_obj != None:
	   port_internal_id = switch_obj.getPortInternalID(port_str)
           if (switch_obj.getPortStatus(port_str) == 1):
	      print "up",
	   else:
	      print "down"
	   #print switch_obj.getPortsSpeedByInternalID([port_internal_id])[0][1]
	   print switch_obj.getPortTdr(port_str)
開發者ID:benroeder,項目名稱:HEN,代碼行數:48,代碼來源:check_port.py

示例6: __init__

class ConfigManager:

    def __init__(self):
        self.__manager = HenManager()

    def writeConfigFileLines(self, lines):
        return self.__manager.writeConfigFileLines(lines)
開發者ID:benroeder,項目名稱:HEN,代碼行數:7,代碼來源:configd.py

示例7: __init__

 def __init__(self):
     Daemon.__init__(self)
     self.__hen_manager = HenManager()
     self.__hen_manager.initLogging()
     self.__hardware_processor = LSHardwareProcessor(self.__hen_manager, \
                                                 self.__parseMacTableURL())
     self.__registerMethods()
開發者ID:benroeder,項目名稱:HEN,代碼行數:7,代碼來源:autodetectdaemon.py

示例8: __init__

 def __init__(self, filename, rightsFilename, notificationsFilename, dbsRoot, maxNumWeeks=2,debug=False):
     self.__daemonEMail = "[email protected]"        
     self.__filename = filename
     self.__rightsFilename = rightsFilename
     self.__notificationsFilename = notificationsFilename
     self.__notifications = {}        
     self.__dbsRoot = dbsRoot
     self.__maxNumWeeks = maxNumWeeks
     self.__reservations = {}
     self.__rights = {}
     self.__nextID = 0
     self.__xmldoc = None
     self.__rightsXmldoc = None
     self.__henManager = HenManager()
     self.__symlinksRoot = "/export/machines/"
     self.__smtpServerName = "smtp.cs.ucl.ac.uk"
     self.__parser = ReservationDBParser(filename, rightsFilename, notificationsFilename, self.__dbsRoot)
     self.__notifier = None        
     self.__debug = debug
     self.mytime = datetime.date.today()
     
     # Start the early notification thread
     self.__notifier = ReservationExpiryNotifier(self.__daemonEMail, \
                                                 self.__smtpServerName, \
                                                 self.__filename, \
                                                 self.__rightsFilename, \
                                                 self.__notificationsFilename, \
                                                 self.__dbsRoot,
                                                 self.__debug)
     if not self.__debug:
         self.__notifier.start()
開發者ID:benroeder,項目名稱:HEN,代碼行數:31,代碼來源:reservationdaemon.py

示例9: __init__

class ElementManager:

    def __init__(self):
        self.__manager = HenManager()

    ##########################################################################################        
    # Create functions
    ##########################################################################################
    def computerNodeCreate(self, netbootable, infrastructure, rackName, macAddress, powerID, powerPort, serialID, serialPort, serviceProcessorID, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status, vendor, model):
        return self.__manager.computerNodeCreate(netbootable, infrastructure, rackName, macAddress, powerID, powerPort, serialID, serialPort, serviceProcessorID, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status, vendor, model)

    def serverNodeCreate(self, rackName, serialID, serialPort, managementMAC, infrastructureMAC, externalMAC, externalIP, externalSubnet, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, powerID, powerPort, serviceProcessorID, status, vendor, model):
        return self.__manager.serverNodeCreate(rackName, serialID, serialPort, managementMAC, infrastructureMAC, externalMAC, externalIP, externalSubnet, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, powerID, powerPort, serviceProcessorID, status, vendor, model)

    def serialNodeCreate(self, vendor, model, macAddress, powerID, powerPort, username, password, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status):
        return self.__manager.serialNodeCreate(vendor, model, macAddress, powerID, powerPort, username, password, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status)

    def switchNodeCreate(self, infrastructure, vendor, model, macAddress, powerID, powerPort, serialID, serialPort, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status):
        return self.__manager.switchNodeCreate(infrastructure, vendor, model, macAddress, powerID, powerPort, serialID, serialPort, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status)
        
    def powerswitchNodeCreate(self, vendor, model, macAddress, serialID, serialPort, rackName, username, password, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status):
        return self.__manager.powerswitchNodeCreate(vendor, model, macAddress, serialID, serialPort, rackName, username, password, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status)

    def routerNodeCreate(self, vendor, model, macAddress, powerID, powerPort, serialID, serialPort, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status):
        return self.__manager.routerNodeCreate(vendor, model, macAddress, powerID, powerPort, serialID, serialPort, rackName, attributes, building, floor, room, rackRow, rackStartUnit, rackEndUnit, rackPosition, status)
            
    def serviceprocessorNodeCreate(self, macAddress, powerID, powerPort, username, password, attributes, status, vendor, model):
        return self.__manager.serviceprocessorNodeCreate(macAddress, powerID, powerPort, username, password, attributes, status, vendor, model)

    def infrastructureRackCreate(self, vendor, model, description, building, floor, room, rackRow, rowPosition, height, width, depth, rearRightSlots, rearLeftSlots, numberUnits, status, attributes):
        return self.__manager.infrastructureRackCreate(vendor, model, description, building, floor, room, rackRow, rowPosition, height, width, depth, rearRightSlots, rearLeftSlots, numberUnits, status, attributes)

    def fileNodeCreate(self, fileNodeType, owner, path, architecture, osType, version, mustClone, description, attributes, username, password, status):
        return self.__manager.fileNodeCreate(fileNodeType, owner, path, architecture, osType, version, mustClone, description, attributes, username, password, status)

    ##########################################################################################
    # Edit functions
    ##########################################################################################
    def elementEdit(self, elementID, parameters, attributes):
        return self.__manager. elementEdit(elementID, parameters, attributes)

    ##########################################################################################    
    # Delete functions
    ##########################################################################################
    def elementDelete(self, elementID):
        return self.__manager.elementDelete(elementID)
開發者ID:benroeder,項目名稱:HEN,代碼行數:46,代碼來源:inventoryd.py

示例10: __init__

 def __init__(self):
     Daemon.__init__(self)
     self.__henManager = HenManager()
     # Allow specialized instance dictionary to be created in hm
     # self.__henManager.createNodeInstances()
     self.__registerMethods()
     self.__computerID = self.__getComputerID()
     self.__computerInfo = self.__henManager.getNodes("computer")[self.__computerID]
     self.__ifaceIDtoNameMappings = self.__getIfaceMappings()
開發者ID:benroeder,項目名稱:HEN,代碼行數:9,代碼來源:computerdaemon.py

示例11: main

def main():
    form = cgi.FieldStorage()
    manager = HenManager()
    manager.initLogging()


    if form.has_key("id"):
        experimentid = form["id"].value
        print experimentid
        #manager.experimentDelete(targetNode)

        #cmd = "export PYTHONPATH=$HOME/hen_scripts/hen_scripts/trunk/lib"
        #os.system(cmd)
        #cmd = "sudo hm experiment delete " + targetNode
        #os.system(cmd)


        server = xmlrpclib.ServerProxy(uri="http://localhost:50001/")
        server.delete(experimentid)
開發者ID:benroeder,項目名稱:HEN,代碼行數:19,代碼來源:deleteconfigcgi.py

示例12: main

def main():
    form = cgi.FieldStorage()
    manager = HenManager()
    manager.initLogging()


    print "Cache-Control: no-store, no-cache, must-revalidate"
    print "Content-type: text/xml\n"
    print "<experiments>"

    experiments = manager.getExperimentEntries()
    for experimentID in experiments.keys():
        #segments = experiment.split("/")
        #Bfilename = segments[len(segments) - 1]
        # slice off the '.xml' extension
        #fileid = filename[:-4]
        print "\t<experiment id=\"" + experimentID + "\"/>"

    print "</experiments>"
開發者ID:benroeder,項目名稱:HEN,代碼行數:19,代碼來源:refreshconfigcgi.py

示例13: run

    def run(self,argv):
        if len(argv) != 2:
            print "Usage :"+argv[0]+" <powerswitch name>"
            sys.exit(1)

        self.target_name = argv[1]
        
        manager = HenManager()
        manager.initLogging()
        nodes = manager.getNodes("powerswitch","all")

        self.target = None
        for node in nodes.values():
            if (node.getNodeID() == self.target_name):
                self.target = node.getInstance()
                
        if self.target == None:
            print "Unknown powerswitch "+argv[1]
            sys.exit(1)

        self.run_tests()
開發者ID:benroeder,項目名稱:HEN,代碼行數:21,代碼來源:test.py

示例14: old

 def old(self):
     BASE_URL="cgi-bin/gui/components/network/"
     
     manager = HenManager()
     manager.initLogging()
     
     links = manager.getLinks("all","all")
     graph = pydot.Dot()
 
     switches = manager.getNodes("switch")
     for switch in switches.values():
         if self.__switchStatuses.has_key(switch.getNodeID()):
             if self.__switchStatuses[switch.getNodeID()] == 1:
                 graph.add_node(pydot.Node(switch.getNodeID(),URL=BASE_URL+\
                   "switchinfocgi.py?id="+switch.getNodeID(),\
                   style="filled",color="chartreuse1"))
             else:
                 graph.add_node(pydot.Node(switch.getNodeID(),URL=BASE_URL+\
                   "switchinfocgi.py?id="+switch.getNodeID(),\
                   style="filled",color="firebrick"))
         else:
             graph.add_node(pydot.Node(switch.getNodeID(),URL=BASE_URL+\
                               "switchinfocgi.py?id="+switch.getNodeID()))
     for linktype in links.values():
         for link in linktype.values():
             members = link.getLinkMembers()
             
             graph.add_edge(pydot.Edge(str(members[0].getDeviceId()),\
               str(members[1].getDeviceId()),label=link.getLinkId(),\
               arrowhead="none",headlabel=str(members[1].getDevicePort().\
               replace('GigabitEthernet ','').replace('Management','M')),\
               taillabel=str(members[0].getDevicePort().\
               replace('GigabitEthernet','')),fontsize=8,\
               tooltip=link.getLinkId(),\
               URL=BASE_URL+"linkinfocgi.py?id="+link.getLinkId()))
 
     # prog='circo' isn't bad
     print graph.create_svg(prog='dot')
開發者ID:benroeder,項目名稱:HEN,代碼行數:38,代碼來源:test_switch_topology.py

示例15: ConfigReader

class ConfigReader(Daemon):
    """\brief Implements basic config daemon functionality.
    """
    __version = "Config Daemon v0.1 (simple)"
    __henManager = None
    
    def __init__(self):
        Daemon.__init__(self)
        self.__henManager = HenManager()
        self.__registerMethods()
        
    def __registerMethods(self):
        self.registerMethodHandler("get_object_for_id", self.getObjectForId)
        self.registerMethodHandler("stop_daemon", self.stopDaemon)
        
    def __sendReply(self,prot,code,seq,payload):
        if (code == 0):
            code = 200
        else:
            code = 422 # returnCodes[422] = "error executing command"
        prot.sendReply(code, seq, payload)

    def getObjectForId(self,prot,seq,ln,payload):
        nodes = self.__henManager.getNodes("all")
        for ntk in nodes:
            #print "ntk ",str(ntk)
            for nk in nodes[ntk]:
                #print "nk ",str(nk)
                if nodes[ntk][nk].getNodeID() == payload:
                    payload=pickle.dumps(nodes[ntk][nk])
                    code = 0
                    self.__sendReply(prot,code,seq,payload)
                    return
        payload = "not found"
        code = -1
        self.__sendReply(prot,code,seq,payload)        

    def stopDaemon(self,prot,seq,ln,payload):
        """\brief Stops the daemon and all threads
        This method will first stop any more incoming queries, then wait for
        any update tasks to complete, before stopping itself.
        """
        log.info("stopDaemon called.")
        prot.sendReply(200, seq, "Accepted stop request.")
        log.debug("Sending stopDaemon() response")
        self.acceptConnections(False)
        log.info("Stopping ConfigDaemon (self)")
        self.stop()
開發者ID:benroeder,項目名稱:HEN,代碼行數:48,代碼來源:configdaemon.py


注:本文中的henmanager.HenManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。