Stop heat resource leaking even if an error occurs

In some test, if an error occurred in setUpClass(), some resources
are not deleted because of tearDownClass() is not called.
This commit fixes it.

 tempest/api
  +---- baremetal (unnecessary)
  +---- compute
  +---- data_processing (unnecessary)
  +---- database (unnecessary)
  +---- identity
  +---- image (done)
  +---- network
  +---- object_storage
  +---- orchestration         <-- this patch
  +---- queuing (unnecessary)
  +---- telemetry (unnecessary)
  +---- volume (done)

Partially Implements: blueprint stop-leaking

Change-Id: Ice13507f4b7625b73fe200c414fa4d7b9be856d5
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 18ba37b..dee26b1 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -18,7 +18,7 @@
 from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
-from tempest.test import attr
+from tempest import test
 
 CONF = config.CONF
 
@@ -100,6 +100,7 @@
 """
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(NeutronResourcesTestJSON, cls).setUpClass()
         if not CONF.orchestration.image_ref:
@@ -155,7 +156,7 @@
                               'network:router_interface', ports)
         return router_ports[0]['device_id']
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_resources(self):
         """Verifies created neutron resources."""
         resources = [('Network', 'OS::Neutron::Net'),
@@ -169,7 +170,7 @@
             self.assertEqual(resource_type, resource['resource_type'])
             self.assertEqual('CREATE_COMPLETE', resource['resource_status'])
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_network(self):
         """Verifies created network."""
         network_id = self.test_resources.get('Network')['physical_resource_id']
@@ -180,7 +181,7 @@
         self.assertEqual(network_id, network['id'])
         self.assertEqual('NewNetwork', network['name'])
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_subnet(self):
         """Verifies created subnet."""
         subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
@@ -197,7 +198,7 @@
         self.assertEqual(4, subnet['ip_version'])
         self.assertEqual('10.0.3.0/24', subnet['cidr'])
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_router(self):
         """Verifies created router."""
         router_id = self.test_resources.get('Router')['physical_resource_id']
@@ -211,7 +212,7 @@
                          router['external_gateway_info']['enable_snat'])
         self.assertEqual(False, router['admin_state_up'])
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_router_interface(self):
         """Verifies created router interface."""
         network_id = self.test_resources.get('Network')['physical_resource_id']
@@ -232,7 +233,7 @@
         router_interface_ip = subnet_fixed_ips[0]['ip_address']
         self.assertEqual('10.0.3.1', router_interface_ip)
 
-    @attr(type='slow')
+    @test.attr(type='slow')
     def test_created_server(self):
         """Verifies created sever."""
         server_id = self.test_resources.get('Server')['physical_resource_id']
diff --git a/tempest/api/orchestration/stacks/test_server_cfn_init.py b/tempest/api/orchestration/stacks/test_server_cfn_init.py
index 95deaf5..a6f74b6 100644
--- a/tempest/api/orchestration/stacks/test_server_cfn_init.py
+++ b/tempest/api/orchestration/stacks/test_server_cfn_init.py
@@ -113,6 +113,7 @@
 """
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(ServerCfnInitTestJSON, cls).setUpClass()
         if not CONF.orchestration.image_ref:
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index 713cfd4..fcf357a 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -18,6 +18,7 @@
 from tempest import clients
 from tempest.common.utils import data_utils
 from tempest import config
+from tempest import test
 
 
 CONF = config.CONF
@@ -53,6 +54,7 @@
 """
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(SwiftResourcesTestJSON, cls).setUpClass()
         cls.client = cls.orchestration_client
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 2da819d..2dc29fc 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -12,7 +12,7 @@
 
 from tempest.api.orchestration import base
 from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
 
 
 class TemplateYAMLTestJSON(base.BaseOrchestrationTest):
@@ -30,6 +30,7 @@
     invalid_template_url = 'http://www.example.com/template.yaml'
 
     @classmethod
+    @test.safe_setup
     def setUpClass(cls):
         super(TemplateYAMLTestJSON, cls).setUpClass()
         cls.client = cls.orchestration_client
@@ -40,13 +41,13 @@
         cls.stack_id = cls.stack_identifier.split('/')[1]
         cls.parameters = {}
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_show_template(self):
         """Getting template used to create the stack."""
         resp, template = self.client.show_template(self.stack_identifier)
         self.assertEqual('200', resp['status'])
 
-    @attr(type='gate')
+    @test.attr(type='gate')
     def test_validate_template(self):
         """Validating template passing it content."""
         resp, parameters = self.client.validate_template(self.template,