Merge "Merge console_output_client to server_client"
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 5888913..d649930 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -199,6 +199,34 @@
     def _parse_resp(self, body):
         return json.loads(body)
 
+    def response_checker(self, method, url, headers, body, resp, resp_body):
+        if (resp.status in set((204, 205, 304)) or resp.status < 200 or
+            method.upper() == 'HEAD') and resp_body:
+            raise exceptions.ResponseWithNonEmptyBody(status=resp.status)
+        #NOTE(afazekas):
+        # If the HTTP Status Code is 205
+        #   'The response MUST NOT include an entity.'
+        # A HTTP entity has an entity-body and an 'entity-header'.
+        # In the HTTP response specification (Section 6) the 'entity-header'
+        # 'generic-header' and 'response-header' are in OR relation.
+        # All headers not in the above two group are considered as entity
+        # header in every interpretation.
+
+        if (resp.status == 205 and
+            0 != len(set(resp.keys()) - set(('status',)) -
+                     self.response_header_lc - self.general_header_lc)):
+                        raise exceptions.ResponseWithEntity()
+        #NOTE(afazekas)
+        # Now the swift sometimes (delete not empty container)
+        # returns with non json error response, we can create new rest class
+        # for swift.
+        # Usually RFC2616 says error responses SHOULD contain an explanation.
+        # The warning is normal for SHOULD/SHOULD NOT case
+
+        # Likely it will cause error
+        if not body and resp.status >= 400:
+            self.log.warning("status >= 400 response with empty body")
+
     def request(self, method, url,
                 headers=None, body=None, depth=0, wait=None):
         """A simple HTTP request interface."""
@@ -215,37 +243,7 @@
         req_url = "%s/%s" % (self.base_url, url)
         resp, resp_body = self.http_obj.request(req_url, method,
                                                 headers=headers, body=body)
-
-        #TODO(afazekas): Make sure we can validate all responses, and the
-        #http library does not do any action automatically
-        if (resp.status in set((204, 205, 304)) or resp.status < 200 or
-                method.upper() == 'HEAD') and resp_body:
-                raise exceptions.ResponseWithNonEmptyBody(status=resp.status)
-
-        #NOTE(afazekas):
-        # If the HTTP Status Code is 205
-        #   'The response MUST NOT include an entity.'
-        # A HTTP entity has an entity-body and an 'entity-header'.
-        # In the HTTP response specification (Section 6) the 'entity-header'
-        # 'generic-header' and 'response-header' are in OR relation.
-        # All headers not in the above two group are considered as entity
-        # header in every interpretation.
-
-        if (resp.status == 205 and
-            0 != len(set(resp.keys()) - set(('status',)) -
-                     self.response_header_lc - self.general_header_lc)):
-                        raise exceptions.ResponseWithEntity()
-
-        #NOTE(afazekas)
-        # Now the swift sometimes (delete not empty container)
-        # returns with non json error response, we can create new rest class
-        # for swift.
-        # Usually RFC2616 says error responses SHOULD contain an explanation.
-        # The warning is normal for SHOULD/SHOULD NOT case
-
-        # Likely it will cause error
-        if not body and resp.status >= 400:
-            self.log.warning("status >= 400 response with empty body")
+        self.response_checker(method, url, headers, body, resp, resp_body)
 
         if resp.status == 401 or resp.status == 403:
             self._log(req_url, body, resp, resp_body)
diff --git a/tempest/testboto.py b/tempest/testboto.py
index ab79f3c..8bcaa33 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -126,7 +126,7 @@
                    testresources.ResourcedTestCase):
     """Recommended to use as base class for boto related test."""
 
-    resources = [('boto_init', tempest.tests.boto.BotoResource())]
+    conclusion = tempest.tests.boto.generic_setup_package()
 
     @classmethod
     def setUpClass(cls):
diff --git a/tempest/tests/boto/__init__.py b/tempest/tests/boto/__init__.py
index 99dd8a9..6d5149e 100644
--- a/tempest/tests/boto/__init__.py
+++ b/tempest/tests/boto/__init__.py
@@ -26,7 +26,6 @@
 import tempest.clients
 from tempest.common.utils.file_utils import have_effective_read_access
 import tempest.config
-from testresources import TestResourceManager
 
 A_I_IMAGES_READY = False  # ari,ami,aki
 S3_CAN_CONNECT_ERROR = "Unknown Error"
@@ -97,8 +96,3 @@
     else:
         S3_CAN_CONNECT_ERROR = None
     boto_logger.setLevel(level)
-
-
-class BotoResource(TestResourceManager):
-    def make(self, dependency_resources=None):
-        return generic_setup_package()
diff --git a/tempest/tests/boto/test_ec2_keys.py b/tempest/tests/boto/test_ec2_keys.py
index 540374a..dea895f 100644
--- a/tempest/tests/boto/test_ec2_keys.py
+++ b/tempest/tests/boto/test_ec2_keys.py
@@ -36,7 +36,9 @@
         super(EC2KeysTest, cls).setUpClass()
         cls.os = clients.Manager()
         cls.client = cls.os.ec2api_client
+        cls.ec = cls.ec2_error_code
 
+#TODO(afazekas): merge create, delete, get test cases
     @attr(type='smoke')
     def test_create_ec2_keypair(self):
         # EC2 create KeyPair
@@ -65,15 +67,13 @@
                         self.client.get_key_pair(key_name)))
 
     @attr(type='smoke')
-    @testtools.skip("Skipped until the Bug #1072762 is resolved")
     def test_duplicate_ec2_keypair(self):
         # EC2 duplicate KeyPair
         key_name = rand_name("keypair-")
         self.addResourceCleanUp(self.client.delete_key_pair, key_name)
         keypair = self.client.create_key_pair(key_name)
-        self.assertEC2ResponseError(self.error_code.client.
-                                    InvalidKeyPair.Duplicate,
-                                    self.client.create_key_pair,
-                                    key_name)
+        self.assertBotoError(self.ec.client.InvalidKeyPair.Duplicate,
+                             self.client.create_key_pair,
+                             key_name)
         self.assertTrue(compare_key_pairs(keypair,
                         self.client.get_key_pair(key_name)))