Merge "Split out Neutron floating IPs client"
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index fce63ac..a32bfbc 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -94,8 +94,6 @@
# Verifies external network can be deleted while still holding
# (unassociated) floating IPs
- # Set cls.client to admin to use base.create_subnet()
- client = self.admin_client
body = self.admin_networks_client.create_network(
**{'router:external': True})
external_network = body['network']
@@ -105,19 +103,19 @@
subnet = self.create_subnet(
external_network, client=self.admin_subnets_client,
enable_dhcp=False)
- body = client.create_floatingip(
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=external_network['id'])
created_floating_ip = body['floatingip']
self.addCleanup(self._try_delete_resource,
- client.delete_floatingip,
+ self.admin_floating_ips_client.delete_floatingip,
created_floating_ip['id'])
- floatingip_list = client.list_floatingips(
+ floatingip_list = self.admin_floating_ips_client.list_floatingips(
network=external_network['id'])
self.assertIn(created_floating_ip['id'],
(f['id'] for f in floatingip_list['floatingips']))
self.admin_networks_client.delete_network(external_network['id'])
# Verifies floating ip is deleted
- floatingip_list = client.list_floatingips()
+ floatingip_list = self.admin_floating_ips_client.list_floatingips()
self.assertNotIn(created_floating_ip['id'],
(f['id'] for f in floatingip_list['floatingips']))
# Verifies subnet is deleted
diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py
index 1e1573e..d031108 100644
--- a/tempest/api/network/admin/test_external_networks_negative.py
+++ b/tempest/api/network/admin/test_external_networks_negative.py
@@ -32,12 +32,11 @@
# pre-created floating-ip should be denied.
# create a floating ip
- client = self.admin_client
- body = client.create_floatingip(
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=CONF.network.public_network_id)
created_floating_ip = body['floatingip']
self.addCleanup(self._try_delete_resource,
- client.delete_floatingip,
+ self.admin_floating_ips_client.delete_floatingip,
created_floating_ip['id'])
floating_ip_address = created_floating_ip['floating_ip_address']
self.assertIsNotNone(floating_ip_address)
diff --git a/tempest/api/network/admin/test_floating_ips_admin_actions.py b/tempest/api/network/admin/test_floating_ips_admin_actions.py
index dfe7307..6ad374b 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -29,6 +29,7 @@
def setup_clients(cls):
super(FloatingIPAdminTestJSON, cls).setup_clients()
cls.alt_client = cls.alt_manager.network_client
+ cls.alt_floating_ips_client = cls.alt_manager.floating_ips_client
@classmethod
def resource_setup(cls):
@@ -45,18 +46,18 @@
@test.idempotent_id('64f2100b-5471-4ded-b46c-ddeeeb4f231b')
def test_list_floating_ips_from_admin_and_nonadmin(self):
# Create floating ip from admin user
- floating_ip_admin = self.admin_client.create_floatingip(
+ floating_ip_admin = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
- self.addCleanup(self.admin_client.delete_floatingip,
+ self.addCleanup(self.admin_floating_ips_client.delete_floatingip,
floating_ip_admin['floatingip']['id'])
# Create floating ip from alt user
- body = self.alt_client.create_floatingip(
+ body = self.alt_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip_alt = body['floatingip']
- self.addCleanup(self.alt_client.delete_floatingip,
+ self.addCleanup(self.alt_floating_ips_client.delete_floatingip,
floating_ip_alt['id'])
# List floating ips from admin
- body = self.admin_client.list_floatingips()
+ body = self.admin_floating_ips_client.list_floatingips()
floating_ip_ids_admin = [f['id'] for f in body['floatingips']]
# Check that admin sees all floating ips
self.assertIn(self.floating_ip['id'], floating_ip_ids_admin)
@@ -64,7 +65,7 @@
floating_ip_ids_admin)
self.assertIn(floating_ip_alt['id'], floating_ip_ids_admin)
# List floating ips from nonadmin
- body = self.client.list_floatingips()
+ body = self.floating_ips_client.list_floatingips()
floating_ip_ids = [f['id'] for f in body['floatingips']]
# Check that nonadmin user doesn't see floating ip created from admin
# and floating ip that is created in another tenant (alt user)
@@ -76,12 +77,12 @@
@test.idempotent_id('32727cc3-abe2-4485-a16e-48f2d54c14f2')
def test_create_list_show_floating_ip_with_tenant_id_by_admin(self):
# Creates a floating IP
- body = self.admin_client.create_floatingip(
+ body = self.admin_floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
tenant_id=self.network['tenant_id'],
port_id=self.port['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
@@ -93,7 +94,7 @@
self.assertEqual(created_floating_ip['fixed_ip_address'],
port[0]['ip_address'])
# Verifies the details of a floating_ip
- floating_ip = self.admin_client.show_floatingip(
+ floating_ip = self.admin_floating_ips_client.show_floatingip(
created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
@@ -105,6 +106,6 @@
created_floating_ip['floating_ip_address'])
self.assertEqual(shown_floating_ip['port_id'], self.port['id'])
# Verify the floating ip exists in the list of all floating_ips
- floating_ips = self.admin_client.list_floatingips()
+ floating_ips = self.admin_floating_ips_client.list_floatingips()
floatingip_id_list = [f['id'] for f in floating_ips['floatingips']]
self.assertIn(created_floating_ip['id'], floatingip_id_list)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 2c0b981..b798cb2 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -74,6 +74,7 @@
cls.networks_client = cls.os.networks_client
cls.subnets_client = cls.os.subnets_client
cls.ports_client = cls.os.ports_client
+ cls.floating_ips_client = cls.os.floating_ips_client
@classmethod
def resource_setup(cls):
@@ -92,8 +93,9 @@
if CONF.service_available.neutron:
# Clean up floating IPs
for floating_ip in cls.floating_ips:
- cls._try_delete_resource(cls.client.delete_floatingip,
- floating_ip['id'])
+ cls._try_delete_resource(
+ cls.floating_ips_client.delete_floatingip,
+ floating_ip['id'])
# Clean up metering label rules
for metering_label_rule in cls.metering_label_rules:
@@ -232,7 +234,7 @@
@classmethod
def create_floatingip(cls, external_network_id):
"""Wrapper utility that returns a test floating IP."""
- body = cls.client.create_floatingip(
+ body = cls.floating_ips_client.create_floatingip(
floating_network_id=external_network_id)
fip = body['floatingip']
cls.floating_ips.append(fip)
@@ -269,6 +271,7 @@
cls.admin_networks_client = cls.os_adm.networks_client
cls.admin_subnets_client = cls.os_adm.subnets_client
cls.admin_ports_client = cls.os_adm.ports_client
+ cls.admin_floating_ips_client = cls.os_adm.floating_ips_client
@classmethod
def create_metering_label(cls, name, description):
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index e9a553a..ce9c4be 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -68,11 +68,11 @@
@test.idempotent_id('62595970-ab1c-4b7f-8fcc-fddfe55e8718')
def test_create_list_show_update_delete_floating_ip(self):
# Creates a floating IP
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[0]['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['tenant_id'])
@@ -83,7 +83,8 @@
self.assertIn(created_floating_ip['fixed_ip_address'],
[ip['ip_address'] for ip in self.ports[0]['fixed_ips']])
# Verifies the details of a floating_ip
- floating_ip = self.client.show_floatingip(created_floating_ip['id'])
+ floating_ip = self.floating_ips_client.show_floatingip(
+ created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
self.assertEqual(shown_floating_ip['floating_network_id'],
@@ -95,13 +96,13 @@
self.assertEqual(shown_floating_ip['port_id'], self.ports[0]['id'])
# Verify the floating ip exists in the list of all floating_ips
- floating_ips = self.client.list_floatingips()
+ floating_ips = self.floating_ips_client.list_floatingips()
floatingip_id_list = list()
for f in floating_ips['floatingips']:
floatingip_id_list.append(f['id'])
self.assertIn(created_floating_ip['id'], floatingip_id_list)
# Associate floating IP to the other port
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=self.ports[1]['id'])
updated_floating_ip = floating_ip['floatingip']
@@ -111,7 +112,7 @@
self.assertEqual(updated_floating_ip['router_id'], self.router['id'])
# Disassociate floating IP from the port
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=None)
updated_floating_ip = floating_ip['floatingip']
@@ -122,21 +123,22 @@
@test.idempotent_id('e1f6bffd-442f-4668-b30e-df13f2705e77')
def test_floating_ip_delete_port(self):
# Create a floating IP
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
# Create a port
port = self.ports_client.create_port(network_id=self.network['id'])
created_port = port['port']
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=created_port['id'])
# Delete port
self.ports_client.delete_port(created_port['id'])
# Verifies the details of the floating_ip
- floating_ip = self.client.show_floatingip(created_floating_ip['id'])
+ floating_ip = self.floating_ips_client.show_floatingip(
+ created_floating_ip['id'])
shown_floating_ip = floating_ip['floatingip']
# Confirm the fields are back to None
self.assertEqual(shown_floating_ip['id'], created_floating_ip['id'])
@@ -147,11 +149,11 @@
@test.idempotent_id('1bb2f731-fe5a-4b8c-8409-799ade1bed4d')
def test_floating_ip_update_different_router(self):
# Associate a floating IP to a port on a router
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[1]['id'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertEqual(created_floating_ip['router_id'], self.router['id'])
network2 = self.create_network()
@@ -161,7 +163,7 @@
self.create_router_interface(router2['id'], subnet2['id'])
port_other_router = self.create_port(network2)
# Associate floating IP to the other port on another router
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=port_other_router['id'])
updated_floating_ip = floating_ip['floatingip']
@@ -173,17 +175,17 @@
@test.attr(type='smoke')
@test.idempotent_id('36de4bd0-f09c-43e3-a8e1-1decc1ffd3a5')
def test_create_floating_ip_specifying_a_fixed_ip_address(self):
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id,
port_id=self.ports[1]['id'],
fixed_ip_address=self.ports[1]['fixed_ips'][0]['ip_address'])
created_floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip,
+ self.addCleanup(self.floating_ips_client.delete_floatingip,
created_floating_ip['id'])
self.assertIsNotNone(created_floating_ip['id'])
self.assertEqual(created_floating_ip['fixed_ip_address'],
self.ports[1]['fixed_ips'][0]['ip_address'])
- floating_ip = self.client.update_floatingip(
+ floating_ip = self.floating_ips_client.update_floatingip(
created_floating_ip['id'],
port_id=None)
self.assertIsNone(floating_ip['floatingip']['port_id'])
@@ -200,18 +202,19 @@
port = body['port']
self.addCleanup(self.ports_client.delete_port, port['id'])
# Create floating ip
- body = self.client.create_floatingip(
+ 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.client.delete_floatingip, floating_ip['id'])
+ 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.client.update_floatingip(floating_ip['id'],
- port_id=port['id'],
- fixed_ip_address=list_ips[1])
+ 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])
diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py
index 5f56fec..f915615 100644
--- a/tempest/api/network/test_floating_ips_negative.py
+++ b/tempest/api/network/test_floating_ips_negative.py
@@ -53,17 +53,17 @@
@test.attr(type=['negative'])
@test.idempotent_id('22996ea8-4a81-4b27-b6e1-fa5df92fa5e8')
def test_create_floatingip_with_port_ext_net_unreachable(self):
- self.assertRaises(lib_exc.NotFound, self.client.create_floatingip,
- floating_network_id=self.ext_net_id,
- port_id=self.port['id'],
- fixed_ip_address=self.port['fixed_ips'][0]
- ['ip_address'])
+ self.assertRaises(
+ lib_exc.NotFound, self.floating_ips_client.create_floatingip,
+ floating_network_id=self.ext_net_id, port_id=self.port['id'],
+ fixed_ip_address=self.port['fixed_ips'][0]
+ ['ip_address'])
@test.attr(type=['negative'])
@test.idempotent_id('50b9aeb4-9f0b-48ee-aa31-fa955a48ff54')
def test_create_floatingip_in_private_network(self):
self.assertRaises(lib_exc.BadRequest,
- self.client.create_floatingip,
+ self.floating_ips_client.create_floatingip,
floating_network_id=self.network['id'],
port_id=self.port['id'],
fixed_ip_address=self.port['fixed_ips'][0]
@@ -73,12 +73,13 @@
@test.idempotent_id('6b3b8797-6d43-4191-985c-c48b773eb429')
def test_associate_floatingip_port_ext_net_unreachable(self):
# Create floating ip
- body = self.client.create_floatingip(
+ body = self.floating_ips_client.create_floatingip(
floating_network_id=self.ext_net_id)
floating_ip = body['floatingip']
- self.addCleanup(self.client.delete_floatingip, floating_ip['id'])
+ self.addCleanup(
+ self.floating_ips_client.delete_floatingip, floating_ip['id'])
# Associate floating IP to the other port
- self.assertRaises(lib_exc.NotFound, self.client.update_floatingip,
- floating_ip['id'], port_id=self.port['id'],
- fixed_ip_address=self.port['fixed_ips'][0]
- ['ip_address'])
+ self.assertRaises(
+ lib_exc.NotFound, self.floating_ips_client.update_floatingip,
+ floating_ip['id'], port_id=self.port['id'],
+ fixed_ip_address=self.port['fixed_ips'][0]['ip_address'])
diff --git a/tempest/clients.py b/tempest/clients.py
index 3fb4c22..d9e624a 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -104,6 +104,7 @@
from tempest.services.image.v2.json.image_client import ImageClientV2
from tempest.services.messaging.json.messaging_client import \
MessagingClient
+from tempest.services.network.json.floating_ips_client import FloatingIPsClient
from tempest.services.network.json.network_client import NetworkClient
from tempest.services.network.json.networks_client import NetworksClient
from tempest.services.network.json.ports_client import PortsClient
@@ -218,6 +219,14 @@
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
+ self.floating_ips_client = FloatingIPsClient(
+ self.auth_provider,
+ CONF.network.catalog_type,
+ CONF.network.region or CONF.identity.region,
+ endpoint_type=CONF.network.endpoint_type,
+ build_interval=CONF.network.build_interval,
+ build_timeout=CONF.network.build_timeout,
+ **self.default_params)
self.messaging_client = MessagingClient(
self.auth_provider,
CONF.messaging.catalog_type,
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index d2f6c03..18508fe 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -385,6 +385,7 @@
self.networks_client = manager.networks_client
self.subnets_client = manager.subnets_client
self.ports_client = manager.ports_client
+ self.floating_ips_client = manager.floating_ips_client
def _filter_by_conf_networks(self, item_list):
if not item_list or not all(('network_id' in i for i in item_list)):
@@ -421,7 +422,7 @@
class NetworkFloatingIpService(NetworkService):
def list(self):
- client = self.client
+ client = self.floating_ips_client
flips = client.list_floatingips(**self.tenant_filter)
flips = flips['floatingips']
LOG.debug("List count, %s Network Floating IPs" % len(flips))
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 9f283c5..147c0ba 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -65,6 +65,7 @@
cls.networks_client = cls.manager.networks_client
cls.ports_client = cls.manager.ports_client
cls.subnets_client = cls.manager.subnets_client
+ cls.floating_ips_client = cls.manager.floating_ips_client
# Heat client
cls.orchestration_client = cls.manager.orchestration_client
@@ -786,7 +787,7 @@
if not external_network_id:
external_network_id = CONF.network.public_network_id
if not client:
- client = self.network_client
+ client = self.floating_ips_client
if not port_id:
port_id, ip4 = self._get_server_port_id_and_ip4(thing)
else:
diff --git a/tempest/scenario/test_security_groups_basic_ops.py b/tempest/scenario/test_security_groups_basic_ops.py
index 51188d5..6a23c4b 100644
--- a/tempest/scenario/test_security_groups_basic_ops.py
+++ b/tempest/scenario/test_security_groups_basic_ops.py
@@ -283,7 +283,7 @@
public_network_id = CONF.network.public_network_id
floating_ip = self.create_floating_ip(
server, public_network_id,
- client=tenant.manager.network_client)
+ client=tenant.manager.floating_ips_client)
self.floating_ips.setdefault(server['id'], floating_ip)
def _create_tenant_network(self, tenant):
diff --git a/tempest/services/network/json/floating_ips_client.py b/tempest/services/network/json/floating_ips_client.py
new file mode 100644
index 0000000..5c490ed
--- /dev/null
+++ b/tempest/services/network/json/floating_ips_client.py
@@ -0,0 +1,38 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest.services.network.json import base
+
+
+class FloatingIPsClient(base.BaseNetworkClient):
+
+ def create_floatingip(self, **kwargs):
+ uri = '/floatingips'
+ post_data = {'floatingip': kwargs}
+ return self.create_resource(uri, post_data)
+
+ def update_floatingip(self, floatingip_id, **kwargs):
+ uri = '/floatingips/%s' % floatingip_id
+ post_data = {'floatingip': kwargs}
+ return self.update_resource(uri, post_data)
+
+ def show_floatingip(self, floatingip_id, **fields):
+ uri = '/floatingips/%s' % floatingip_id
+ return self.show_resource(uri, **fields)
+
+ def delete_floatingip(self, floatingip_id):
+ uri = '/floatingips/%s' % floatingip_id
+ return self.delete_resource(uri)
+
+ def list_floatingips(self, **filters):
+ uri = '/floatingips'
+ return self.list_resources(uri, **filters)
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 50a5d5e..5a4229c 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -35,28 +35,6 @@
quotas
"""
- def create_floatingip(self, **kwargs):
- uri = '/floatingips'
- post_data = {'floatingip': kwargs}
- return self.create_resource(uri, post_data)
-
- def update_floatingip(self, floatingip_id, **kwargs):
- uri = '/floatingips/%s' % floatingip_id
- post_data = {'floatingip': kwargs}
- return self.update_resource(uri, post_data)
-
- def show_floatingip(self, floatingip_id, **fields):
- uri = '/floatingips/%s' % floatingip_id
- return self.show_resource(uri, **fields)
-
- def delete_floatingip(self, floatingip_id):
- uri = '/floatingips/%s' % floatingip_id
- return self.delete_resource(uri)
-
- def list_floatingips(self, **filters):
- uri = '/floatingips'
- return self.list_resources(uri, **filters)
-
def create_metering_label(self, **kwargs):
uri = '/metering/metering-labels'
post_data = {'metering_label': kwargs}