예제 #1
0
    def test_create_network_type_vlan_with_physical_net_and_seg_id(self):
        """
        Tests the creation of an OpenStack network of type vlan with
        specified physical network and segmentation id.
        """
        # Create Network
        network_type = 'vlan'

        # The two values must be variable to work on all OpenStack pods
        physical_network = 'datacentre'
        segmentation_id = 2366

        net_settings = NetworkConfig(
            name=self.net_config.network_settings.name,
            subnet_settings=self.net_config.network_settings.subnet_settings,
            network_type=network_type,
            physical_network=physical_network,
            segmentation_id=segmentation_id)

        # When setting the network_type, creds must be admin
        self.net_creator = OpenStackNetwork(self.os_creds, net_settings)
        network = self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone, net_settings.name, True,
            self.os_creds.project_name))

        self.assertEquals(network_type, network.type)
예제 #2
0
    def test_create_network_one_ipv6_subnet(self):
        """
        Tests the creation of an OpenStack network without a router.
        """
        # Create Network
        subnet_settings = SubnetConfig(
            name=self.guid + '-subnet', cidr='1:1:0:0:0:0:0:0/64',
            ip_version=6)
        network_settings = NetworkConfig(
            name=self.guid + '-net', subnet_settings=[subnet_settings])

        self.net_creator = OpenStackNetwork(self.os_creds, network_settings)
        self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone,
            self.net_creator.network_settings.name, True,
            self.os_creds.project_name))

        network = self.net_creator.get_network()
        self.assertEqual(1, len(network.subnets))
        subnet = network.subnets[0]

        self.assertEqual(network.id, subnet.network_id)
        self.assertEqual(subnet_settings.name, subnet.name)
        self.assertEqual('1:1::/64', subnet.cidr)
        self.assertEqual(6, subnet.ip_version)
        self.assertEqual(0, len(subnet.dns_nameservers))
예제 #3
0
    def test_create_subnet_no_gateway(self):
        """
        Tests the creation of an OpenStack network with a subnet that has a
        valid value assigned to the gateway IP.
        """
        # Create Network
        subnet_config = SubnetConfig(
            name=self.guid + '-subnet', cidr=self.ip_prfx + '0/24',
            gateway_ip='none')
        net_config = NetworkConfig(
            name=self.guid + '-net', subnets=[subnet_config])
        self.net_creator = OpenStackNetwork(
            self.os_creds, net_config)
        out_net = self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone,
            self.net_creator.network_settings.name, True,
            self.os_creds.project_name))

        # Validate subnets
        self.assertTrue(neutron_utils_tests.validate_subnet(
            self.neutron, out_net,
            self.net_creator.network_settings.subnet_settings[0].name,
            self.net_creator.network_settings.subnet_settings[0].cidr, True))

        self.assertIsNone(out_net.subnets[0].gateway_ip)
예제 #4
0
    def test_create_network_without_router(self):
        """
        Tests the creation of an OpenStack network without a router.
        """
        # Create Network
        self.net_creator = OpenStackNetwork(
            self.os_creds, self.net_config.network_settings)
        network = self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone,
            self.net_creator.network_settings.name, True,
            self.os_creds.project_name, mtu=999))

        # Validate subnets
        self.assertTrue(neutron_utils_tests.validate_subnet(
            self.neutron, network,
            self.net_creator.network_settings.subnet_settings[0].name,
            self.net_creator.network_settings.subnet_settings[0].cidr, True))
예제 #5
0
    def test_create_network_type_vxlan(self):
        """
        Tests the creation of an OpenStack network of type vxlan.
        """
        # Create Network
        network_type = 'vxlan'
        net_settings = NetworkConfig(
            name=self.net_config.network_settings.name,
            subnet_settings=self.net_config.network_settings.subnet_settings,
            network_type=network_type)

        # When setting the network_type, creds must be admin
        self.net_creator = OpenStackNetwork(self.os_creds, net_settings)
        network = self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone, net_settings.name, True,
            self.os_creds.project_name))

        self.assertEqual(network_type, network.type)
예제 #6
0
    def test_create_network_type_flat(self):
        """
        Tests the creation of an OpenStack network of type flat.
        """
        # Create Network
        network_type = 'flat'

        # This value must be variable to work on all OpenStack pods
        physical_network = 'datacentre'

        net_settings = NetworkConfig(
            name=self.net_config.network_settings.name,
            subnet_settings=self.net_config.network_settings.subnet_settings,
            network_type=network_type, physical_network=physical_network)
        self.net_creator = OpenStackNetwork(self.os_creds, net_settings)
        network = self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone, net_settings.name, True,
            self.os_creds.project_name))

        self.assertEquals(network_type, network.type)
예제 #7
0
    def test_create_network_with_router(self):
        """
        Tests the creation of an OpenStack network with a router.
        """
        # Create Network
        self.net_creator = OpenStackNetwork(
            self.os_creds, self.net_config.network_settings)
        network = self.net_creator.create()

        # Create Router
        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, self.net_config.router_settings)
        self.router_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone,
            self.net_creator.network_settings.name, True,
            self.os_creds.project_name, mtu=999))

        # Validate subnets
        self.assertTrue(neutron_utils_tests.validate_subnet(
            self.neutron, network,
            self.net_creator.network_settings.subnet_settings[0].name,
            self.net_creator.network_settings.subnet_settings[0].cidr, True))

        # Validate routers
        neutron_utils_tests.validate_router(
            self.neutron, self.keystone,
            self.router_creator.router_settings.name,
            self.os_creds.project_name, True)

        neutron_utils_tests.validate_interface_router(
            self.router_creator.get_internal_router_interface(),
            self.router_creator.get_router(),
            self.net_creator.get_network().subnets[0])
예제 #8
0
    def test_create_delete_network(self):
        """
        Tests the creation of an OpenStack network, it's deletion, then cleanup
        """
        # Create Network
        self.net_creator = OpenStackNetwork(
            self.os_creds, self.net_config.network_settings)
        self.net_creator.create()

        # Validate network was created
        self.assertTrue(neutron_utils_tests.validate_network(
            self.neutron, self.keystone,
            self.net_creator.network_settings.name, True,
            self.os_creds.project_name, mtu=999))

        neutron_utils.delete_network(
            self.neutron, self.net_creator.get_network())
        self.assertIsNone(neutron_utils.get_network(
            self.neutron, self.keystone,
            network_settings=self.net_creator.network_settings,
            project_name=self.os_creds.project_name))

        # This shall not throw an exception here
        self.net_creator.clean()