Ejemplo n.º 1
0
 def test_create_update_floatingip_with_port_multiple_ip_address(self):
     # Find out ips that can be used for tests
     list_ips = net_utils.get_unused_ip_addresses(self.ports_client,
                                                  self.subnets_client,
                                                  self.subnet['network_id'],
                                                  self.subnet['id'], 2)
     fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
     # Create port
     body = self.ports_client.create_port(network_id=self.network['id'],
                                          fixed_ips=fixed_ips)
     port = body['port']
     self.addCleanup(self.ports_client.delete_port, port['id'])
     # Create floating ip
     body = self.floating_ips_client.create_floatingip(
         floating_network_id=self.ext_net_id,
         port_id=port['id'],
         fixed_ip_address=list_ips[0])
     floating_ip = body['floatingip']
     self.addCleanup(self.floating_ips_client.delete_floatingip,
                     floating_ip['id'])
     self.assertIsNotNone(floating_ip['id'])
     self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])
     # Update floating ip
     body = self.floating_ips_client.update_floatingip(
         floating_ip['id'],
         port_id=port['id'],
         fixed_ip_address=list_ips[1])
     update_floating_ip = body['floatingip']
     self.assertEqual(update_floating_ip['fixed_ip_address'], list_ips[1])
Ejemplo n.º 2
0
 def test_create_update_floatingip_with_port_multiple_ip_address(self):
     # Find out ips that can be used for tests
     list_ips = net_utils.get_unused_ip_addresses(
         self.ports_client,
         self.subnets_client,
         self.subnet['network_id'],
         self.subnet['id'],
         2)
     fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
     # Create port
     body = self.ports_client.create_port(network_id=self.network['id'],
                                          fixed_ips=fixed_ips)
     port = body['port']
     self.addCleanup(self.ports_client.delete_port, port['id'])
     # Create floating ip
     body = self.floating_ips_client.create_floatingip(
         floating_network_id=self.ext_net_id,
         port_id=port['id'],
         fixed_ip_address=list_ips[0])
     floating_ip = body['floatingip']
     self.addCleanup(self.floating_ips_client.delete_floatingip,
                     floating_ip['id'])
     self.assertIsNotNone(floating_ip['id'])
     self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])
     # Update floating ip
     body = self.floating_ips_client.update_floatingip(
         floating_ip['id'], port_id=port['id'],
         fixed_ip_address=list_ips[1])
     update_floating_ip = body['floatingip']
     self.assertEqual(update_floating_ip['fixed_ip_address'],
                      list_ips[1])
Ejemplo n.º 3
0
 def _get_unused_ip_address(self):
     # Pick an unused ip address.
     ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                 self.subnets_client,
                                                 self.network['id'],
                                                 self.subnet['id'], 1)
     return ip_list
Ejemplo n.º 4
0
 def _get_unused_ip_address(self):
     unused_ip = net_utils.get_unused_ip_addresses(self.ports_client,
                                                   self.subnets_client,
                                                   self.network['id'],
                                                   self.subnet['id'],
                                                   1)
     return unused_ip[0]
Ejemplo n.º 5
0
    def test_create_router_external_fixed_ips(self):
        """Create Router Fixed IPs

        RBAC test for the neutron
        create_router:external_gateway_info:external_fixed_ips policy
        """
        name = data_utils.rand_name(self.__class__.__name__ + '-snat-router')

        # Pick an unused IP address.
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    self.network['id'],
                                                    self.subnet['id'],
                                                    1)
        external_fixed_ips = {'subnet_id': self.subnet['id'],
                              'ip_address': ip_list[0]}
        external_gateway_info = {'network_id': self.network['id'],
                                 'enable_snat': False,
                                 'external_fixed_ips': [external_fixed_ips]}

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        router = self.routers_client.create_router(
            name=name, external_gateway_info=external_gateway_info)
        self.addCleanup(self.routers_client.delete_router,
                        router['router']['id'])
Ejemplo n.º 6
0
    def test_update_router_external_fixed_ips(self):
        """Update Router External Gateway Info External Fixed Ips

        RBAC test for the neutron
        update_router:external_gateway_info:external_fixed_ips policy
        """
        # Pick an unused IP address.
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    self.network['id'],
                                                    self.subnet['id'],
                                                    1)
        external_fixed_ips = {'subnet_id': self.subnet['id'],
                              'ip_address': ip_list[0]}
        external_gateway_info = {'network_id': self.network['id'],
                                 'external_fixed_ips': [external_fixed_ips]}

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.routers_client.update_router(
            self.router['id'],
            external_gateway_info=external_gateway_info)
        self.addCleanup(
            self.routers_client.update_router,
            self.router['id'],
            external_gateway_info=None)
    def test_update_port_fixed_ips(self):

        # Pick an ip address within the allocation_pools range.
        post_body = {'network_id': self.network['id']}
        port = self._create_port(**post_body)

        # Pick an unused ip address.
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    self.network['id'],
                                                    self.subnet['id'], 1)
        fixed_ips = [{'ip_address': ip_list[0]}]

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.ports_client.update_port(port['id'], fixed_ips=fixed_ips)
Ejemplo n.º 8
0
    def _test_create_interface_by_fixed_ips(self, server, ifs):
        network_id = ifs[0]['net_id']
        subnet_id = ifs[0]['fixed_ips'][0]['subnet_id']
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    network_id, subnet_id, 1)

        fixed_ips = [{'ip_address': ip_list[0]}]
        iface = self.interfaces_client.create_interface(
            server['id'], net_id=network_id,
            fixed_ips=fixed_ips)['interfaceAttachment']
        self.addCleanup(self.ports_client.delete_port, iface['port_id'])
        iface = self.wait_for_interface_status(server['id'], iface['port_id'],
                                               'ACTIVE')
        self._check_interface(iface, fixed_ip=ip_list[0])
        return iface
 def test_create_update_floatingip_with_port_multiple_ip_address(self):
     # TODO(Team) Adapt once we are on 5.3.2
     # Find out ips that can be used for tests
     list_ips = net_utils.get_unused_ip_addresses(self.ports_client,
                                                  self.subnets_client,
                                                  self.subnet['network_id'],
                                                  self.subnet['id'], 2)
     fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
     # Create port
     port = self.create_port(network=self.network, fixed_ips=fixed_ips)
     # Create floating ip
     self.assertRaises(exceptions.BadRequest,
                       self.floating_ips_client.create_floatingip,
                       floating_network_id=self.ext_net_id,
                       port_id=port['id'],
                       fixed_ip_address=list_ips[0])
    def test_create_port_fixed_ips(self):

        # Pick an unused ip address.
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    self.network['id'],
                                                    self.subnet['id'], 1)
        fixed_ips = [{
            'ip_address': ip_list[0]
        }, {
            'subnet_id': self.subnet['id']
        }]

        post_body = {'network_id': self.network['id'], 'fixed_ips': fixed_ips}

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self._create_port(**post_body)
Ejemplo n.º 11
0
    def _test_create_interface_by_fixed_ips(self, server, ifs):
        network_id = ifs[0]['net_id']
        subnet_id = ifs[0]['fixed_ips'][0]['subnet_id']
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    network_id,
                                                    subnet_id,
                                                    1)

        fixed_ips = [{'ip_address': ip_list[0]}]
        iface = self.interfaces_client.create_interface(
            server['id'], net_id=network_id,
            fixed_ips=fixed_ips)['interfaceAttachment']
        self.addCleanup(self.ports_client.delete_port, iface['port_id'])
        self._check_interface(iface, server_id=server['id'],
                              fixed_ip=ip_list[0])
        return iface
Ejemplo n.º 12
0
    def _test_create_interface_by_fixed_ips(self, server, ifs):
        network_id = ifs[0]['net_id']
        subnet_id = ifs[0]['fixed_ips'][0]['subnet_id']
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    network_id, subnet_id, 1)

        fixed_ips = [{'ip_address': ip_list[0]}]
        iface = self.interfaces_client.create_interface(
            server['id'], net_id=network_id,
            fixed_ips=fixed_ips)['interfaceAttachment']
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.ports_client.delete_port, iface['port_id'])
        self._check_interface(iface,
                              server_id=server['id'],
                              fixed_ip=ip_list[0])
        return iface
    def test_update_port_allowed_address_pairs(self):

        # Pick an unused ip address.
        ip_list = net_utils.get_unused_ip_addresses(self.ports_client,
                                                    self.subnets_client,
                                                    self.network['id'],
                                                    self.subnet['id'], 1)
        # Update allowed address pair attribute of port
        address_pairs = [{
            'ip_address': ip_list[0],
            'mac_address': data_utils.rand_mac_address()
        }]
        post_body = {'network_id': self.network['id']}
        port = self._create_port(**post_body)

        self.rbac_utils.switch_role(self, toggle_rbac_role=True)
        self.ports_client.update_port(port['id'],
                                      allowed_address_pairs=address_pairs)
Ejemplo n.º 14
0
    def test_create_update_floatingip_with_port_multiple_ip_address(self):
        """Test updating floating ip's fixed_ips to another ip of same port

        First we create a port with 2 fixed ips, then we create a floating ip
        with one of the fixed ips, and then we update the floating ip to
        another fixed ip of that port.
        """
        # Find out ips that can be used for tests
        list_ips = net_utils.get_unused_ip_addresses(self.ports_client,
                                                     self.subnets_client,
                                                     self.subnet['network_id'],
                                                     self.subnet['id'], 2)
        fixed_ips = [{'ip_address': list_ips[0]}, {'ip_address': list_ips[1]}]
        # Create port
        body = self.ports_client.create_port(network_id=self.network['id'],
                                             name=data_utils.rand_name(
                                                 self.__class__.__name__),
                                             fixed_ips=fixed_ips)
        port = body['port']
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.ports_client.delete_port, port['id'])
        # Create floating ip
        body = self.floating_ips_client.create_floatingip(
            floating_network_id=self.ext_net_id,
            port_id=port['id'],
            fixed_ip_address=list_ips[0])
        floating_ip = body['floatingip']
        self.addCleanup(test_utils.call_and_ignore_notfound_exc,
                        self.floating_ips_client.delete_floatingip,
                        floating_ip['id'])
        self.assertIsNotNone(floating_ip['id'])
        self.assertEqual(floating_ip['fixed_ip_address'], list_ips[0])
        # Update floating ip
        body = self.floating_ips_client.update_floatingip(
            floating_ip['id'],
            port_id=port['id'],
            fixed_ip_address=list_ips[1])
        update_floating_ip = body['floatingip']
        self.assertEqual(update_floating_ip['fixed_ip_address'], list_ips[1])