当前位置: 首页>>代码示例>>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;未经允许,请勿转载。