Exemplo n.º 1
0
 def addNode(self, name, location):
     '''Add a running node to the manager. Sends an event to the location.'''
     initializer = {
         'destination': name,
         'location': self.location(),
         'session': self.session
     }
     e = event.SetManagerEvent(initializer=initializer)
     client = datatransport.Client(location, self.clientlogger)
     try:
         client.send(e)
     except datatransport.TransportError:
         try:
             hostname = location['TCP transport']['hostname']
         except KeyError:
             hostname = '<unknown host>'
         try:
             tcp_port = location['TCP transport']['port']
         except KeyError:
             tcp_port = '<unknown port>'
         try:
             self.logger.error('Failed to add node at ' + hostname + ':' +
                               str(tcp_port))
         except AttributeError:
             pass
Exemplo n.º 2
0
	def addDescription(self, nodename, name, description, types, location):
		if (nodename not in self.clients or
				self.clients[nodename].serverlocation != location):
			self.clients[nodename] = datatransport.Client(location,
																										self.node.clientlogger)

		if nodename not in self.descriptions:
			self.descriptions[nodename] = {}
		self.descriptions[nodename][name] = (description, types)
		self._addHandler(nodename, name, description, types)
Exemplo n.º 3
0
    def setManager(self, location):
        '''Set the manager controlling the node and notify said manager this node is available.'''
        self.managerclient = datatransport.Client(location['data binder'],
                                                  self.clientlogger)

        available_event = event.NodeAvailableEvent(
            location=self.location(), nodeclass=self.__class__.__name__)
        self.outputEvent(ievent=available_event, wait=True, timeout=10)

        self.objectservice = self.objectserviceclass(self)
def printData(d):
    manlocation = d['location']
    managerhost = manlocation['TCP transport']['hostname']
    managerport = manlocation['TCP transport']['port']
    print 'MANAGER:  %s:%s' % (managerhost, managerport)
    print 'connecting to manager...'
    client = datatransport.Client(manlocation, Logger())
    myloc = db.location()
    print 'MYLOC', myloc
    del myloc['local transport']
    e = event.NodeAvailableEvent(location=myloc, destination=managerhost)
    client.send(e)
Exemplo n.º 5
0
 def addClient(self, name, databinderlocation):
     '''Add a databinder client for a node keyed by the node ID.'''
     self.clients[name] = datatransport.Client(databinderlocation,
                                               self.clientlogger)
        print 'EXCEPTION', stuff

    def warning(self, stuff):
        print 'WARNING', stuff


myhostname = socket.gethostname().lower()

for myport in range(49152, 65536):
    try:
        db = databinder.DataBinder(myhostname, Logger(), tcpport=myport)
        break
    except:
        continue
print 'ACCEPTING CONNECTIONS AT:  %s:%s' % (myhostname, myport)

db.addBinding(myhostname, event.NodeAvailableEvent, printData)

mylocation = {'TCP transport': {'hostname': myhostname, 'port': myport}}
yourlocation = {'TCP transport': {'hostname': tecnaihost, 'port': tecnaiport}}

e = event.SetManagerEvent(destination=tecnaihost, location=mylocation)
print 'CONNECTING TO:  %s:%s' % (tecnaihost, tecnaiport)
client = datatransport.Client(yourlocation, Logger())

## this will connect to the tecnai
client.send(e)

raw_input('hit enter to kill')
db.exit()