コード例 #1
0
    def test_create_router_admin_ports(self):
        """
        Test creation of a router with ports to subnets owned by the admin
        project
        """
        network_settings = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1',
                                            gateway_ip=static_gateway_ip1)
            ])
        self.network_creator = OpenStackNetwork(self.admin_os_creds,
                                                network_settings)
        self.network_creator.create()

        port_settings = [
            create_network.PortConfig(
                name=self.guid + '-port1',
                ip_addrs=[{
                    'subnet_name': network_settings.subnet_settings[0].name,
                    'ip': static_gateway_ip1
                }],
                network_name=network_settings.name)
        ]

        router_settings = RouterConfig(name=self.guid + '-pub-router',
                                       external_gateway=self.ext_net_name,
                                       port_settings=port_settings)
        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, router_settings)

        with self.assertRaises(PortConfigError):
            self.router_creator.create()
コード例 #2
0
    def test_create_router_secure_port(self):
        """
        Test creation of a router with a port that has a security group.
        """
        network_settings = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1')
            ])
        self.network_creator = OpenStackNetwork(self.os_creds,
                                                network_settings)
        self.network_creator.create()

        port_settings = [
            create_network.PortConfig(
                name=self.guid + '-port1',
                ip_addrs=[{
                    'subnet_name': network_settings.subnet_settings[0].name,
                    'ip': static_gateway_ip1
                }],
                network_name=network_settings.name,
                security_groups=[self.sec_grp_creator.sec_grp_settings.name])
        ]

        router_settings = RouterConfig(name=self.guid + '-pub-router',
                                       external_gateway=self.ext_net_name,
                                       port_settings=port_settings)
        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, router_settings)
        self.router_creator.create()
コード例 #3
0
    def test_create_with_invalid_internal_sub(self):
        """
        Test adding an internal subnet owned by admin which should fail.
        """
        network_settings1 = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1',
                                            gateway_ip=static_gateway_ip1)
            ])
        self.network_creator1 = OpenStackNetwork(self.admin_os_creds,
                                                 network_settings1)

        self.network_creator1.create()
        self.router_settings = RouterConfig(
            name=self.guid + '-pub-router',
            external_gateway=self.ext_net_name,
            internal_subnets=[network_settings1.subnet_settings[0].name])

        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, self.router_settings)

        with self.assertRaises(RouterCreationError):
            self.router_creator.create()
コード例 #4
0
    def setUp(self):
        """
        Initializes objects used for router testing
        """
        super(self.__class__, self).__start__()

        self.guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
        self.router_creator = None

        ext_network_settings = NetworkConfig(
            name=self.guid + '-ext-net',
            external=True,
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-ext-subnet1')
            ])
        self.ext_network_creator = OpenStackNetwork(self.admin_os_creds,
                                                    ext_network_settings)
        self.ext_network_creator.create()

        shared_network_settings = NetworkConfig(
            name=self.guid + '-shared-net',
            shared=True,
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr2,
                                            name=self.guid + '-shared-subnet1')
            ])
        self.shared_network_creator = OpenStackNetwork(
            self.admin_os_creds, shared_network_settings)
        self.shared_network_creator.create()

        overlay_network_settings = NetworkConfig(
            name=self.guid + '-overlay-net',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr3,
                                            name=self.guid +
                                            '-overlay-subnet1')
            ])
        self.overlay_network_creator = OpenStackNetwork(
            self.os_creds, overlay_network_settings)
        self.overlay_network_creator.create()

        self.neutron = neutron_utils.neutron_client(self.os_creds,
                                                    self.os_session)
コード例 #5
0
    def test_create_router_external_network(self):
        """
        Test creation of a router connected to an external network and a
        private network.
        """
        network_settings = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1',
                                            gateway_ip=static_gateway_ip1)
            ])
        self.network_creator1 = OpenStackNetwork(self.os_creds,
                                                 network_settings)
        self.network_creator1.create()

        port_settings = [
            create_network.PortConfig(
                name=self.guid + '-port1',
                ip_addrs=[{
                    'subnet_name': network_settings.subnet_settings[0].name,
                    'ip': static_gateway_ip1
                }],
                network_name=network_settings.name)
        ]

        router_settings = RouterConfig(name=self.guid + '-pub-router',
                                       external_gateway=self.ext_net_name,
                                       port_settings=port_settings)
        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, router_settings)
        self.router_creator.create()

        router = neutron_utils.get_router(
            self.neutron,
            self.keystone,
            router_settings=router_settings,
            project_name=self.os_creds.project_name)

        self.assertEquals(router, self.router_creator.get_router())

        self.check_router_recreation(router, router_settings)
コード例 #6
0
    def setUp(self):
        """
        Initializes objects used for router testing
        """
        super(self.__class__, self).__start__()

        self.guid = self.__class__.__name__ + '-' + str(uuid.uuid4())
        self.admin_router_creator = None
        self.proj_router_creator = None
        self.neutron = neutron_utils.neutron_client(self.os_creds,
                                                    self.os_session)

        network_settings = NetworkConfig(
            name=self.guid + '-pub-net',
            shared=True,
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet',
                                            gateway_ip=static_gateway_ip1)
            ])

        self.network_creator = OpenStackNetwork(self.admin_os_creds,
                                                network_settings)
        self.network_creator.create()
コード例 #7
0
    def test_create_with_internal_sub(self):
        """
        Test internal_subnets works.
        """
        network_settings1 = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1',
                                            gateway_ip=static_gateway_ip1)
            ])
        self.network_creator1 = OpenStackNetwork(self.os_creds,
                                                 network_settings1)

        self.network_creator1.create()
        self.router_settings = RouterConfig(
            name=self.guid + '-pub-router',
            external_gateway=self.ext_net_name,
            internal_subnets=[network_settings1.subnet_settings[0].name])

        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, self.router_settings)
        created_router = self.router_creator.create()
        self.assertIsNotNone(created_router)
コード例 #8
0
    def test_create_router_private_network(self):
        """
        Test creation of a router connected with two private networks and no
        external gateway
        """
        network_settings1 = NetworkConfig(
            name=self.guid + '-pub-net1',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr1,
                                            name=self.guid + '-pub-subnet1',
                                            gateway_ip=static_gateway_ip1)
            ])
        network_settings2 = NetworkConfig(
            name=self.guid + '-pub-net2',
            subnet_settings=[
                create_network.SubnetConfig(cidr=cidr2,
                                            name=self.guid + '-pub-subnet2',
                                            gateway_ip=static_gateway_ip2)
            ])

        self.network_creator1 = OpenStackNetwork(self.os_creds,
                                                 network_settings1)
        self.network_creator2 = OpenStackNetwork(self.os_creds,
                                                 network_settings2)

        self.network_creator1.create()
        self.network_creator2.create()

        port_settings = [
            create_network.PortConfig(
                name=self.guid + '-port1',
                ip_addrs=[{
                    'subnet_name': network_settings1.subnet_settings[0].name,
                    'ip': static_gateway_ip1
                }],
                network_name=network_settings1.name),
            create_network.PortConfig(
                name=self.guid + '-port2',
                ip_addrs=[{
                    'subnet_name': network_settings2.subnet_settings[0].name,
                    'ip': static_gateway_ip2
                }],
                network_name=network_settings2.name)
        ]

        router_settings = RouterConfig(name=self.guid + '-pub-router',
                                       port_settings=port_settings)
        self.router_creator = create_router.OpenStackRouter(
            self.os_creds, router_settings)
        self.router_creator.create()

        router = neutron_utils.get_router(
            self.neutron,
            self.keystone,
            router_settings=router_settings,
            project_name=self.os_creds.project_name)

        self.assertEqual(router, self.router_creator.get_router())

        # Instantiate second identical creator to ensure a second router
        # has not been created
        router_creator2 = create_router.OpenStackRouter(
            self.os_creds, router_settings)
        router2 = router_creator2.create()
        self.assertIsNotNone(self.router_creator.get_router(), router2)

        self.check_router_recreation(router2, router_settings)