Exemplo n.º 1
0
 def test_list_vlans_on_base_device(self):
     with dummy_device() as nic:
         with vlan_device(nic, tag=999) as vlan_dev:
             self.assertEqual(
                 [vlan_dev.devName],
                 list(vlan.get_vlans_on_base_device(nic)),
             )
Exemplo n.º 2
0
def _create_dhcp_client_server_peers(network_config, vlan_id):
    with veth_pair(max_length=10) as (server, client):
        if vlan_id:
            with vlan_device(server, vlan_id) as vlan_iface:
                _configure_iface_ip(vlan_iface, network_config)
                yield vlan_iface, client
        else:
            _configure_iface_ip(server, network_config)
            yield server, client
Exemplo n.º 3
0
def _create_dhcp_client_server_peers(network_config, vlan_id):
    with veth_pair(max_length=10) as (server, client):
        linkSet(server, ['up'])
        linkSet(client, ['up'])

        if vlan_id:
            with vlan_device(server, vlan_id) as vlan_iface:
                vlan_iface_name = vlan_iface.devName
                _configure_iface_ip(vlan_iface_name, network_config)
                yield vlan_iface_name, client
        else:
            _configure_iface_ip(server, network_config)
            yield server, client
Exemplo n.º 4
0
    def test_add_net_on_existing_external_vlanned_bond(self):
        ADDRESS1 = '192.168.99.1'
        ADDRESS2 = '192.168.99.254'
        PREFIX = '29'
        with dummy_devices(2) as (nic1, nic2):
            with Bond(BOND_NAME, slaves=(nic1, nic2)) as bond:
                bond.create()
                bond.up()
                with vlan_device(bond.master) as vlan:
                    # Make slaves dirty intentionally and check if they recover
                    self._set_ip_address('1.1.1.1/29', nic1)
                    self._set_ip_address('1.1.1.2/29', nic2)

                    self._set_ip_address(ADDRESS1 + '/' + PREFIX, bond.master)
                    self._set_ip_address(ADDRESS2 + '/' + PREFIX, vlan.devName)

                    NETBASE = {
                        NETWORK1_NAME: {
                            'bonding': BOND_NAME,
                            'bridged': True,
                            'ipaddr': ADDRESS1,
                            'prefix': PREFIX,
                            'switch': 'legacy',
                        }
                    }
                    with adapter.setupNetworks(NETBASE, {}, NOCHK):
                        adapter.assertNetwork(NETWORK1_NAME,
                                              NETBASE[NETWORK1_NAME])
                        adapter.assertBond(
                            BOND_NAME,
                            {
                                'nics': [nic1, nic2],
                                'switch': 'legacy'
                            },
                        )

                        nic1_info = adapter.netinfo.nics[nic1]
                        nic2_info = adapter.netinfo.nics[nic2]
                        vlan_info = adapter.netinfo.vlans[vlan.devName]
                        assert nic1_info['ipv4addrs'] == []
                        assert nic2_info['ipv4addrs'] == []
                        assert vlan_info['ipv4addrs'] == [
                            ADDRESS2 + '/' + PREFIX
                        ]

            adapter.setupNetworks({}, {BOND_NAME: {'remove': True}}, NOCHK)
Exemplo n.º 5
0
    def test_add_vlan_network_on_existing_external_bond_with_used_slave(self):
        with dummy_devices(2) as (nic1, nic2):
            with Bond(BOND_NAME, slaves=(nic1, nic2)) as bond:
                bond.create()
                bond.up()
                with vlan_device(nic1):
                    NETBASE = {NETWORK1_NAME: {'bonding': BOND_NAME,
                                               'bridged': True,
                                               'switch': 'legacy',
                                               'vlan': 17}}

                    with pytest.raises(SetupNetworksError) as err:
                        with adapter.setupNetworks(NETBASE, {}, NOCHK):
                            pass

                    assert err.value.status == ne.ERR_USED_NIC
                    assert 'already used by' in err.value.msg
                bond.destroy()
Exemplo n.º 6
0
    def test_add_vlan_network_on_existing_external_bond_with_used_slave(
            self, adapter, bond0_with_slaves):
        bond, (nic0, _) = bond0_with_slaves
        with vlan_device(nic0):
            NETBASE = {
                NETWORK1_NAME: {
                    'bonding': bond,
                    'bridged': True,
                    'switch': 'legacy',
                    'vlan': 17,
                }
            }

            with pytest.raises(SetupNetworksError) as err:
                with adapter.setupNetworks(NETBASE, {}, NOCHK):
                    pass

            assert err.value.status == ne.ERR_USED_NIC
            assert 'Nics with multiple usages' in err.value.msg
Exemplo n.º 7
0
    def test_add_net_on_existing_external_vlanned_bond(self):
        ADDRESS1 = '192.168.99.1'
        ADDRESS2 = '192.168.99.254'
        PREFIX = '29'
        with dummy_devices(2) as (nic1, nic2):
            with Bond(BOND_NAME, slaves=(nic1, nic2)) as bond:
                bond.create()
                bond.up()
                with vlan_device(bond.master) as vlan:
                    # Make slaves dirty intentionally and check if they recover
                    self._set_ip_address('1.1.1.1/29', nic1)
                    self._set_ip_address('1.1.1.2/29', nic2)

                    self._set_ip_address(
                        ADDRESS1 + '/' + PREFIX, bond.master)
                    self._set_ip_address(
                        ADDRESS2 + '/' + PREFIX, vlan.devName)

                    NETBASE = {NETWORK1_NAME: {'bonding': BOND_NAME,
                                               'bridged': True,
                                               'ipaddr': ADDRESS1,
                                               'prefix': PREFIX,
                                               'switch': 'legacy'}}
                    with adapter.setupNetworks(NETBASE, {}, NOCHK):
                        adapter.assertNetwork(NETWORK1_NAME,
                                              NETBASE[NETWORK1_NAME])
                        adapter.assertBond(
                            BOND_NAME, {'nics': [nic1, nic2],
                                        'switch': 'legacy'
                                        })

                        nic1_info = adapter.netinfo.nics[nic1]
                        nic2_info = adapter.netinfo.nics[nic2]
                        vlan_info = adapter.netinfo.vlans[vlan.devName]
                        assert nic1_info['ipv4addrs'] == []
                        assert nic2_info['ipv4addrs'] == []
                        assert vlan_info['ipv4addrs'] == [
                            ADDRESS2 + '/' + PREFIX]

            adapter.setupNetworks({}, {BOND_NAME: {'remove': True}}, NOCHK)
Exemplo n.º 8
0
    def test_add_net_on_existing_external_vlanned_bond(self, adapter, nic0,
                                                       nic1):
        ADDRESS1 = '192.168.99.1'
        ADDRESS2 = '192.168.99.254'
        PREFIX = '29'
        bond = bond_without_remove(slaves=[nic0, nic1])
        with vlan_device(bond) as vlan:
            # Make slaves dirty intentionally and check if they recover
            self._set_ip_address(nic0, '1.1.1.1', PREFIX)
            self._set_ip_address(nic1, '1.1.1.2', PREFIX)

            self._set_ip_address(bond, ADDRESS1, PREFIX)
            self._set_ip_address(vlan, ADDRESS2, PREFIX)

            NETBASE = {
                NETWORK1_NAME: {
                    'bonding': bond,
                    'bridged': True,
                    'ipaddr': ADDRESS1,
                    'prefix': PREFIX,
                    'switch': 'legacy',
                }
            }
            with adapter.setupNetworks(NETBASE, {}, NOCHK):
                adapter.assertNetwork(NETWORK1_NAME, NETBASE[NETWORK1_NAME])
                adapter.assertBond(bond, {
                    'nics': [nic0, nic1],
                    'switch': 'legacy'
                })

                nic1_info = adapter.netinfo.nics[nic0]
                nic2_info = adapter.netinfo.nics[nic1]
                vlan_info = adapter.netinfo.vlans[vlan]
                assert nic1_info['ipv4addrs'] == []
                assert nic2_info['ipv4addrs'] == []
                assert vlan_info['ipv4addrs'] == [ADDRESS2 + '/' + PREFIX]
        adapter.setupNetworks({}, {bond: {'remove': True}}, NOCHK)
Exemplo n.º 9
0
def _vlan_device():
    with nettestlib.dummy_device() as nic:
        with nettestlib.vlan_device(nic, 101) as vlan:
            yield vlan.devName
Exemplo n.º 10
0
def vlan16(dummy):
    with vlan_device(dummy, tag=16) as vlan:
        yield vlan
Exemplo n.º 11
0
def vlan0(bond0):
    with vlan_device(bond0.master, 27) as vlan:
        yield vlan
Exemplo n.º 12
0
 def test_identify_vlan_base_device(self):
     with dummy_device() as nic:
         with vlan_device(nic, tag=999):
             self.assertTrue(vlan.is_base_device(nic))
Exemplo n.º 13
0
def _vlan_device():
    with nettestlib.dummy_device() as nic:
        with nettestlib.vlan_device(nic, 101) as vlan:
            yield vlan.devName
Exemplo n.º 14
0
 def test_identify_vlan_base_device(self):
     with dummy_device() as nic:
         with vlan_device(nic, tag=999):
             self.assertTrue(vlan.is_base_device(nic))
Exemplo n.º 15
0
 def test_list_vlans_on_base_device(self):
     with dummy_device() as nic:
         with vlan_device(nic, tag=999) as vlan_dev:
             self.assertEqual([vlan_dev.devName],
                              list(vlan.get_vlans_on_base_device(nic)))
Exemplo n.º 16
0
def vlan17(dummy):
    with vlan_device(dummy, tag=17) as vlan:
        yield vlan
Exemplo n.º 17
0
def vlan17(dummy):
    with vlan_device(dummy, VLAN17_TAG) as vlan:
        yield vlan
Exemplo n.º 18
0
def vlan999(nic0):
    with vlan_device(nic0, tag=999) as vlan_dev:
        yield vlan_dev
Exemplo n.º 19
0
def _vlan_device():
    with dummy_device() as nic:
        with vlan_device(nic, 101) as vlan:
            yield vlan
Exemplo n.º 20
0
def vlan0(bond0):
    with vlan_device(bond0, 27) as vlan:
        yield vlan