Merge "Clean up network class resources via addClassResourceCleanup"
diff --git a/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py b/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py
index 67b32a2..dc674d1 100644
--- a/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_floating_ips_rbac.py
@@ -30,10 +30,15 @@
@classmethod
def resource_setup(cls):
super(FloatingIpsRbacTest, cls).resource_setup()
-
- # Create an external network for floating ip creation
+ # Create an external network for floating ip creation.
cls.fip_extnet = cls.create_network(**{'router:external': True})
+ # Update router:external attribute to False for proper subnet resource
+ # cleanup by base class.
cls.fip_extnet_id = cls.fip_extnet['id']
+ cls.addClassResourceCleanup(
+ test_utils.call_and_ignore_notfound_exc,
+ cls.networks_client.update_network, cls.fip_extnet_id,
+ **{'router:external': False})
# Create a subnet for the external network
cls.cidr = netaddr.IPNetwork(CONF.network.project_network_cidr)
@@ -41,14 +46,6 @@
cidr=cls.cidr,
mask_bits=24)
- @classmethod
- def resource_cleanup(cls):
- # Update router:external attribute to False for proper subnet resource
- # cleanup by base class
- cls.networks_client.update_network(cls.fip_extnet_id,
- **{'router:external': False})
- super(FloatingIpsRbacTest, cls).resource_cleanup()
-
def _create_floatingip(self, floating_ip_address=None):
if floating_ip_address is not None:
body = self.floating_ips_client.create_floatingip(
diff --git a/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py b/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
index 3c74c07..1434858 100644
--- a/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_metering_label_rules_rbac.py
@@ -44,15 +44,11 @@
@classmethod
def resource_setup(cls):
super(MeteringLabelRulesRbacTest, cls).resource_setup()
-
body = cls.metering_labels_client.create_metering_label(
name=data_utils.rand_name(cls.__name__))
cls.label = body['metering_label']
-
- @classmethod
- def resource_cleanup(cls):
- cls.metering_labels_client.delete_metering_label(cls.label['id'])
- super(MeteringLabelRulesRbacTest, cls).resource_cleanup()
+ cls.addClassResourceCleanup(
+ cls.metering_labels_client.delete_metering_label, cls.label['id'])
def _create_metering_label_rule(self, label):
body = self.metering_label_rules_client.create_metering_label_rule(
diff --git a/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py b/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
index 2672b57..84c2df5 100644
--- a/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
+++ b/patrole_tempest_plugin/tests/api/network/test_security_groups_rbac.py
@@ -37,14 +37,9 @@
secgroup_name = data_utils.rand_name(cls.__name__ + '-secgroup')
cls.secgroup = cls.security_groups_client.create_security_group(
name=secgroup_name)['security_group']
-
- @classmethod
- def resource_cleanup(cls):
- # Clean up security group
- test_utils.call_and_ignore_notfound_exc(
+ cls.addClassResourceCleanup(
cls.security_groups_client.delete_security_group,
cls.secgroup['id'])
- super(SecGroupRbacTest, cls).resource_cleanup()
def _create_security_group(self):
# Create a security group