Add a hacking check to block scenario manager in api tests

This commit adds a new hacking check to ensure that the manager class
from the scenario tests, OfficialClientManager, isn't used in the API
tests. There is already a hacking rule preventing imports of the
official clients, T102. But, the official clients could still be used
through the scenario tests which wouldn't be caught by T102. This
attempts to close that gap by adding a new hacking check for
OfficialClientManager.

Change-Id: I608a1319c136118947e3df74fa88f7124011caa4
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index 183d422..6a4cc6d 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -105,9 +105,24 @@
                             "T107: service tag should not be in path")
 
 
+def no_official_client_manager_in_api_tests(physical_line, filename):
+    """Check that the OfficialClientManager isn't used in the api tests
+
+    The api tests should not use the official clients.
+
+    T108: Can not use OfficialClientManager in the API tests
+    """
+    if 'tempest/api' in filename:
+        if 'OfficialClientManager' in physical_line:
+            return (physical_line.find('OfficialClientManager'),
+                    'T108: OfficialClientManager can not be used in the api '
+                    'tests')
+
+
 def factory(register):
     register(import_no_clients_in_api)
     register(scenario_tests_need_service_tags)
     register(no_setupclass_for_unit_tests)
     register(no_vi_headers)
     register(service_tags_not_in_module_path)
+    register(no_official_client_manager_in_api_tests)
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index ab81836..70bfdb7 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -93,3 +93,11 @@
             './tempest/scenario/compute/fake_test.py'))
         self.assertFalse(checks.service_tags_not_in_module_path(
             "@test.services('compute')", './tempest/api/image/fake_test.py'))
+
+    def test_no_official_client_manager_in_api_tests(self):
+        self.assertTrue(checks.no_official_client_manager_in_api_tests(
+            "cls.official_client = clients.OfficialClientManager(credentials)",
+            "tempest/api/compute/base.py"))
+        self.assertFalse(checks.no_official_client_manager_in_api_tests(
+            "cls.official_client = clients.OfficialClientManager(credentials)",
+            "tempest/scenario/fake_test.py"))