Beispiel #1
0
    def connectInNameSpace(self,
                           ovsbridge,
                           namespace,
                           ipaddress=None,
                           gateway=None,
                           name=None):
        namespace = netcl.NameSpace(namespace)
        bridge = netcl.Bridge(ovsbridge)
        namespace.create()

        iin = self._generatenewdevname()
        iout = self._generatenewdevname()
        createVethPair(iin, iout)
        namespace.connect(iin)
        bridge.connect(iout)
        if name:
            ip_link_set(iin, 'name {}'.format(name), namespace.name)
        else:
            name = iin
        ip_link_set(name, 'up', namespace.name)
        if ipaddress:
            self._exec('ip -n {} address add {} dev {}'.format(
                namespace.name, ipaddress, name))
        if gateway:
            self._exec('ip -n {} route add default via {}'.format(
                namespace.name, gateway))
        return name, iout
Beispiel #2
0
 def newBridge(self, name, interface=None):
     """
     @param interface interface where to connect this bridge to
     """
     br = netcl.Bridge(name)
     br.create()
     if interface is not None:
         br.connect(interface)
Beispiel #3
0
 def cleanupIfUnusedVlanBridge(self, bridgename=None, vlan=None):
     if bridgename is None and vlan is None:
         raise ValueError('Requires at least bridgename or vlan')
     if bridgename is None:
         bridgename = self.getVlanBridge(vlan)
     with FileLock('vlan_%s' % bridgename):
         bridge = netcl.Bridge(bridgename)
         connections = bridge.listConnections()
         if len(connections) > 1:
             return False
         else:
             for connection in connections:
                 parentbridge, vlan = connection.split('-')
                 bridge.removeInterface(connection)
                 pbridge = netcl.Bridge(parentbridge)
                 pbridge.removeInterface('{}-{}'.format(bridgename, vlan))
             bridge.destroy()
 def newBridge(self, name, interface=None):
     """
     @param interface ['interface'] can take multiple interfaces where to connect this bridge
     """
     br = netcl.Bridge(name)
     br.create()
     if interface is not None:
         br.connect(interface)
Beispiel #5
0
 def createVXLanBridge(self, networkid, backend, bridgename=None):
     """
     Creates a proper vxlan interface and bridge based on a backplane
     """
     networkoid = netcl.NetID(networkid)
     vxlan = netcl.VXlan(networkoid, backend)
     vxlan.create()
     vxlan.no6()
     bridge = netcl.Bridge(bridgename)
     bridge.create()
     bridge.connect(vxlan.name)
     return vxlan