Enable tenant isolation for the boto tests

This commit enables using tenant isolation on the boto tests. It also
replaces duplicate Manager() create calls by doing this in the base
boto test class.

Change-Id: Icb018631dcda0753218af8cf1cc4ad461160072c
diff --git a/tempest/test.py b/tempest/test.py
index 61d1311..ab0aa9a 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -273,7 +273,7 @@
                                                    level=None))
 
     @classmethod
-    def get_client_manager(cls):
+    def get_client_manager(cls, interface=None):
         """
         Returns an Openstack client manager
         """
@@ -285,12 +285,27 @@
             force_tenant_isolation):
             creds = cls.isolated_creds.get_primary_creds()
             username, tenant_name, password = creds
-            os = clients.Manager(username=username,
-                                 password=password,
-                                 tenant_name=tenant_name,
-                                 interface=cls._interface)
+            if getattr(cls, '_interface', None):
+                os = clients.Manager(username=username,
+                                     password=password,
+                                     tenant_name=tenant_name,
+                                     interface=cls._interface)
+            elif interface:
+                os = clients.Manager(username=username,
+                                     password=password,
+                                     tenant_name=tenant_name,
+                                     interface=interface)
+            else:
+                os = clients.Manager(username=username,
+                                     password=password,
+                                     tenant_name=tenant_name)
         else:
-            os = clients.Manager(interface=cls._interface)
+            if getattr(cls, '_interface', None):
+                os = clients.Manager(interface=cls._interface)
+            elif interface:
+                os = clients.Manager(interface=interface)
+            else:
+                os = clients.Manager()
         return os
 
     @classmethod
diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py
index d484d94..b36e8c7 100644
--- a/tempest/thirdparty/boto/test.py
+++ b/tempest/thirdparty/boto/test.py
@@ -195,6 +195,7 @@
     def setUpClass(cls):
         super(BotoTestCase, cls).setUpClass()
         cls.conclusion = decision_maker()
+        cls.os = cls.get_client_manager()
         # The trash contains cleanup functions and paramaters in tuples
         # (function, *args, **kwargs)
         cls._resource_trash_bin = {}
@@ -259,6 +260,7 @@
                 LOG.exception("Cleanup failed %s" % func_name)
             finally:
                 del cls._resource_trash_bin[key]
+        cls.clear_isolated_creds()
         super(BotoTestCase, cls).tearDownClass()
         # NOTE(afazekas): let the super called even on exceptions
         # The real exceptions already logged, if the super throws another,
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index 8a08cc2..b638d02 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -15,7 +15,6 @@
 
 from boto import exception
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.common.utils.linux.remote_client import RemoteClient
 from tempest import exceptions
@@ -38,7 +37,6 @@
         if not cls.conclusion['A_I_IMAGES_READY']:
             raise cls.skipException("".join(("EC2 ", cls.__name__,
                                     ": requires ami/aki/ari manifest")))
-        cls.os = clients.Manager()
         cls.s3_client = cls.os.s3_client
         cls.ec2_client = cls.os.ec2api_client
         cls.zone = cls.ec2_client.get_good_zone()
diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py
index b4c1827..329ace3 100644
--- a/tempest/thirdparty/boto/test_ec2_keys.py
+++ b/tempest/thirdparty/boto/test_ec2_keys.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.test import attr
 from tempest.test import skip_because
@@ -30,7 +29,6 @@
     @classmethod
     def setUpClass(cls):
         super(EC2KeysTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.ec2api_client
         cls.ec = cls.ec2_error_code
 
diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py
index 3c3c74d..4b2f01f 100644
--- a/tempest/thirdparty/boto/test_ec2_network.py
+++ b/tempest/thirdparty/boto/test_ec2_network.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from tempest import clients
 from tempest.test import attr
 from tempest.test import skip_because
 from tempest.thirdparty.boto.test import BotoTestCase
@@ -24,7 +23,6 @@
     @classmethod
     def setUpClass(cls):
         super(EC2NetworkTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.ec2api_client
 
     # Note(afazekas): these tests for things duable without an instance
diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py
index 75dd254..9b58603 100644
--- a/tempest/thirdparty/boto/test_ec2_security_groups.py
+++ b/tempest/thirdparty/boto/test_ec2_security_groups.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.test import attr
 from tempest.thirdparty.boto.test import BotoTestCase
@@ -24,7 +23,6 @@
     @classmethod
     def setUpClass(cls):
         super(EC2SecurityGroupTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.ec2api_client
 
     @attr(type='smoke')
diff --git a/tempest/thirdparty/boto/test_ec2_volumes.py b/tempest/thirdparty/boto/test_ec2_volumes.py
index 3e7e2de..04671c5 100644
--- a/tempest/thirdparty/boto/test_ec2_volumes.py
+++ b/tempest/thirdparty/boto/test_ec2_volumes.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from tempest import clients
 from tempest.openstack.common import log as logging
 from tempest.test import attr
 from tempest.thirdparty.boto.test import BotoTestCase
@@ -31,7 +30,6 @@
     @classmethod
     def setUpClass(cls):
         super(EC2VolumesTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.ec2api_client
         cls.zone = cls.client.get_good_zone()
 
diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py
index f8948fd..f34faac 100644
--- a/tempest/thirdparty/boto/test_s3_buckets.py
+++ b/tempest/thirdparty/boto/test_s3_buckets.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.test import attr
 from tempest.test import skip_because
@@ -25,7 +24,6 @@
     @classmethod
     def setUpClass(cls):
         super(S3BucketsTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.s3_client
 
     @skip_because(bug="1076965")
diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py
index 4b7d9dd..7c06d46 100644
--- a/tempest/thirdparty/boto/test_s3_ec2_images.py
+++ b/tempest/thirdparty/boto/test_s3_ec2_images.py
@@ -15,7 +15,6 @@
 
 import os
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.test import attr
 from tempest.thirdparty.boto.test import BotoTestCase
@@ -30,7 +29,6 @@
         if not cls.conclusion['A_I_IMAGES_READY']:
             raise cls.skipException("".join(("EC2 ", cls.__name__,
                                     ": requires ami/aki/ari manifest")))
-        cls.os = clients.Manager()
         cls.s3_client = cls.os.s3_client
         cls.images_client = cls.os.ec2api_client
         config = cls.config
diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py
index f355899..a102a22 100644
--- a/tempest/thirdparty/boto/test_s3_objects.py
+++ b/tempest/thirdparty/boto/test_s3_objects.py
@@ -17,7 +17,6 @@
 
 import boto.s3.key
 
-from tempest import clients
 from tempest.common.utils import data_utils
 from tempest.test import attr
 from tempest.thirdparty.boto.test import BotoTestCase
@@ -28,7 +27,6 @@
     @classmethod
     def setUpClass(cls):
         super(S3BucketsTest, cls).setUpClass()
-        cls.os = clients.Manager()
         cls.client = cls.os.s3_client
 
     @attr(type='smoke')