コード例 #1
0
ファイル: native_networks.py プロジェクト: saacg/hil
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(model.Project, 'anvil-nextgen')
            nodes = project.nodes
            ports = self.get_all_ports(nodes)

            # Remove all nodes from their networks. We do this in two different
            # ways for different ports to test the different mechanisms. For
            # the first two nodes we explicity remove the attachments. For the
            # latter two we call port_revert.
            for node in nodes[:2]:
                attachment = model.NetworkAttachment.query \
                    .filter_by(nic=node.nics[0]).one()
                api.node_detach_network(node.label, node.nics[0].label,
                                        attachment.network.label)
            for node in nodes[2:]:
                port = node.nics[0].port
                api.port_revert(port.owner.label, port.label)
            deferred.apply_networking()

            # Assert that none of the nodes are on any network
            port_networks = self.get_port_networks(ports)
            for node in nodes:
                assert self.get_network(node.nics[0].port, port_networks) == \
                    set()

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #2
0
ファイル: vlan_networks.py プロジェクト: gvsurenderreddy/hil
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(model.Project, 'anvil-nextgen')
            nodes = project.nodes
            ports = self.get_all_ports(nodes)

            # Remove all nodes from their networks. We first build up a list of
            # the arguments to the API calls, which has no direct references to
            # database objects, and then make the API calls and invoke
            # deferred.apply_networking after. This is important --
            # The API calls and apply_networking normally run in their own
            # transaction. We get away with not doing this in the tests because
            # we serialize everything ourselves, so there's no risk of
            # interference. If we were to hang on to references to database
            # objects across such calls however, things could get harry.
            all_attachments = []
            for node in nodes:
                attachments = model.NetworkAttachment.query \
                    .filter_by(nic=node.nics[0]).all()
                for attachment in attachments:
                    all_attachments.append((node.label,
                                            node.nics[0].label,
                                            attachment.network.label))
            for attachment in all_attachments:
                api.node_detach_network(*attachment)
                deferred.apply_networking()

            # Assert that none of the nodes are on any network
            port_networks = self.get_port_networks(ports)
            for node in nodes:
                assert self.get_network(node.nics[0].port, port_networks) == set()

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #3
0
ファイル: vlan_networks.py プロジェクト: sarthakjagetia/hil
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(model.Project, 'anvil-nextgen')
            nodes = project.nodes
            ports = self.get_all_ports(nodes)

            # Remove all nodes from their networks. We first build up a list of
            # the arguments to the API calls, which has no direct references to
            # database objects, and then make the API calls and invoke
            # deferred.apply_networking after. This is important --
            # The API calls and apply_networking normally run in their own
            # transaction. We get away with not doing this in the tests because
            # we serialize everything ourselves, so there's no risk of
            # interference. If we were to hang on to references to database
            # objects across such calls however, things could get harry.
            all_attachments = []
            for node in nodes:
                attachments = model.NetworkAttachment.query \
                    .filter_by(nic=node.nics[0]).all()
                for attachment in attachments:
                    all_attachments.append((node.label, node.nics[0].label,
                                            attachment.network.label))
            for attachment in all_attachments:
                api.node_detach_network(*attachment)
                deferred.apply_networking()

            # Assert that none of the nodes are on any network
            port_networks = self.get_port_networks(ports)
            for node in nodes:
                assert self.get_network(node.nics[0].port, port_networks) == \
                    set()

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #4
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()
コード例 #5
0
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(db, model.Project, 'anvil-nextgen')
            nodes = project.nodes

            # Remove all nodes from their networks
            for node in nodes:
                if node.nics[0].network is not None:
                    api.node_detach_network(node.label, node.nics[0].label)
            deferred.apply_networking()

            # Assert that none of the nodes are on any network
            vlan_cfgs = get_switch_vlans()
            for node in nodes:
                assert get_network(node.nics[0].label, vlan_cfgs) == []

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #6
0
ファイル: deployment.py プロジェクト: SahilTikale/switchHaaS
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(db, model.Project, 'anvil-nextgen')
            nodes = project.nodes

            # Remove all nodes from their networks
            for node in nodes:
                if node.nics[0].network is not None:
                    api.node_detach_network(node.label, node.nics[0].label)
            deferred.apply_networking()

            # Assert that none of the nodes are on any network
            vlan_cfgs = get_switch_vlans()
            for node in nodes:
                assert get_network(node.nics[0].label, vlan_cfgs) == []

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #7
0
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(db, model.Project, "anvil-nextgen")
            nodes = project.nodes
            ports = self.get_all_ports(nodes)

            # Remove all nodes from their networks
            for node in nodes:
                attachment = db.query(model.NetworkAttachment).filter_by(nic=node.nics[0]).one()
                api.node_detach_network(node.label, node.nics[0].label, attachment.network.label)
            deferred.apply_networking()

            # Assert that none of the nodes are on any network
            port_networks = self.get_port_networks(ports)
            for node in nodes:
                assert self.get_network(node.nics[0].port, port_networks) == set()

            # Delete the networks
            api.network_delete("net-0")
            api.network_delete("net-1")
コード例 #8
0
        def delete_networks():
            # Query the DB for nodes on this project
            project = api._must_find(model.Project, 'anvil-nextgen')
            nodes = project.nodes
            ports = self.get_all_ports(nodes)

            # Remove all nodes from their networks
            for node in nodes:
                attachment = model.NetworkAttachment.query \
                    .filter_by(nic=node.nics[0]).one()
                api.node_detach_network(node.label, node.nics[0].label,
                                        attachment.network.label)
            deferred.apply_networking()

            # Assert that none of the nodes are on any network
            port_networks = self.get_port_networks(ports)
            for node in nodes:
                assert self.get_network(node.nics[0].port, port_networks) == \
                    set()

            # Delete the networks
            api.network_delete('net-0')
            api.network_delete('net-1')
コード例 #9
0
ファイル: auth.py プロジェクト: henn/hil
 def test_wrong_project(self):
     self.auth_backend.set_project(self.runway)
     with pytest.raises(AuthorizationError):
         api.node_detach_network('manhattan_node_0', 'boot-nic', 'stock_int_pub')
コード例 #10
0
ファイル: auth.py プロジェクト: henn/hil
 def test_success(self):
     self.auth_backend.set_project(self.manhattan)
     api.node_detach_network('manhattan_node_0', 'boot-nic', 'stock_int_pub')
コード例 #11
0
ファイル: auth.py プロジェクト: CCI-MOC/hil
 def test_success(self):
     self.auth_backend.set_project(self.manhattan)
     api.node_detach_network("manhattan_node_0", "boot-nic", "stock_int_pub")
コード例 #12
0
 def test_wrong_project(self):
     self.auth_backend.set_project(self.runway)
     with pytest.raises(AuthorizationError):
         api.node_detach_network('manhattan_node_0', 'boot-nic',
                                 'stock_int_pub')
コード例 #13
0
 def test_success(self):
     self.auth_backend.set_project(self.manhattan)
     api.node_detach_network('manhattan_node_0', 'boot-nic',
                             'stock_int_pub')