Make testing neutron agents optional

Closes-Bug: #1247778
Change-Id: Ia67213d661a8dd3b64ca7a7e596e10d3eeba71dc
diff --git a/tempest/api/network/test_load_balancer.py b/tempest/api/network/test_load_balancer.py
index 7e4ec37..1f4b378 100644
--- a/tempest/api/network/test_load_balancer.py
+++ b/tempest/api/network/test_load_balancer.py
@@ -17,7 +17,7 @@
 
 from tempest.api.network import base
 from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
 
 
 class LoadBalancerJSON(base.BaseNetworkTest):
@@ -42,6 +42,9 @@
     @classmethod
     def setUpClass(cls):
         super(LoadBalancerJSON, cls).setUpClass()
+        if not test.is_extension_enabled('lbaas', 'network'):
+            msg = "lbaas extension not enabled."
+            raise cls.skipException(msg)
         cls.network = cls.create_network()
         cls.name = cls.network['name']
         cls.subnet = cls.create_subnet(cls.network)
@@ -53,7 +56,7 @@
         cls.member = cls.create_member(80, cls.pool)
         cls.health_monitor = cls.create_health_monitor(4, 3, "TCP", 1)
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_vips(self):
         # Verify the vIP exists in the list of all vIPs
         resp, body = self.client.list_vips()
@@ -97,7 +100,7 @@
         resp, body = self.client.delete_pool(pool['id'])
         self.assertEqual('204', resp['status'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_vip(self):
         # Verifies the details of a vip
         resp, body = self.client.show_vip(self.vip['id'])
@@ -106,7 +109,7 @@
         self.assertEqual(self.vip['id'], vip['id'])
         self.assertEqual(self.vip['name'], vip['name'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_pool(self):
         # Verifies the details of a pool
         resp, body = self.client.show_pool(self.pool['id'])
@@ -115,7 +118,7 @@
         self.assertEqual(self.pool['id'], pool['id'])
         self.assertEqual(self.pool['name'], pool['name'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_pools(self):
         # Verify the pool exists in the list of all pools
         resp, body = self.client.list_pools()
@@ -123,7 +126,7 @@
         pools = body['pools']
         self.assertIn(self.pool['id'], [p['id'] for p in pools])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_members(self):
         # Verify the member exists in the list of all members
         resp, body = self.client.list_members()
@@ -131,7 +134,7 @@
         members = body['members']
         self.assertIn(self.member['id'], [m['id'] for m in members])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_create_update_delete_member(self):
         # Creates a member
         resp, body = self.client.create_member("10.0.9.47", 80,
@@ -148,7 +151,7 @@
         resp, body = self.client.delete_member(member['id'])
         self.assertEqual('204', resp['status'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_member(self):
         # Verifies the details of a member
         resp, body = self.client.show_member(self.member['id'])
@@ -158,7 +161,7 @@
         self.assertEqual(self.member['admin_state_up'],
                          member['admin_state_up'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_health_monitors(self):
         # Verify the health monitor exists in the list of all health monitors
         resp, body = self.client.list_health_monitors()
@@ -167,7 +170,7 @@
         self.assertIn(self.health_monitor['id'],
                       [h['id'] for h in health_monitors])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_create_update_delete_health_monitor(self):
         # Creates a health_monitor
         resp, body = self.client.create_health_monitor(4, 3, "TCP", 1)
@@ -184,7 +187,7 @@
         resp, body = self.client.delete_health_monitor(health_monitor['id'])
         self.assertEqual('204', resp['status'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_health_monitor(self):
         # Verifies the details of a health_monitor
         resp, body = self.client.show_health_monitor(self.health_monitor['id'])
@@ -194,7 +197,7 @@
         self.assertEqual(self.health_monitor['admin_state_up'],
                          health_monitor['admin_state_up'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_associate_disassociate_health_monitor_with_pool(self):
         # Verify that a health monitor can be associated with a pool
         resp, body = (self.client.associate_health_monitor_with_pool
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
index fc3b1d9..d196886 100644
--- a/tempest/api/network/test_vpnaas_extensions.py
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -17,7 +17,7 @@
 
 from tempest.api.network import base
 from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
 
 
 class VPNaaSJSON(base.BaseNetworkTest):
@@ -38,6 +38,9 @@
     @classmethod
     def setUpClass(cls):
         super(VPNaaSJSON, cls).setUpClass()
+        if not test.is_extension_enabled('vpnaas', 'network'):
+            msg = "vpnaas extension not enabled."
+            raise cls.skipException(msg)
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
         cls.router = cls.create_router(
@@ -65,7 +68,7 @@
                 ike_id_list.append(i['id'])
             self.assertNotIn(ike_policy_id, ike_id_list)
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_vpn_services(self):
         # Verify the VPN service exists in the list of all VPN services
         resp, body = self.client.list_vpnservices()
@@ -73,7 +76,7 @@
         vpnservices = body['vpnservices']
         self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_create_update_delete_vpn_service(self):
         # Creates a VPN service
         name = data_utils.rand_name('vpn-service-')
@@ -102,7 +105,7 @@
         vpn_services = [vs['id'] for vs in body['vpnservices']]
         self.assertNotIn(vpnservice['id'], vpn_services)
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_vpn_service(self):
         # Verifies the details of a vpn service
         resp, body = self.client.show_vpnservice(self.vpnservice['id'])
@@ -116,7 +119,7 @@
         self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
         self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_ike_policies(self):
         # Verify the ike policy exists in the list of all IKE policies
         resp, body = self.client.list_ikepolicies()
@@ -124,7 +127,7 @@
         ikepolicies = body['ikepolicies']
         self.assertIn(self.ikepolicy['id'], [i['id'] for i in ikepolicies])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_create_update_delete_ike_policy(self):
         # Creates a IKE policy
         name = data_utils.rand_name('ike-policy-')
@@ -149,7 +152,7 @@
         resp, body = self.client.delete_ikepolicy(ikepolicy['id'])
         self.assertEqual('204', resp['status'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_show_ike_policy(self):
         # Verifies the details of a ike policy
         resp, body = self.client.show_ikepolicy(self.ikepolicy['id'])
diff --git a/tempest/cli/simple_read_only/test_neutron.py b/tempest/cli/simple_read_only/test_neutron.py
index 80376ab..61ffc25 100644
--- a/tempest/cli/simple_read_only/test_neutron.py
+++ b/tempest/cli/simple_read_only/test_neutron.py
@@ -76,11 +76,13 @@
 
     @test.skip_because(bug="1240694")
     @test.attr(type='smoke')
+    @test.requires_ext(extension='metering', service='network')
     def test_neutron_meter_label_list(self):
         self.neutron('meter-label-list')
 
     @test.skip_because(bug="1240694")
     @test.attr(type='smoke')
+    @test.requires_ext(extension='metering', service='network')
     def test_neutron_meter_label_rule_list(self):
         self.neutron('meter-label-rule-list')