api-tests: Common way to define required extensions

As some tests require extensions to be enabled on the server, this patch
introduces a new class attribute to the API base class. If any extension
defined in test class is not enabled on the server, then all tests in
the test class will be skipped.

Change-Id: I0629153f973daeb3bef3a6968360cbc2d427f9ad
diff --git a/neutron/tests/tempest/api/test_trunk.py b/neutron/tests/tempest/api/test_trunk.py
index 2617eba..3e035a0 100644
--- a/neutron/tests/tempest/api/test_trunk.py
+++ b/neutron/tests/tempest/api/test_trunk.py
@@ -38,20 +38,13 @@
 
 class TrunkTestJSONBase(base.BaseAdminNetworkTest):
 
-    extension = 'trunk'
+    required_extensions = ['trunk']
 
     def setUp(self):
         self.addCleanup(self.resource_cleanup)
         super(TrunkTestJSONBase, self).setUp()
 
     @classmethod
-    def skip_checks(cls):
-        super(TrunkTestJSONBase, cls).skip_checks()
-        if not test.is_extension_enabled(cls.extension, 'network'):
-            msg = "%s extension not enabled." % cls.extension
-            raise cls.skipException(msg)
-
-    @classmethod
     def resource_setup(cls):
         super(TrunkTestJSONBase, cls).resource_setup()
         cls.trunks = []
@@ -227,10 +220,6 @@
     @classmethod
     def skip_checks(cls):
         super(TrunkTestInheritJSONBase, cls).skip_checks()
-        for ext in cls.required_extensions:
-            if not test.is_extension_enabled(ext, 'network'):
-                msg = "%s extension not enabled." % ext
-                raise cls.skipException(msg)
         if ("vlan" not in
                 config.CONF.neutron_plugin_options.available_type_drivers):
             raise cls.skipException("VLAN type_driver is not enabled")
@@ -277,11 +266,6 @@
     @classmethod
     def skip_checks(cls):
         super(TrunkTestMtusJSONBase, cls).skip_checks()
-        for ext in cls.required_extensions:
-            if not test.is_extension_enabled(ext, 'network'):
-                msg = "%s extension not enabled." % ext
-                raise cls.skipException(msg)
-
         if any(t
                not in config.CONF.neutron_plugin_options.available_type_drivers
                for t in ['gre', 'vxlan']):
@@ -351,16 +335,10 @@
 
 class TrunksSearchCriteriaTest(base.BaseSearchCriteriaTest):
 
+    required_extensions = ['trunk']
     resource = 'trunk'
 
     @classmethod
-    def skip_checks(cls):
-        super(TrunksSearchCriteriaTest, cls).skip_checks()
-        if not test.is_extension_enabled('trunk', 'network'):
-            msg = "trunk extension not enabled."
-            raise cls.skipException(msg)
-
-    @classmethod
     def resource_setup(cls):
         super(TrunksSearchCriteriaTest, cls).resource_setup()
         cls.trunks = []