Esempio n. 1
0
    def test_saving_config_file(self):
        """Test saving the switch config to flash."""
        api.project_create('anvil-nextgen')
        nodes = self.collect_nodes()

        # Create two networks
        network_create_simple('net-0', 'anvil-nextgen')
        network_create_simple('net-1', 'anvil-nextgen')

        # save the old startup config before performing a networking action
        old_startup_config = self.get_config('startup')
        # Connect n0 and n1 to net-0 and net-1 respectively
        api.node_connect_network(nodes[0].label, nodes[0].nics[0].label,
                                 'net-0')

        api.node_connect_network(nodes[1].label, nodes[1].nics[0].label,
                                 'net-1')

        deferred.apply_networking()

        # get the running config, and the new startup config
        running_config = self.get_config('running')
        new_startup_config = self.get_config('startup')

        assert new_startup_config == running_config
        assert new_startup_config != old_startup_config

        # cleanup
        api.node_detach_network(nodes[0].label, nodes[0].nics[0].label,
                                'net-0')

        api.node_detach_network(nodes[1].label, nodes[1].nics[0].label,
                                'net-1')

        deferred.apply_networking()
Esempio n. 2
0
def test_ensure_legal_operations():
    """Test to ensure that ensure_legal_operations works as expected"""

    # create a project and a network
    api.project_create('anvil-nextgen')
    network_create_simple('hammernet', 'anvil-nextgen')
    network_create_simple('pineapple', 'anvil-nextgen')

    # register a switch of type dellnos9 and add a port to it
    api.switch_register('s3048',
                        type=SWITCH_TYPE,
                        username="******",
                        password="******",
                        hostname="switchname",
                        interface_type="GigabitEthernet")
    api.switch_register_port('s3048', '1/3')
    switch = api.get_or_404(model.Switch, 's3048')

    # register a ndoe and a nic
    api.node_register(
        node='compute-01',
        obmd={
            'uri': 'http://obmd.example.com',
            'admin_token': 'secret',
        },
    )
    api.project_connect_node('anvil-nextgen', 'compute-01')
    api.node_register_nic('compute-01', 'eth0', 'DE:AD:BE:EF:20:14')
    nic = api.get_or_404(model.Nic, 'eth0')

    api.port_connect_nic('s3048', '1/3', 'compute-01', 'eth0')

    # connecting a trunked network wihtout having a native should fail.
    # call the method directly and test the API too.
    with pytest.raises(BlockedError):
        switch.ensure_legal_operation(nic, 'connect', 'vlan/1212')

    with pytest.raises(BlockedError):
        api.node_connect_network('compute-01', 'eth0', 'hammernet', 'vlan/40')

    # doing these operations in the correct order, that is native network first
    # and then trunked, should work.
    api.node_connect_network('compute-01', 'eth0', 'hammernet', 'vlan/native')
    mock_networking_action()
    api.node_connect_network('compute-01', 'eth0', 'pineapple', 'vlan/41')
    mock_networking_action()

    # removing these networks in the wrong order should not work.
    with pytest.raises(BlockedError):
        switch.ensure_legal_operation(nic, 'detach', 'vlan/native')

    with pytest.raises(BlockedError):
        api.node_detach_network('compute-01', 'eth0', 'hammernet')

    # removing networks in the right order should work
    api.node_detach_network('compute-01', 'eth0', 'pineapple')
    mock_networking_action()
    api.node_detach_network('compute-01', 'eth0', 'hammernet')
    mock_networking_action()
    db.session.close()
Esempio n. 3
0
def test_ensure_legal_operations():
    """Test to ensure that ensure_legal_operations works as expected"""

    # create a project and a network
    api.project_create('anvil-nextgen')
    network_create_simple('hammernet', 'anvil-nextgen')
    network_create_simple('pineapple', 'anvil-nextgen')

    # register a switch of type dellnos9 and add a port to it
    api.switch_register('s3048',
                        type=SWITCH_TYPE,
                        username="******",
                        password="******",
                        hostname="switchname",
                        interface_type="GigabitEthernet")
    api.switch_register_port('s3048', '1/3')
    switch = api.get_or_404(model.Switch, 's3048')

    # register a ndoe and a nic
    api.node_register(
        node='compute-01',
        obmd={
            'uri': 'http://obmd.example.com',
            'admin_token': 'secret',
        },
    )
    api.project_connect_node('anvil-nextgen', 'compute-01')
    api.node_register_nic('compute-01', 'eth0', 'DE:AD:BE:EF:20:14')
    nic = api.get_or_404(model.Nic, 'eth0')

    api.port_connect_nic('s3048', '1/3', 'compute-01', 'eth0')

    # connecting a trunked network wihtout having a native should fail.
    # call the method directly and test the API too.
    with pytest.raises(BlockedError):
        switch.ensure_legal_operation(nic, 'connect', 'vlan/1212')

    with pytest.raises(BlockedError):
        api.node_connect_network('compute-01', 'eth0', 'hammernet', 'vlan/40')

    # doing these operations in the correct order, that is native network first
    # and then trunked, should work.
    api.node_connect_network('compute-01', 'eth0', 'hammernet', 'vlan/native')
    mock_networking_action()
    api.node_connect_network('compute-01', 'eth0', 'pineapple', 'vlan/41')
    mock_networking_action()

    # removing these networks in the wrong order should not work.
    with pytest.raises(BlockedError):
        switch.ensure_legal_operation(nic, 'detach', 'vlan/native')

    with pytest.raises(BlockedError):
        api.node_detach_network('compute-01', 'eth0', 'hammernet')

    # removing networks in the right order should work
    api.node_detach_network('compute-01', 'eth0', 'pineapple')
    mock_networking_action()
    api.node_detach_network('compute-01', 'eth0', 'hammernet')
    mock_networking_action()
    db.session.close()
Esempio n. 4
0
        def create_multi_nets():
            """Create multiple networks and connect them all to one port.

            Test that each network can be successfully added and discovered
            on the port.
            """

            nodes = self.collect_nodes()

            # create 5 networks
            for i in range(5):
                network_create_simple('net-%d' % i, 'anvil-nextgen')

            ports = self.get_all_ports(nodes)

            # assert that node 0 is not on any network
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()

            # get channel IDs for tagged versions of networks
            net_tag = {}
            for i in range(4):
                net_tag[i] = get_legal_channels('net-%d' % i)[1]

            # connect node 0 to net-0 in native mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-0')
            deferred.apply_networking()
            # connect node 0 to net-1 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            # connect node 0 to net-2 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-2',
                                     channel=net_tag[2])
            deferred.apply_networking()
            # connect node 0 to net-3 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-3',
                                     channel=net_tag[3])
            deferred.apply_networking()

            # assert that all networks show up on the port
            port_networks = self.get_port_networks(ports)
            networks = \
                set([net for net,
                    _channel in port_networks.get(nodes[0].nics[0].port)])
            # create a list of networks with native net-0 included
            networks_added = set([get_legal_channels('net-0')[0],
                                 net_tag[1],
                                 net_tag[2], net_tag[3]])
            assert networks == networks_added
Esempio n. 5
0
        def create_multi_nets():
            """Create multiple networks and connect them all to one port.

            Test that each network can be successfully added and discovered
            on the port.
            """

            nodes = self.collect_nodes()

            # create 5 networks
            for i in range(5):
                network_create_simple('net-%d' % i, 'anvil-nextgen')

            ports = self.get_all_ports(nodes)

            # assert that node 0 is not on any network
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()

            # get channel IDs for tagged versions of networks
            net_tag = {}
            for i in range(4):
                net_tag[i] = get_legal_channels('net-%d' % i)[1]

            # connect node 0 to net-0 in native mode
            api.node_connect_network(nodes[0].label, nodes[0].nics[0].label,
                                     'net-0')
            deferred.apply_networking()
            # connect node 0 to net-1 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            # connect node 0 to net-2 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-2',
                                     channel=net_tag[2])
            deferred.apply_networking()
            # connect node 0 to net-3 in tagged mode
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-3',
                                     channel=net_tag[3])
            deferred.apply_networking()

            # assert that all networks show up on the port
            port_networks = self.get_port_networks(ports)
            networks = \
                set([net for net,
                    _channel in port_networks.get(nodes[0].nics[0].port)])
            # create a list of networks with native net-0 included
            networks_added = set([
                get_legal_channels('net-0')[0], net_tag[1], net_tag[2],
                net_tag[3]
            ])
            assert networks == networks_added
Esempio n. 6
0
        def create_networks():
            """Create networks and connect things to them.

            Test various things along the way.
            """
            nodes = self.collect_nodes()

            # Create two networks
            network_create_simple('net-0', 'anvil-nextgen')
            network_create_simple('net-1', 'anvil-nextgen')

            ports = self.get_all_ports(nodes)

            # Assert that n0 and n1 are not on any network
            port_networks = self.get_port_networks(ports)

            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set()

            # Connect n0 and n1 to net-0 and net-1 respectively
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-0')
            api.node_connect_network(nodes[1].label,
                                     nodes[1].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n0 and n1 are on isolated networks
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port])

            # Add n2 and n3 to the same networks as n0 and n1 respectively
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-0')
            api.node_connect_network(nodes[3].label,
                                     nodes[3].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n2 and n3 have been added to n0 and n1's networks
            # respectively
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port, nodes[2].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port, nodes[3].nics[0].port])
Esempio n. 7
0
 def test_headnode(self):
     api.project_create('anvil-nextgen')
     network_create_simple('spider-web', 'anvil-nextgen')
     api.headnode_create('hn-0', 'anvil-nextgen', 'base-headnode')
     api.headnode_create_hnic('hn-0', 'hnic-0')
     api.headnode_connect_network('hn-0', 'hnic-0', 'spider-web')
     if have_dry_run():
         pytest.xfail("Running in dry-run mode; can't talk to libvirt.")
     assert json.loads(api.show_headnode('hn-0'))['vncport'] is None
     api.headnode_start('hn-0')
     assert json.loads(api.show_headnode('hn-0'))['vncport'] is not None
     api.headnode_stop('hn-0')
     api.headnode_delete('hn-0')
Esempio n. 8
0
        def create_networks():
            """Create networks and connect things to them.

            Test various things along the way.
            """
            nodes = self.collect_nodes()

            # Create two networks
            network_create_simple('net-0', 'anvil-nextgen')
            network_create_simple('net-1', 'anvil-nextgen')

            ports = self.get_all_ports(nodes)

            # Assert that n0 and n1 are not on any network
            port_networks = self.get_port_networks(ports)

            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set()

            # Connect n0 and n1 to net-0 and net-1 respectively
            api.node_connect_network(nodes[0].label, nodes[0].nics[0].label,
                                     'net-0')
            api.node_connect_network(nodes[1].label, nodes[1].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n0 and n1 are on isolated networks
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port])

            # Add n2 and n3 to the same networks as n0 and n1 respectively
            api.node_connect_network(nodes[2].label, nodes[2].nics[0].label,
                                     'net-0')
            api.node_connect_network(nodes[3].label, nodes[3].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n2 and n3 have been added to n0 and n1's networks
            # respectively
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port, nodes[2].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port, nodes[3].nics[0].port])
Esempio n. 9
0
    def test_saving_config_file(self):

        api.project_create('anvil-nextgen')
        nodes = self.collect_nodes()

        # Create two networks
        network_create_simple('net-0', 'anvil-nextgen')
        network_create_simple('net-1', 'anvil-nextgen')

        # save the old startup config before performing a networking action
        old_startup_config = self.get_config('startup')
        # Connect n0 and n1 to net-0 and net-1 respectively
        api.node_connect_network(nodes[0].label,
                                 nodes[0].nics[0].label,
                                 'net-0')

        api.node_connect_network(nodes[1].label,
                                 nodes[1].nics[0].label,
                                 'net-1')

        deferred.apply_networking()

        # get the running config, and the new startup config
        running_config = self.get_config('running')
        new_startup_config = self.get_config('startup')

        assert new_startup_config == running_config
        assert new_startup_config != old_startup_config

        # cleanup
        api.node_detach_network(nodes[0].label,
                                nodes[0].nics[0].label,
                                'net-0')

        api.node_detach_network(nodes[1].label,
                                nodes[1].nics[0].label,
                                'net-1')

        deferred.apply_networking()
Esempio n. 10
0
    def test_headnode(self):
        """Test each of the headnode related operations

        * create
        * connect_hnic,
        * connect_network
        * start
        * stop
        * delete
        """
        api.project_create('anvil-nextgen')
        network_create_simple('spider-web', 'anvil-nextgen')
        api.headnode_create('hn-0', 'anvil-nextgen', 'base-headnode')
        api.headnode_create_hnic('hn-0', 'hnic-0')
        api.headnode_connect_network('hn-0', 'hnic-0', 'spider-web')
        if have_dry_run():
            pytest.xfail("Running in dry-run mode; can't talk to libvirt.")
        assert json.loads(api.show_headnode('hn-0'))['vncport'] is None
        api.headnode_start('hn-0')
        assert json.loads(api.show_headnode('hn-0'))['vncport'] is not None
        api.headnode_stop('hn-0')
        api.headnode_delete('hn-0')
Esempio n. 11
0
        def create_networks():
            """Create networks and connect things to them.

            Test various things along the way.
            """
            nodes = self.collect_nodes()

            # Create four networks
            network_create_simple('net-0', 'anvil-nextgen')
            network_create_simple('net-1', 'anvil-nextgen')
            network_create_simple('net-2', 'anvil-nextgen')
            network_create_simple('net-3', 'anvil-nextgen')

            ports = self.get_all_ports(nodes)
            # get the switch name from any of the nics
            switch = nodes[0].nics[0].port.owner

            # Assert that n0 and n1 are not on any network
            port_networks = self.get_port_networks(ports)

            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set()

            # Get the channel ids for the tagged versions of the networks:
            net_tag = {}
            net_tag[0] = get_legal_channels('net-0')[1]
            net_tag[1] = get_legal_channels('net-1')[1]
            net_tag[2] = get_legal_channels('net-2')[1]

            # Connect node 0 to net-0 (native mode)
            api.node_connect_network(nodes[0].label, nodes[0].nics[0].label,
                                     'net-0')

            # before connecting node 1 to net-1 in tagged mode, we must check
            # if the switch supports nativeless trunk mode; if not, then we
            # add some native network and perform additional checks before
            # proceeding.
            if 'nativeless-trunk-mode' not in switch.get_capabilities():
                # connecting the first network as tagged should raise an error
                with pytest.raises(errors.BlockedError):
                    api.node_connect_network(nodes[1].label,
                                             nodes[1].nics[0].label,
                                             'net-2',
                                             channel=net_tag[2])
                api.node_connect_network(nodes[1].label,
                                         nodes[1].nics[0].label, 'net-2')
                deferred.apply_networking()

            # Connect node 1 to net-1 (tagged mode)
            api.node_connect_network(nodes[1].label,
                                     nodes[1].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            # Assert that n0 and n1 are on isolated networks
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port])

            # Add n2 and n3 to the same networks as n0 and n1 respectively, but
            # with different channels (native vs. tagged)
            if 'nativeless-trunk-mode' not in switch.get_capabilities():
                api.node_connect_network(nodes[2].label,
                                         nodes[2].nics[0].label, 'net-3')
                deferred.apply_networking()
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-0',
                                     channel=net_tag[0])

            api.node_connect_network(nodes[3].label, nodes[3].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n2 and n3 have been added to n0 and n1's networks
            # respectively
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port, nodes[2].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port, nodes[3].nics[0].port])

            # Verify that we can put nodes on more than one network, with
            # different channels:

            # at this point, node-2 is connected to net-0 (tagged)
            # and depending on the switch, to net-3 (native). Let's connect it
            # to net-1 (tagged) (which node-1 is connected to)
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            port_networks = self.get_port_networks(ports)
            # assert that node-2 was added to node-1's network correctly.
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port,
                     nodes[2].nics[0].port,
                     nodes[3].nics[0].port])
Esempio n. 12
0
        def create_networks():
            """Create networks and connect things to them.

            Test various things along the way.
            """
            nodes = self.collect_nodes()

            # Create two networks
            network_create_simple('net-0', 'anvil-nextgen')
            network_create_simple('net-1', 'anvil-nextgen')

            ports = self.get_all_ports(nodes)

            # Assert that n0 and n1 are not on any network
            port_networks = self.get_port_networks(ports)

            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set()

            # Get the channel ids for the tagged versions of the networks:
            net_tag = {}
            net_tag[0] = get_legal_channels('net-0')[1]
            net_tag[1] = get_legal_channels('net-1')[1]

            # Connect node 0 to net-0 (native mode)
            api.node_connect_network(nodes[0].label, nodes[0].nics[0].label,
                                     'net-0')
            # Connect node 1 to net-1 (tagged mode)
            api.node_connect_network(nodes[1].label,
                                     nodes[1].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()

            # Assert that n0 and n1 are on isolated networks
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port])

            # Add n2 and n3 to the same networks as n0 and n1 respectively, but
            # with different channels (native vs. tagged)
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-0',
                                     channel=net_tag[0])
            api.node_connect_network(nodes[3].label, nodes[3].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n2 and n3 have been added to n0 and n1's networks
            # respectively
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port, nodes[2].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port, nodes[3].nics[0].port])

            # Verify that we can put nodes on more than one network, with
            # different channels:
            api.node_connect_network(nodes[2].label, nodes[2].nics[0].label,
                                     'net-1')
            deferred.apply_networking()
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port,
                     nodes[2].nics[0].port,
                     nodes[3].nics[0].port])
Esempio n. 13
0
        def create_networks():
            """Create networks and connect things to them.

            Test various things along the way.
            """
            nodes = self.collect_nodes()

            # Create four networks
            network_create_simple('net-0', 'anvil-nextgen')
            network_create_simple('net-1', 'anvil-nextgen')
            network_create_simple('net-2', 'anvil-nextgen')
            network_create_simple('net-3', 'anvil-nextgen')

            ports = self.get_all_ports(nodes)
            # get the switch name from any of the nics
            switch = nodes[0].nics[0].port.owner

            # Assert that n0 and n1 are not on any network
            port_networks = self.get_port_networks(ports)

            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set()
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set()

            # Get the channel ids for the tagged versions of the networks:
            net_tag = {}
            net_tag[0] = get_legal_channels('net-0')[1]
            net_tag[1] = get_legal_channels('net-1')[1]
            net_tag[2] = get_legal_channels('net-2')[1]

            # Connect node 0 to net-0 (native mode)
            api.node_connect_network(nodes[0].label,
                                     nodes[0].nics[0].label,
                                     'net-0')

            # before connecting node 1 to net-1 in tagged mode, we must check
            # if the switch supports nativeless trunk mode; if not, then we
            # add some native network and perform additional checks before
            # proceeding.
            if 'nativeless-trunk-mode' not in switch.get_capabilities():
                # connecting the first network as tagged should raise an error
                with pytest.raises(errors.BlockedError):
                    api.node_connect_network(nodes[1].label,
                                             nodes[1].nics[0].label,
                                             'net-2',
                                             channel=net_tag[2])
                api.node_connect_network(nodes[1].label,
                                         nodes[1].nics[0].label,
                                         'net-2')
                deferred.apply_networking()

            # Connect node 1 to net-1 (tagged mode)
            api.node_connect_network(nodes[1].label,
                                     nodes[1].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            # Assert that n0 and n1 are on isolated networks
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port])

            # Add n2 and n3 to the same networks as n0 and n1 respectively, but
            # with different channels (native vs. tagged)
            if 'nativeless-trunk-mode' not in switch.get_capabilities():
                api.node_connect_network(nodes[2].label,
                                         nodes[2].nics[0].label,
                                         'net-3')
                deferred.apply_networking()
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-0',
                                     channel=net_tag[0])

            api.node_connect_network(nodes[3].label,
                                     nodes[3].nics[0].label,
                                     'net-1')
            deferred.apply_networking()

            # Assert that n2 and n3 have been added to n0 and n1's networks
            # respectively
            port_networks = self.get_port_networks(ports)
            assert self.get_network(nodes[0].nics[0].port, port_networks) == \
                set([nodes[0].nics[0].port, nodes[2].nics[0].port])
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port, nodes[3].nics[0].port])

            # Verify that we can put nodes on more than one network, with
            # different channels:

            # at this point, node-2 is connected to net-0 (tagged)
            # and depending on the switch, to net-3 (native). Let's connect it
            # to net-1 (tagged) (which node-1 is connected to)
            api.node_connect_network(nodes[2].label,
                                     nodes[2].nics[0].label,
                                     'net-1',
                                     channel=net_tag[1])
            deferred.apply_networking()
            port_networks = self.get_port_networks(ports)
            # assert that node-2 was added to node-1's network correctly.
            assert self.get_network(nodes[1].nics[0].port, port_networks) == \
                set([nodes[1].nics[0].port,
                     nodes[2].nics[0].port,
                     nodes[3].nics[0].port])