Example #1
0
    def start(self):
        '''
        Start the static overlay link.
        '''

        self.logger.info("starting static overlay link '%s'" % self.name)

        # Start the network namespace object for the linked overlay.
        self.inner_netns.start()

        # Create the inner and outer veth interfaces, which link the
        # overlays together. At the same time, move the inner veth
        # interface to the inner overlay.
        outer_if = veth.create(
            self.dry_run,
            self.logger,
            self.outer_name,
            self.inner_name,
            netns = self.netns,
        )

        inner_if = outer_if.peer_get(peer_netns=self.inner_netns)
        inner_if.netns_set(self.inner_netns)

        # Create a dummy interface for the outer veth interface to be
        # bridged with.
        dummy_if = dummy.create(
            self.dry_run,
            self.logger,
            self.dummy_name,
            netns = self.netns,
        )

        # Create the bridge interface for the dummy interface and the
        # veth pair interface, and add the bridge ports.
        bridge_if = bridge.create(
            self.dry_run,
            self.logger,
            self.bridge_name,
            netns = self.netns,
        )
        bridge_if.add_port(outer_if)
        bridge_if.add_port(dummy_if)

        # Assign address to the interfaces.
        bridge_if.add_ip(self.outer_address, self.netmask)
        inner_if.add_ip(self.inner_address, self.netmask)

        # Bring up both the inner and outer interfaces, and their
        # linking interfaces.
        outer_if.up()
        inner_if.up()
        dummy_if.up()
        bridge_if.up()

        # Stop the network namespace object for the linked overlay,
        # to remove its process from memory.
        self.inner_netns.stop()

        self.logger.info("finished starting static overlay link '%s'" % self.name)
Example #2
0
    def start(self):
        '''
        Start the mesh tunnel.
        '''

        self.logger.info("starting mesh tunnel '%s'" % self.name)

        tunnel_if = gre.create(
            self.dry_run,
            self.logger,
            self.name,
            "gretap",
            self.physical_local,
            self.physical_remote,
            key = self.asn,
            root_ipdb = self.root_ipdb,
        )

        root_veth_if = veth.create(
            self.dry_run,
            self.logger,
            self.root_veth_name,
            self.netns_veth_name,
            root_ipdb = self.root_ipdb,
        )

        netns_veth_if = root_veth_if.peer_get(peer_netns=self.netns)
        netns_veth_if.netns_set(self.netns)

        bridge_if = bridge.create(
            self.dry_run,
            self.logger,
            self.bridge_name,
            root_ipdb = self.root_ipdb,
        )
        bridge_if.add_port(tunnel_if)
        bridge_if.add_port(root_veth_if)

        # Add an address to the network namespace veth interface, so it can
        # be addressed from either side of the mesh tunnel.
        netns_veth_if.add_ip(self.virtual_local, self.virtual_netmask)

        tunnel_if.up()
        root_veth_if.up()
        netns_veth_if.up()
        bridge_if.up()

        self.logger.info("finished starting mesh tunnel '%s'" % self.name)
Example #3
0
    def start(self):
        '''
        Start the static vlan.
        '''

        self.logger.info("starting static vlan '%s'" % self.name)

        # Find the physical interface.
        physical_if = interface.get(
            self.dry_run,
            self.logger,
            self.physical_interface,
            root_ipdb = self.root_ipdb,
        )

        # Create the VLAN interface.
        vlan_if = vlan.create(
            self.dry_run,
            self.logger,
            self.vlan_name,
            physical_if, 
            self.id,
            root_ipdb = self.root_ipdb,
        )

        # Create the veth pair.
        root_veth_if = veth.create(
            self.dry_run,
            self.logger,
            self.root_veth_name,
            self.netns_veth_name,
            root_ipdb = self.root_ipdb,
        )

        # Move the netns veth interface to the network namespace.
        netns_veth_if = root_veth_if.peer_get(peer_netns=self.netns)
        netns_veth_if.netns_set(self.netns)

        # Add the assigned address for the VLAN to the netns veth
        # interface.
        netns_veth_if.add_ip(self.address, self.netmask)

        # Create a bridge for the physical interface to connect to the
        # network namespace via the veth pair.
        bridge_if = bridge.create(
            self.dry_run,
            self.logger,
            self.bridge_name,
            root_ipdb = self.root_ipdb,
        )

        # Add the physical interface and the root veth interface to the
        # bridge.
        bridge_if.add_port(vlan_if)
        bridge_if.add_port(root_veth_if)

        # Finally, we're done! Bring up the interfaces!
        physical_if.up()
        vlan_if.up()
        root_veth_if.up()
        netns_veth_if.up()
        bridge_if.up()

        self.logger.info("finished starting static vlan '%s'" % self.name)