Merge "Migrate network API tests to resource_* fixtures"
diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py
index f8782ad..0d27afa 100644
--- a/tempest/api/network/admin/test_agent_management.py
+++ b/tempest/api/network/admin/test_agent_management.py
@@ -21,8 +21,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(AgentManagementTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(AgentManagementTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('agent', 'network'):
             msg = "agent extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_dhcp_agent_scheduler.py b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
index c84d1a7..78f211d 100644
--- a/tempest/api/network/admin/test_dhcp_agent_scheduler.py
+++ b/tempest/api/network/admin/test_dhcp_agent_scheduler.py
@@ -20,9 +20,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(DHCPAgentSchedulersTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(DHCPAgentSchedulersTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('dhcp_agent_scheduler', 'network'):
             msg = "dhcp_agent_scheduler extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py
index 710c669..2e58dae 100644
--- a/tempest/api/network/admin/test_external_network_extension.py
+++ b/tempest/api/network/admin/test_external_network_extension.py
@@ -18,8 +18,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(ExternalNetworksTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(ExternalNetworksTestJSON, cls).resource_setup()
         cls.network = cls.create_network()
 
     def _create_network(self, external=True):
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 3718cb5..46c5e76 100644
--- a/tempest/api/network/admin/test_floating_ips_admin_actions.py
+++ b/tempest/api/network/admin/test_floating_ips_admin_actions.py
@@ -26,8 +26,8 @@
     force_tenant_isolation = True
 
     @classmethod
-    def setUpClass(cls):
-        super(FloatingIPAdminTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(FloatingIPAdminTestJSON, cls).resource_setup()
         cls.ext_net_id = CONF.network.public_network_id
         cls.floating_ip = cls.create_floatingip(cls.ext_net_id)
         cls.alt_manager = clients.Manager(cls.isolated_creds.get_alt_creds())
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index d7de73b..567af24 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -34,8 +34,8 @@
     """
 
     @classmethod
-    def setUpClass(cls):
-        super(L3AgentSchedulerTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(L3AgentSchedulerTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('l3_agent_scheduler', 'network'):
             msg = "L3 Agent Scheduler Extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_lbaas_agent_scheduler.py b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
index d0c31b3..1476f30 100644
--- a/tempest/api/network/admin/test_lbaas_agent_scheduler.py
+++ b/tempest/api/network/admin/test_lbaas_agent_scheduler.py
@@ -35,9 +35,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(LBaaSAgentSchedulerTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(LBaaSAgentSchedulerTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('lbaas_agent_scheduler', 'network'):
             msg = "LBaaS Agent Scheduler Extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_load_balancer_admin_actions.py b/tempest/api/network/admin/test_load_balancer_admin_actions.py
index a97d275..6d115e8 100644
--- a/tempest/api/network/admin/test_load_balancer_admin_actions.py
+++ b/tempest/api/network/admin/test_load_balancer_admin_actions.py
@@ -29,9 +29,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(LoadBalancerAdminTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(LoadBalancerAdminTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('lbaas', 'network'):
             msg = "lbaas extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py
index 9ac97f9..72aef36 100644
--- a/tempest/api/network/admin/test_quotas.py
+++ b/tempest/api/network/admin/test_quotas.py
@@ -39,8 +39,8 @@
     """
 
     @classmethod
-    def setUpClass(cls):
-        super(QuotasTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(QuotasTest, cls).resource_setup()
         if not test.is_extension_enabled('quotas', 'network'):
             msg = "quotas extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 1a23cb6..834c010 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -56,10 +56,10 @@
     _ip_version = 4
 
     @classmethod
-    def setUpClass(cls):
+    def resource_setup(cls):
         # Create no network resources for these test.
         cls.set_network_resources()
-        super(BaseNetworkTest, cls).setUpClass()
+        super(BaseNetworkTest, cls).resource_setup()
         if not CONF.service_available.neutron:
             raise cls.skipException("Neutron support is required")
 
@@ -85,7 +85,7 @@
         cls.ipsecpolicies = []
 
     @classmethod
-    def tearDownClass(cls):
+    def resource_cleanup(cls):
         if CONF.service_available.neutron:
             # Clean up ipsec policies
             for ipsecpolicy in cls.ipsecpolicies:
@@ -138,7 +138,7 @@
             for network in cls.networks:
                 cls.client.delete_network(network['id'])
             cls.clear_isolated_creds()
-        super(BaseNetworkTest, cls).tearDownClass()
+        super(BaseNetworkTest, cls).resource_cleanup()
 
     @classmethod
     def create_network(cls, network_name=None):
@@ -363,8 +363,8 @@
 class BaseAdminNetworkTest(BaseNetworkTest):
 
     @classmethod
-    def setUpClass(cls):
-        super(BaseAdminNetworkTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(BaseAdminNetworkTest, cls).resource_setup()
         admin_username = CONF.compute_admin.username
         admin_password = CONF.compute_admin.password
         admin_tenant = CONF.compute_admin.tenant_name
diff --git a/tempest/api/network/base_routers.py b/tempest/api/network/base_routers.py
index f69e6fd..38985a0 100644
--- a/tempest/api/network/base_routers.py
+++ b/tempest/api/network/base_routers.py
@@ -22,8 +22,8 @@
     # require admin credentials by default
 
     @classmethod
-    def setUpClass(cls):
-        super(BaseRouterTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(BaseRouterTest, cls).resource_setup()
 
     def _delete_router(self, router_id):
         self.client.delete_router(router_id)
diff --git a/tempest/api/network/base_security_groups.py b/tempest/api/network/base_security_groups.py
index c2af2f2..622ed01 100644
--- a/tempest/api/network/base_security_groups.py
+++ b/tempest/api/network/base_security_groups.py
@@ -20,8 +20,8 @@
 class BaseSecGroupTest(base.BaseNetworkTest):
 
     @classmethod
-    def setUpClass(cls):
-        super(BaseSecGroupTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(BaseSecGroupTest, cls).resource_setup()
 
     def _create_security_group(self):
         # Create a security group
diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py
index 86acc71..c085c39 100644
--- a/tempest/api/network/test_allowed_address_pair.py
+++ b/tempest/api/network/test_allowed_address_pair.py
@@ -37,9 +37,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(AllowedAddressPairTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(AllowedAddressPairTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('allowed-address-pairs', 'network'):
             msg = "Allowed Address Pairs extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index c3607c8..715136c 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -33,8 +33,8 @@
     """
 
     @classmethod
-    def setUpClass(cls):
-        super(ExtensionsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(ExtensionsTestJSON, cls).resource_setup()
 
     @test.attr(type='smoke')
     def test_list_show_extensions(self):
diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py
index 82ebc5a..86da9b7 100644
--- a/tempest/api/network/test_extra_dhcp_options.py
+++ b/tempest/api/network/test_extra_dhcp_options.py
@@ -36,9 +36,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(ExtraDHCPOptionsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(ExtraDHCPOptionsTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('extra_dhcp_opt', 'network'):
             msg = "Extra DHCP Options extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py
index 8b42a9e..52672ea 100644
--- a/tempest/api/network/test_floating_ips.py
+++ b/tempest/api/network/test_floating_ips.py
@@ -46,9 +46,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(FloatingIPTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(FloatingIPTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('router', 'network'):
             msg = "router extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_fwaas_extensions.py b/tempest/api/network/test_fwaas_extensions.py
index 9300c5e..193bf76 100644
--- a/tempest/api/network/test_fwaas_extensions.py
+++ b/tempest/api/network/test_fwaas_extensions.py
@@ -46,8 +46,8 @@
     """
 
     @classmethod
-    def setUpClass(cls):
-        super(FWaaSExtensionTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(FWaaSExtensionTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('fwaas', 'network'):
             msg = "FWaaS Extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index e3109ea..baa8cad 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -38,9 +38,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(LoadBalancerTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(LoadBalancerTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('lbaas', 'network'):
             msg = "lbaas extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py
index 0cc218b..2cfb841 100644
--- a/tempest/api/network/test_metering_extensions.py
+++ b/tempest/api/network/test_metering_extensions.py
@@ -35,9 +35,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(MeteringJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(MeteringJSON, cls).resource_setup()
         if not test.is_extension_enabled('metering', 'network'):
             msg = "metering extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index f3da614..e1eb48d 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -59,9 +59,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(NetworksTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(NetworksTestJSON, cls).resource_setup()
         cls.network = cls.create_network()
         cls.name = cls.network['name']
         cls.subnet = cls.create_subnet(cls.network)
@@ -366,11 +365,11 @@
     _ip_version = 6
 
     @classmethod
-    def setUpClass(cls):
+    def resource_setup(cls):
         if not CONF.network_feature_enabled.ipv6:
             skip_msg = "IPv6 Tests are disabled."
             raise cls.skipException(skip_msg)
-        super(NetworksIpV6TestJSON, cls).setUpClass()
+        super(NetworksIpV6TestJSON, cls).resource_setup()
 
     @test.attr(type='smoke')
     def test_create_delete_subnet_with_gw(self):
diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py
index 26f6b8f..ce0bb57 100644
--- a/tempest/api/network/test_ports.py
+++ b/tempest/api/network/test_ports.py
@@ -38,9 +38,8 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(PortsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(PortsTestJSON, cls).resource_setup()
         cls.network = cls.create_network()
         cls.port = cls.create_port(cls.network)
 
@@ -162,9 +161,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(PortsAdminExtendedAttrsTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(PortsAdminExtendedAttrsTestJSON, cls).resource_setup()
         cls.identity_client = cls._get_identity_admin_client()
         cls.tenant = cls.identity_client.get_tenant_by_name(
             CONF.identity.tenant_name)
@@ -245,9 +243,8 @@
     _tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(PortsIpV6TestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(PortsIpV6TestJSON, cls).resource_setup()
         if not CONF.network_feature_enabled.ipv6:
             skip_msg = "IPv6 Tests are disabled."
             raise cls.skipException(skip_msg)
@@ -263,11 +260,11 @@
     _tenant_network_mask_bits = CONF.network.tenant_network_v6_mask_bits
 
     @classmethod
-    def setUpClass(cls):
+    def resource_setup(cls):
         if not CONF.network_feature_enabled.ipv6:
             skip_msg = "IPv6 Tests are disabled."
             raise cls.skipException(skip_msg)
-        super(PortsAdminExtendedAttrsIpV6TestJSON, cls).setUpClass()
+        super(PortsAdminExtendedAttrsIpV6TestJSON, cls).resource_setup()
 
 
 class PortsAdminExtendedAttrsIpV6TestXML(PortsAdminExtendedAttrsIpV6TestJSON):
diff --git a/tempest/api/network/test_routers.py b/tempest/api/network/test_routers.py
index bcd8113..f3f25ac 100644
--- a/tempest/api/network/test_routers.py
+++ b/tempest/api/network/test_routers.py
@@ -28,8 +28,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(RoutersTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(RoutersTest, cls).resource_setup()
         if not test.is_extension_enabled('router', 'network'):
             msg = "router extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_routers_negative.py b/tempest/api/network/test_routers_negative.py
index feee51b..4c226af 100644
--- a/tempest/api/network/test_routers_negative.py
+++ b/tempest/api/network/test_routers_negative.py
@@ -28,9 +28,8 @@
     _interface = 'json'
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
-        super(RoutersNegativeTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(RoutersNegativeTest, cls).resource_setup()
         if not test.is_extension_enabled('router', 'network'):
             msg = "router extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_security_groups.py b/tempest/api/network/test_security_groups.py
index cea8344..9764b4d 100644
--- a/tempest/api/network/test_security_groups.py
+++ b/tempest/api/network/test_security_groups.py
@@ -24,8 +24,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(SecGroupTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(SecGroupTest, cls).resource_setup()
         if not test.is_extension_enabled('security-group', 'network'):
             msg = "security-group extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_security_groups_negative.py b/tempest/api/network/test_security_groups_negative.py
index 53c9d12..9c6c267 100644
--- a/tempest/api/network/test_security_groups_negative.py
+++ b/tempest/api/network/test_security_groups_negative.py
@@ -24,8 +24,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(NegativeSecGroupTest, cls).setUpClass()
+    def resource_setup(cls):
+        super(NegativeSecGroupTest, cls).resource_setup()
         if not test.is_extension_enabled('security-group', 'network'):
             msg = "security-group extension not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_service_type_management.py b/tempest/api/network/test_service_type_management.py
index dbb72fb..302069f 100644
--- a/tempest/api/network/test_service_type_management.py
+++ b/tempest/api/network/test_service_type_management.py
@@ -18,8 +18,8 @@
     _interface = 'json'
 
     @classmethod
-    def setUpClass(cls):
-        super(ServiceTypeManagementTestJSON, cls).setUpClass()
+    def resource_setup(cls):
+        super(ServiceTypeManagementTestJSON, cls).resource_setup()
         if not test.is_extension_enabled('service-type', 'network'):
             msg = "Neutron Service Type Management not enabled."
             raise cls.skipException(msg)
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index 09e9640..c61bf41 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -34,12 +34,11 @@
     """
 
     @classmethod
-    @test.safe_setup
-    def setUpClass(cls):
+    def resource_setup(cls):
         if not test.is_extension_enabled('vpnaas', 'network'):
             msg = "vpnaas extension not enabled."
             raise cls.skipException(msg)
-        super(VPNaaSTestJSON, cls).setUpClass()
+        super(VPNaaSTestJSON, cls).resource_setup()
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
         cls.router = cls.create_router(