Merge "Consolidate irrelevant-files in zuul config"
diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py
index 966b30d..8ec98cd 100644
--- a/neutron_tempest_plugin/api/base.py
+++ b/neutron_tempest_plugin/api/base.py
@@ -63,6 +63,8 @@
# Derive from BaseAdminNetworkTest class to have this initialized
admin_client = None
+ external_network_id = CONF.network.public_network_id
+
@classmethod
def get_client_manager(cls, credential_type=None, roles=None,
force_new=None):
@@ -139,8 +141,8 @@
# 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.delete_floatingip, floating_ip)
+
# Clean up routers
for router in cls.routers:
cls._try_delete_resource(cls.delete_router,
@@ -577,15 +579,56 @@
*args, **kwargs)
@classmethod
- def create_floatingip(cls, external_network_id):
- """Wrapper utility that returns a test floating IP."""
- body = cls.client.create_floatingip(
- floating_network_id=external_network_id)
- fip = body['floatingip']
+ def create_floatingip(cls, external_network_id=None, port=None,
+ client=None, **kwargs):
+ """Creates a floating IP.
+
+ Create a floating IP and schedule it for later deletion.
+ If a client is passed, then it is used for deleting the IP too.
+
+ :param external_network_id: network ID where to create
+ By default this is 'CONF.network.public_network_id'.
+
+ :param port: port to bind floating IP to
+ This is translated to 'port_id=port['id']'
+ By default it is None.
+
+ :param client: network client to be used for creating and cleaning up
+ the floating IP.
+
+ :param **kwargs: additional creation parameters to be forwarded to
+ networking server.
+ """
+
+ client = client or cls.client
+ external_network_id = (external_network_id or
+ cls.external_network_id)
+
+ if port:
+ kwargs['port_id'] = port['id']
+
+ fip = client.create_floatingip(external_network_id,
+ **kwargs)['floatingip']
+
+ # save client to be used later in cls.delete_floatingip
+ # for final cleanup
+ fip['client'] = client
cls.floating_ips.append(fip)
return fip
@classmethod
+ def delete_floatingip(cls, floating_ip, client=None):
+ """Delete floating IP
+
+ :param client: Client to be used
+ If client is not given it will use the client used to create
+ the floating IP, or cls.client if unknown.
+ """
+
+ client = client or floating_ip.get('client') or cls.client
+ client.delete_floatingip(floating_ip['id'])
+
+ @classmethod
def create_router_interface(cls, router_id, subnet_id):
"""Wrapper utility that returns a router interface."""
interface = cls.client.add_router_interface_with_subnet_id(
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 3adaa1e..1aaf8ce 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -14,6 +14,7 @@
# under the License.
import subprocess
+from debtcollector import removals
import netaddr
from neutron_lib.api import validators
from neutron_lib import constants as neutron_lib_constants
@@ -158,14 +159,12 @@
cls.routers.append(router)
return router
+ @removals.remove(version='Stein',
+ message="Please use create_floatingip method instead of "
+ "create_and_associate_floatingip.")
def create_and_associate_floatingip(self, port_id, client=None):
client = client or self.os_primary.network_client
- fip = client.create_floatingip(
- CONF.network.public_network_id,
- port_id=port_id)['floatingip']
- if client is self.os_primary.network_client:
- self.floating_ips.append(fip)
- return fip
+ return self.create_floatingip(port_id=port_id, client=client)
def create_interface(cls, server_id, port_id, client=None):
client = client or cls.os_primary.interfaces_client
@@ -215,7 +214,7 @@
self.port = self.client.list_ports(network_id=self.network['id'],
device_id=self.server[
'server']['id'])['ports'][0]
- self.fip = self.create_and_associate_floatingip(self.port['id'])
+ self.fip = self.create_floatingip(port=self.port)
def check_connectivity(self, host, ssh_user, ssh_key, servers=None):
ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
diff --git a/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml b/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml
new file mode 100644
index 0000000..ab9f37a
--- /dev/null
+++ b/releasenotes/notes/mark-methods-removals-f8b230171c045a3e.yaml
@@ -0,0 +1,11 @@
+---
+
+features:
+ - |
+ Add new 'debtcollector' dependency with the purpose of deprecating methods
+ that are going to be removed.
+
+deprecations:
+ - |
+ Deprecate method BaseTempestTestCase.create_and_associate_floatingip after
+ replacing it with method BaseNetworkTest.create_floatingip.
diff --git a/requirements.txt b/requirements.txt
index 5660c68..e48daf7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -16,3 +16,4 @@
testtools>=2.2.0 # MIT
testscenarios>=0.4 # Apache-2.0/BSD
eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
+debtcollector>=1.2.0 # Apache-2.0