Fix failures when l3_agent_scheduler ext is not available

Some plugins do not support the L3 agent scheduler extension.
Therefore, make the tests that rely on it dependent on whether
this is actually available in the plugin under test.

Change-Id: I3154b646677379a34465c6826b71d4ad72c471a2
Closes-bug: #1231152
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 9c187fd..64ab051 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -16,7 +16,7 @@
 
 from tempest.api.network import base
 from tempest.common.utils import data_utils
-from tempest.test import attr
+from tempest import test
 
 
 class L3AgentSchedulerJSON(base.BaseAdminNetworkTest):
@@ -36,8 +36,11 @@
     @classmethod
     def setUpClass(cls):
         super(L3AgentSchedulerJSON, cls).setUpClass()
+        if not test.is_extension_enabled('l3_agent_scheduler', 'network'):
+            msg = "L3 Agent Scheduler Extension not enabled."
+            raise cls.skipException(msg)
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_routers_on_l3_agent(self):
         resp, body = self.admin_client.list_agents()
         agents = body['agents']
@@ -48,7 +51,7 @@
             agent['id'])
         self.assertEqual('200', resp['status'])
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_l3_agents_hosting_router(self):
         name = data_utils.rand_name('router-')
         resp, router = self.client.create_router(name)
diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py
index 1b27d1b..ff35d20 100644
--- a/tempest/api/network/test_extensions.py
+++ b/tempest/api/network/test_extensions.py
@@ -17,7 +17,7 @@
 
 
 from tempest.api.network import base
-from tempest.test import attr
+from tempest import test
 
 
 class ExtensionsTestJSON(base.BaseNetworkTest):
@@ -38,7 +38,7 @@
     def setUpClass(cls):
         super(ExtensionsTestJSON, cls).setUpClass()
 
-    @attr(type='smoke')
+    @test.attr(type='smoke')
     def test_list_show_extensions(self):
         # List available extensions for the tenant
         expected_alias = ['security-group', 'l3_agent_scheduler',
@@ -70,9 +70,11 @@
             self.assertEqual(ext_details['alias'], ext_alias)
             self.assertEqual(ext_details, ext)
         # Verify if expected extensions are present in the actual list
-        # of extensions returned
+        # of extensions returned, but only for those that have been
+        # enabled via configuration
         for e in expected_alias:
-            self.assertIn(e, actual_alias)
+            if test.is_extension_enabled(e, 'network'):
+                self.assertIn(e, actual_alias)
 
 
 class ExtensionsTestXML(ExtensionsTestJSON):