daemon/core/broker.py
def handlenodemsg(self, msg):
        ''' Determine and return the servers to which this node message should
            be forwarded. Also keep track of link-layer nodes and the mapping of
            nodes to servers.
        '''
        serverlist = []
        handle_locally = False
        serverfiletxt = None
        # snoop Node Message for emulation server TLV and record mapping
        n = msg.tlvdata[coreapi.CORE_TLV_NODE_NUMBER]
        # replicate link-layer nodes on all servers
        nodetype = msg.gettlv(coreapi.CORE_TLV_NODE_TYPE)
        if nodetype is not None:
            try:
                nodecls = coreapi.node_class(nodetype)
            except KeyError:
                self.session.warn("broker invalid node type %s" % nodetype)
                return (False, serverlist)
            if nodecls is None:
                self.session.warn("broker unimplemented node type %s" % nodetype)
                return (False, serverlist)
            if issubclass(nodecls, PyCoreNet) and \
                nodetype != coreapi.CORE_NODE_WLAN:
                # network node replicated on all servers; could be optimized
                # don't replicate WLANs, because ebtables rules won't work
                serverlist = self.getserverlist()
                handle_locally = True
                self.addnet(n)
                for server in serverlist:
                    self.addnodemap(server, n)
                # do not record server name for networks since network
                # nodes are replicated across all server
                return (handle_locally, serverlist)
            if issubclass(nodecls, PyCoreNet) and \
                nodetype == coreapi.CORE_NODE_WLAN:
                # special case where remote WLANs not in session._objs, and no
                # node response message received, so they are counted here
                if msg.gettlv(coreapi.CORE_TLV_NODE_EMUSRV) is not None:
                    self.incrbootcount()
            elif issubclass(nodecls, PyCoreNode):
                name = msg.gettlv(coreapi.CORE_TLV_NODE_NAME)
                if name:
                    serverfiletxt = "%s %s %s" % (n, name, nodecls)
                if issubclass(nodecls, PhysicalNode):
                    # remember physical nodes
                    self.addphys(n)
            
        # emulation server TLV specifies server
        server = msg.gettlv(coreapi.CORE_TLV_NODE_EMUSRV)
        if server is not None:
            self.addnodemap(server, n)
            if server not in serverlist:
                serverlist.append(server)
            if serverfiletxt and self.session.master:
                self.writenodeserver(serverfiletxt, server)
        # hook to update coordinates of physical nodes
        if n in self.phys:
            self.session.mobility.physnodeupdateposition(msg)
        return (handle_locally, serverlist)
 Determine and return the servers to which this node message should
            be forwarded. Also keep track of link-layer nodes and the mapping of
            nodes to servers.
        
Determine and return the servers to which this node message should
be forwarded. Also keep track of link-layer nodes and the mapping of
nodes to servers.
Determine and return the servers to which this node message should be forwarded . Also keep track of link - layer nodes and the mapping of nodes to servers .
def handlenodemsg(self, msg):
        serverlist = []
        handle_locally = False
        serverfiletxt = None
        n = msg.tlvdata[coreapi.CORE_TLV_NODE_NUMBER]
        nodetype = msg.gettlv(coreapi.CORE_TLV_NODE_TYPE)
        if nodetype is not None:
            try:
                nodecls = coreapi.node_class(nodetype)
            except KeyError:
                self.session.warn("broker invalid node type %s" % nodetype)
                return (False, serverlist)
            if nodecls is None:
                self.session.warn("broker unimplemented node type %s" % nodetype)
                return (False, serverlist)
            if issubclass(nodecls, PyCoreNet) and \
                nodetype != coreapi.CORE_NODE_WLAN:
                serverlist = self.getserverlist()
                handle_locally = True
                self.addnet(n)
                for server in serverlist:
                    self.addnodemap(server, n)
                return (handle_locally, serverlist)
            if issubclass(nodecls, PyCoreNet) and \
                nodetype == coreapi.CORE_NODE_WLAN:
                if msg.gettlv(coreapi.CORE_TLV_NODE_EMUSRV) is not None:
                    self.incrbootcount()
            elif issubclass(nodecls, PyCoreNode):
                name = msg.gettlv(coreapi.CORE_TLV_NODE_NAME)
                if name:
                    serverfiletxt = "%s %s %s" % (n, name, nodecls)
                if issubclass(nodecls, PhysicalNode):
                    self.addphys(n)
        server = msg.gettlv(coreapi.CORE_TLV_NODE_EMUSRV)
        if server is not None:
            self.addnodemap(server, n)
            if server not in serverlist:
                serverlist.append(server)
            if serverfiletxt and self.session.master:
                self.writenodeserver(serverfiletxt, server)
        if n in self.phys:
            self.session.mobility.physnodeupdateposition(msg)
        return (handle_locally, serverlist)
def handlenodemsg ( self , msg ) : serverlist = [ ] handle_locally = False serverfiletxt = None n = msg . tlvdata [ coreapi . CORE_TLV_NODE_NUMBER ] nodetype = msg . gettlv ( coreapi . CORE_TLV_NODE_TYPE ) if nodetype is not None : try : nodecls = coreapi . node_class ( nodetype ) except KeyError : self . session . warn ( "broker invalid node type %s" % nodetype ) return ( False , serverlist ) if nodecls is None : self . session . warn ( "broker unimplemented node type %s" % nodetype ) return ( False , serverlist ) if issubclass ( nodecls , PyCoreNet ) and nodetype != coreapi . CORE_NODE_WLAN : serverlist = self . getserverlist ( ) handle_locally = True self . addnet ( n ) for server in serverlist : self . addnodemap ( server , n ) return ( handle_locally , serverlist ) if issubclass ( nodecls , PyCoreNet ) and nodetype == coreapi . CORE_NODE_WLAN : if msg . gettlv ( coreapi . CORE_TLV_NODE_EMUSRV ) is not None : self . incrbootcount ( ) elif issubclass ( nodecls , PyCoreNode ) : name = msg . gettlv ( coreapi . CORE_TLV_NODE_NAME ) if name : serverfiletxt = "%s %s %s" % ( n , name , nodecls ) if issubclass ( nodecls , PhysicalNode ) : self . addphys ( n ) server = msg . gettlv ( coreapi . CORE_TLV_NODE_EMUSRV ) if server is not None : self . addnodemap ( server , n ) if server not in serverlist : serverlist . append ( server ) if serverfiletxt and self . session . master : self . writenodeserver ( serverfiletxt , server ) if n in self . phys : self . session . mobility . physnodeupdateposition ( msg ) return ( handle_locally , serverlist )
Determine and return the servers to which this node message should
be forwarded.
Determine and return the servers to which this node message should be forwarded .
''' Determine and return the servers to which this node message should
            be forwarded. Also keep track of link-layer nodes and the mapping of
            nodes to servers.
        ''' # snoop Node Message for emulation server TLV and record mapping # replicate link-layer nodes on all servers # network node replicated on all servers; could be optimized # don't replicate WLANs, because ebtables rules won't work # do not record server name for networks since network # nodes are replicated across all server # special case where remote WLANs not in session._objs, and no # node response message received, so they are counted here # remember physical nodes # emulation server TLV specifies server # hook to update coordinates of physical nodes
self
msg