Beispiel #1
0
    def test_addr_add(self):
        """Test IP address configuration.
        """
        netdev.addr_add('1.2.3.4', 'foo_dev', addr_scope='foo_scope')

        treadmill.subproc.check_call.assert_called_with([
            'ip',
            'addr',
            'add',
            '1.2.3.4',
            'dev',
            'foo_dev',
            'scope',
            'foo_scope',
        ], )

        netdev.addr_add('1.2.3.4',
                        'foo_dev',
                        ptp_addr='3.4.5.6',
                        addr_scope='foo_scope')

        treadmill.subproc.check_call.assert_called_with([
            'ip',
            'addr',
            'add',
            '1.2.3.4',
            'peer',
            '3.4.5.6',
            'dev',
            'foo_dev',
            'scope',
            'foo_scope',
        ], )
Beispiel #2
0
    def _bridge_initialize(self):
        """Reset/initialize the Treadmill node bridge.
        """
        try:
            # FIXME(boysson): This is for migration when TM_DEV0 used to be a
            #                 bridge.
            netdev.link_set_down(self._TM_DEV0)
            netdev.bridge_delete(self._TM_DEV0)
        except subproc.CalledProcessError:
            pass

        try:
            netdev.link_set_down(self._TM_DEV0)
            netdev.link_del_veth(self._TM_DEV0)
        except subproc.CalledProcessError:
            pass

        try:
            netdev.link_set_down(self._TMBR_DEV)
            netdev.bridge_delete(self._TMBR_DEV)
        except subproc.CalledProcessError:
            pass

        netdev.bridge_create(self._TMBR_DEV)
        netdev.bridge_setfd(self._TMBR_DEV, 0)
        netdev.link_add_veth(self._TM_DEV0, self._TM_DEV1)
        netdev.link_set_mtu(self._TM_DEV0, self.ext_mtu)
        netdev.link_set_mtu(self._TM_DEV1, self.ext_mtu)
        netdev.bridge_addif(self._TMBR_DEV, self._TM_DEV1)
        # Force the bridge MAC address to the Treadmill device. This
        # prevents the bridge's MAC from changing when adding/removing
        # container interfaces.
        # (Default Linux bridge behavior is to set the bridge's MAC to be
        # lowest of it's ports).
        tm_mac = netdev.dev_mac(self._TM_DEV1)
        netdev.link_set_addr(self._TMBR_DEV, tm_mac)
        # Bring up the bridge interface
        netdev.link_set_up(self._TMBR_DEV)
        netdev.link_set_up(self._TM_DEV1)
        netdev.addr_add(
            addr='{ip}/16'.format(ip=self._TM_IP),
            devname=self._TM_DEV0
        )
        # Enable route_localnet so that we can redirect traffic from the
        # container to the node's loopback address.
        netdev.dev_conf_route_localnet_set(self._TM_DEV0, True)
        # Bring up the TM interface
        netdev.link_set_up(self._TM_DEV0)
Beispiel #3
0
def wg_dev_create(unique_id, tun_localaddr, tun_remoteaddr, ll_devname,
                  ll_localaddr, ll_remoteaddr):
    """Configure a Warpgate tunnel interface.
    """
    tun_devname = _WG_DEV_FORMAT.format(id=unique_id)
    netdev.gre_create(
        grename=tun_devname,
        devname=ll_devname,
        localaddr=ll_localaddr,
        remoteaddr=ll_remoteaddr,
        key=unique_id,
    )
    netdev.addr_add(addr=tun_localaddr,
                    devname=tun_devname,
                    ptp_addr=tun_remoteaddr,
                    addr_scope='host')
    return tun_devname