Beispiel #1
0
 def addtunnel(self, remoteip, n1num, n2num, localnum):
     ''' Add a new GreTapBridge between nodes on two different machines.
     '''
     key = self.tunnelkey(n1num, n2num)
     if localnum == n2num:
         remotenum = n1num
     else:
         remotenum = n2num
     if key in self.tunnels.keys():
         self.session.warn("tunnel with key %s (%s-%s) already exists!" % \
                           (key, n1num, n2num))
     else:
         objid = key & ((1<<16)-1)
         self.session.info("Adding tunnel for %s-%s to %s with key %s" % \
                           (n1num, n2num, remoteip, key))
         if localnum in self.phys:
             # no bridge is needed on physical nodes; use the GreTap directly
             gt = GreTap(node=None, name=None, session=self.session,
                             remoteip=remoteip, key=key)
         else:
             gt = self.session.addobj(cls = GreTapBridge, objid = objid,
                                 policy="ACCEPT", remoteip=remoteip, key = key)
         gt.localnum = localnum
         gt.remotenum = remotenum
         self.tunnels[key] = gt
Beispiel #2
0
 def addtunnel(self, remoteip, n1num, n2num, localnum):
     ''' Add a new GreTapBridge between nodes on two different machines.
     '''
     key = self.tunnelkey(n1num, n2num)
     if localnum == n2num:
         remotenum = n1num
     else:
         remotenum = n2num
     if key in list(self.tunnels.keys()):
         self.session.warn("tunnel with key %s (%s-%s) already exists!" % \
                           (key, n1num, n2num))
     else:
         objid = key & ((1<<16)-1)
         self.session.info("Adding tunnel for %s-%s to %s with key %s" % \
                           (n1num, n2num, remoteip, key))
         if localnum in self.phys:
             # no bridge is needed on physical nodes; use the GreTap directly
             gt = GreTap(node=None, name=None, session=self.session,
                             remoteip=remoteip, key=key)
         else:
             gt = self.session.addobj(cls = GreTapBridge, objid = objid,
                                 policy="ACCEPT", remoteip=remoteip, key = key)
         gt.localnum = localnum
         gt.remotenum = remotenum
         self.tunnels[key] = gt
Beispiel #3
0
    def addtunnel(self, remoteip, n1num, n2num, localnum):
        """
        Adds a new GreTapBridge between nodes on two different machines.

        :param str remoteip: remote address for tunnel
        :param int n1num: node one id
        :param int n2num: node two id
        :param int localnum: local id
        :return: nothing
        """
        key = self.tunnelkey(n1num, n2num)
        if localnum == n2num:
            remotenum = n1num
        else:
            remotenum = n2num

        if key in self.tunnels.keys():
            logger.warn("tunnel with key %s (%s-%s) already exists!", key, n1num, n2num)
        else:
            objid = key & ((1 << 16) - 1)
            logger.info("adding tunnel for %s-%s to %s with key %s", n1num, n2num, remoteip, key)
            if localnum in self.physical_nodes:
                # no bridge is needed on physical nodes; use the GreTap directly
                gt = GreTap(node=None, name=None, session=self.session,
                            remoteip=remoteip, key=key)
            else:
                gt = self.session.add_object(cls=GreTapBridge, objid=objid,
                                             policy="ACCEPT", remoteip=remoteip, key=key)
            gt.localnum = localnum
            gt.remotenum = remotenum
            self.tunnels[key] = gt