本文整理汇总了Python中henmanager.HenManager.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Python HenManager.getNodes方法的具体用法?Python HenManager.getNodes怎么用?Python HenManager.getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类henmanager.HenManager
的用法示例。
在下文中一共展示了HenManager.getNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interfaceid_to_mac
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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
示例2: writeDHCPConfig
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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
示例3: ConfigReader
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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()
示例4: check_port
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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)
示例5: run
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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()
示例6: old
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
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')
示例7: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
for i in temp:
sys.path.append(i)
from henmanager import HenManager
###########################################################################################
# Main execution
###########################################################################################
print "Content-Type: text/xml"
print ""
print ""
print "<row>"
manager = HenManager("/usr/local/hen/etc/configs/config" )
racks = manager.getInfrastructures("rack")
nodes = manager.getNodes("all", "all")
rackNodes = {}
for key in racks.keys():
rackNodes[key] = []
for nodeTypeDictionary in nodes.values():
for node in nodeTypeDictionary.values():
location = node.getPhysicalLocation()
if (location != None):
if rackNodes.has_key(location.getRackName()):
s = '<node id="' + str(node.getNodeID())
s += '" type="physicallocation-' + str(node.getNodeType())
if (location.getRackStartUnit() != None):
s += '" rackstartunit="' + str(location.getRackStartUnit())
示例8: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
from henmanager import HenManager
# First create a list containing the mac addresses of all the running interfaces
macAddresses = []
macAddressMatcher = re.compile("(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}")
lines = commands.getstatusoutput("ifconfig")[1].splitlines()
for line in lines:
matchObject = macAddressMatcher.search(line)
if matchObject:
macAddresses.append(line[matchObject.start() : matchObject.end()].upper())
# Now match the created list against all of the management mac addresses in the testbed's database
# for computer nodes
manager = HenManager()
manager.initLogging()
nodes = manager.getNodes("computer", "all")
nodeName = None
for node in nodes.values():
for interface in node.getInterfaces("management"):
for macAddress in macAddresses:
if macAddress == interface.getMAC().upper():
nodeName = node.getNodeID()
if nodeName == None:
nodes = manager.getNodes("virtualcomputer", "all")
for node in nodes.values():
for interface in node.getInterfaces("management"):
for macAddress in macAddresses:
if macAddress == interface.getMAC().upper():
nodeName = node.getNodeID()
print nodeName
示例9: DetectorDaemon
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
class DetectorDaemon(threading.Thread):
def __init__(self, d, debug):
self.__debug = debug
self.__device_list = d
self.__run = True
self.__nodes = {}
self.__running = []
self.__man_ips = {}
self.__inf_ips = {}
self.__symlinksRoot = "/export/machines/"
if self.__debug:
self.__etcRoot = "/usr/local/hen/etc/daemons/autodetectiond/debug/"
else:
self.__etcRoot = "/usr/local/hen/etc/daemons/autodetectiond/"
self.load_data()
self.show_stats()
threading.Thread.__init__(self)
def show_stats(self):
count = 0
string = "Number of free management ips :"
for i in self.__man_ips:
if self.__man_ips[i] == "free":
count = count + 1
string = string + str(count)
log.info(string)
count = 0
string = "Number of free infrastructure ips :"
for i in self.__inf_ips:
if self.__inf_ips[i] == "free":
count = count + 1
string = string + str(count)
log.info(string)
def load_data(self):
log.info("Loading Data")
self.__manager = HenManager()
for i in range(1, 254):
self.__man_ips["192.168.0." + str(i)] = "free"
self.__inf_ips["192.168.1." + str(i)] = "free"
n = self.__manager.getNodes("all", "all")
for nt in n:
for node in n[nt].values():
try:
man_ip = node.getInterfaces("management")
inf_ip = node.getInterfaces("infrastructure")
if man_ip != []:
self.__nodes[man_ip[0].getIP()] = node
self.__man_ips[str(man_ip[0].getIP())] = node.getNodeID()
if inf_ip != []:
self.__nodes[inf_ip[0].getIP()] = node
self.__inf_ips[str(inf_ip[0].getIP())] = node.getNodeID()
except:
pass
self.show_stats()
def getFreeIp(self, type_str):
if type_str == "infrastructure":
for i in self.__inf_ips:
if self.__inf_ips[i] == "free":
return i
return "no free infrastructure ip"
elif type_str == "management":
for i in self.__man_ips:
if self.__man_ips[i] == "free":
return i
return "no free infrastructure ip"
else:
return "unknown ip type " + type_str
def writeXML(self, node, old=False):
xmlstring = self.__manager.parser.writeNodePhysicalFileString(node, self.__debug)
print xmlstring
filename = self.__etcRoot + node.getNodeID() + ".xml"
if old:
filename = filename + ".old"
try:
if not self.__debug:
theFile = open(filename, "w")
theFile.write(xmlstring)
theFile.close()
else:
print "Would write to file ", filename
print xmlstring
except Exception, e:
log.info("error while writing xml file for " + str(node.getNodeID()))
log.info(str(e))
return -1
示例10: ComputerControl
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
class ComputerControl(Daemon):
"""\brief Implements basic computer daemon functionality.
"""
__version = "Computer Daemon v0.1 (simple)"
__henManager = None
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()
def getComputerManagementIP(self):
# Get the management ip address so that we can bind to it.
interfaces = self.__computerInfo.getInterfaces("management")
try:
return interfaces[0].getIP()
except:
return "0.0.0.0"
def __getComputerID(self):
# Prints the name of the node that the script is run from. To do so it matches the mac addresses of
# all running interfaces against the mac addresses in the testbed's database. Prints None if no match is found
# First create a list containing the mac addresses of all the running interfaces
macAddresses = []
macAddressMatcher = re.compile("(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}")
lines = commands.getstatusoutput("ifconfig")[1].splitlines()
for line in lines:
matchObject = macAddressMatcher.search(line)
if matchObject:
macAddresses.append(line[matchObject.start() : matchObject.end()].upper())
# Now match the created list against all of the management mac addresses in the testbed's database
# for computer nodes
self.__henManager.initLogging()
nodes = self.__henManager.getNodes("computer", "all")
nodeName = None
for node in nodes.values():
for interface in node.getInterfaces("management"):
for macAddress in macAddresses:
if macAddress == interface.getMAC().upper():
nodeName = node.getNodeID()
if nodeName == None:
nodes = self.__henManager.getNodes("virtualcomputer", "all")
for node in nodes.values():
for interface in node.getInterfaces("management"):
for macAddress in macAddresses:
if macAddress == interface.getMAC().upper():
nodeName = node.getNodeID()
return nodeName
def __getIfaceMappings(self):
mappings = {}
# Supports only Linux for now
interfaces = self.__computerInfo.getInterfaces("experimental")
ifacesInfo = commands.getstatusoutput("ifconfig -a | grep HWaddr")[1].splitlines()
for interface in interfaces:
for infoLine in ifacesInfo:
if infoLine.find(interface.getMAC()) != -1:
mappings[interface.getInterfaceID()] = infoLine[: infoLine.find(" ")]
return mappings
def __registerMethods(self):
self.registerMethodHandler("get_computer_id", self.getComputerID)
self.registerMethodHandler("autodetect", self.autodetect)
self.registerMethodHandler("execute_command", self.executeCommand)
self.registerMethodHandler("gcc_compile", self.gccCompile)
self.registerMethodHandler("cat", self.cat)
self.registerMethodHandler("make", self.make)
self.registerMethodHandler("mkdir", self.mkdir)
self.registerMethodHandler("untar", self.untar)
self.registerMethodHandler("add_route", self.addRoute)
self.registerMethodHandler("delete_route", self.delRoute)
self.registerMethodHandler("config_iface", self.configIface)
self.registerMethodHandler("click-align", self.clickAlign)
self.registerMethodHandler("click-install", self.clickInstall)
self.registerMethodHandler("click-uninstall", self.clickUninstall)
self.registerMethodHandler("load_module", self.loadModule)
self.registerMethodHandler("unload_module", self.unloadModule)
self.registerMethodHandler("linux_forwarding_on", self.linuxForwardingOn)
self.registerMethodHandler("linux_forwarding_off", self.linuxForwardingOff)
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 autodetect(self, prot, seq, ln, payload):
pass
def getComputerID(self, prot, seq, ln, payload):
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
class HardwareDetectionRunner:
__prot = None
__host = None
__port = None
__hm = None
__interfaceNames = None
__data = None
def __init__(self, host, port):
self.__prot = auxiliary.protocol.Protocol(None)
self.__host = host
self.__port = port
self.__data = ""
self.__hm = HenManager()
def run(self):
"""\brief Runs all the necessary detection methods."""
print "Running hardware detection:"
print "\tRetrieving experimental interface names..."
self.getExperimentalInterfacesNames()
print "\tPolling interfaces..."
self.pollInterfaces()
# Sometimes mii-tool will report no link if this sleep time is not here
print "Waiting " + str(AUTONEGOTIATION_WAIT_TIME) + \
" seconds for autonegotiation to finish",
self.waitForAutonegotiation()
print "Retrieving number of processors..."
self.getNumberProcessors()
print "Retrieving number of cores..."
self.getNumberCores()
print "Retrieving no-carrier-sense MACs..."
self.getNoCarrierMACs()
print "Retrieving output from lshw..."
self.getLSHWOutput()
print "Polling interfaces once to seed fdb"
self.pollInterfaces()
print "Sending results to AutodetectDaemon... "
self.sendData()
print "Polling interfaces continually..."
while 1:
self.pollInterfaces()
time.sleep(POLL_INTERFACE_INTERVAL)
def waitForAutonegotiation(self):
"""\brief Prints a dot per second whilst waiting for the number of
seconds defined by AUTONEGOTIATION_WAIT_TIME
"""
ticks = AUTONEGOTIATION_WAIT_TIME
while ticks > 0:
print '.',
ticks -= 1
time.sleep(1)
def pollInterfaces(self):
for interfaceName in self.__interfaceNames:
cmd = "/sbin/ifconfig " + interfaceName + " up"
os.system(cmd)
cmd = "etherwake -i " + interfaceName + " 00:11:22:33:44:55"
os.system(cmd)
def getExperimentalInterfacesNames(self):
# First create a list containing the mac addresses of all the interfaces
macAddresses = []
macAddressMatcher = re.compile('(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}')
lines = commands.getstatusoutput("ifconfig -a")[1].splitlines()
for line in lines:
matchObject = macAddressMatcher.search(line)
if (matchObject):
macAddresses.append(\
line[matchObject.start():matchObject.end()].upper())
# Find which of these is the management interface so we can filter it out
nodes = self.__hm.getNodes("computer", "all")
for node in nodes.values():
managementMACAddress = \
node.getInterfaces("management")[0].getMAC().upper()
if (managementMACAddress in macAddresses):
break
self.__interfaceNames = []
for macAddress in macAddresses:
if (macAddress != managementMACAddress):
# We need to convert the mac addresses to interface names
self.__interfaceNames.append(commands.getstatusoutput(\
"ifconfig -a | grep " + macAddress + \
" | awk '{print $1}'")[1])
def getNumberProcessors(self):
data = commands.getstatusoutput(\
"cat /proc/cpuinfo | grep 'physical id'")[1]
data = data.split("\n")
uniqueIDs = []
for line in data:
processorID = line[line.find(":") + 1:]
if (processorID not in uniqueIDs):
uniqueIDs.append(processorID)
self.__data += "<numbercpus>%s</numbercpus>" % str(len(uniqueIDs))
def getNumberCores(self):
#.........这里部分代码省略.........
示例12: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
#!/usr/bin/env python
import os, sys, commands
from henmanager import HenManager
manager = HenManager()
nodes = manager.getNodes("computer")
user=""
usage = "usage: reservations.py [computerid] [computerid]\n"
usage += "usage: reservations.py all\n"
usage += "usage: reservations.py model [dell2950|dell1950|dell1850|sunx4100|sunv20z|delloptiplex]\n"
usage += "usage: reservations.py user [username]"
if (len(sys.argv) < 2):
print usage
os._exit(0)
if (sys.argv[1] == "model"):
if (len(sys.argv) != 3):
print usage
os._exit(0)
elif (sys.argv[2] == "dell2950"):
beginID="computer81"
endID="computer100"
elif (sys.argv[2] == "dell1950"):
beginID="computer56"
endID="computer80"
elif (sys.argv[2] == "dell1850"):
beginID="computer21"
endID="computer25"
示例13: HenManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
#!/usr/local/bin/python
from henmanager import HenManager
import time
import resource
import gc
manager = HenManager()
manager.initLogging()
switches = manager.getNodes("all","all")
alive_list =['switch14', 'switch5', 'serviceprocessor16', 'sensor1', 'serviceprocessor20','serviceprocessor22','serviceprocessor42','serviceprocessor43','serviceprocessor44', 'powerswitch3', 'switch1', 'switch2', 'switch3' , 'switch4' ,'switch8', 'computer71' ]
switch = {}
#sn = {}
#switch_node = None
for a in switches.values():
for sw in a.values():
for h in alive_list:
if sw.getNodeID() == h:
try:
switch[sw.getNodeID()] = sw.getInstance()
except:
pass
num = 1
while True:
print "run ",num
for s in switch.keys():
print s
#sn[s] = switch[s].getSensorReadings()
示例14: AutodetectManager
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
class AutodetectManager(Daemon):
__hen_manager = None
__hardware_processor = None
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()
def __parseMacTableURL(self):
"""\brief Parses the Hen config file, and returns the MACTABLE_URL
\return macTableURL - the value of MACTABLE_URL in the Hen config
"""
configFile = ConfigParser.ConfigParser()
configFile.read(HEN_CONFIG)
return configFile.get('AUTODETECT', 'MACTABLE_URL')
def __registerMethods(self):
self.registerMethodHandler("receive_detectiondata", \
self.receiveDetectionData)
self.registerMethodHandler("enable_debug_mode", \
self.enableDebugMode)
self.registerMethodHandler("disable_debug_mode", \
self.disableDebugMode)
def enableDebugMode(self,prot,seq,ln,payload):
self.__hardware_processor.enableDebugMode()
prot.sendReply(200, seq, "")
def disableDebugMode(self,prot,seq,ln,payload):
self.__hardware_processor.disableDebugMode()
prot.sendReply(200, seq, "")
def receiveDetectionData(self,prot,seq,ln,payload):
"""\brief Method called when detection data is received from
autodetectclient scripts being run on remote hosts.
"""
log.debug("receiveDetectionData() called.")
(nodeid, addr) = self.__ipAddressToNodeID(prot.getSocket())
if not nodeid or not addr:
log.warning("Bad results from __ipAddressToNodeID().")
prot.sendReply(500, seq, \
"Failure: Daemon could not resolve IP to nodeid.")
return
log.info("received data from %s (%s)" % (str(addr), str(nodeid)))
prot.sendReply(200, seq, "")
self.__hardware_processor.parseFileAndPrint(nodeid, payload)
def __ipAddressToNodeID(self, sock):
"""\brief Retrieves the IP address of the connected client, then tries
to look up a nodeid for it from HenManager
\param sock - socket on which the client is connected
\return nodeid - id of node to which IP address belongs, -1 if not
found
"""
try:
(addr, port) = sock.getpeername()
log.debug("addr %" + str(addr))
computerNodes = self.__hen_manager.getNodes("computer", "all")
for computerNode in computerNodes.values():
interfaces = computerNode.getInterfaces("management")
for interface in interfaces:
if (interface.getIP() == addr):
return (computerNode.getNodeID(), addr)
except:
pass
return (None, None)
示例15: raw_input
# 需要导入模块: from henmanager import HenManager [as 别名]
# 或者: from henmanager.HenManager import getNodes [as 别名]
p = auxiliary.protocol.Protocol(None)
# read connection info from user
# host = raw_input("host name (localhost):")
# if (host==""):
# host = "localhost"
# try:
# port = int(raw_input("port (1105):"))
# except:
## port = 1105
host = DaemonPorts().powerDaemonHost
port = DaemonPorts().powerDaemonPort
print "connecting to " + host + "port " + str(port)
p.open(host, port)
# send state!
payload = "10," + pickle.dumps(hm.getNodes("all"))
# p.sendRequest("set_config",payload,state_check)
# p.readAndProcess()
p.doSynchronousCall("set_config", payload)
# read smth from the user
while True:
method = raw_input("method:")
payload = raw_input("payload:")
# p.sendRequest(method,payload,handler)
# p.readAndProcess()
print p.doSynchronousCall(method, payload)