Make rest_client module py34-compatible

We are testing tempest-lib on py27 and py34 now.
To move rest_client module to tempest-lib, this patch makes it
py34-compatible.

* iteritems() has been removed since py3.
* items() returns dict_keys object on py3, so it is necessary to
  convert the return value with list() clearly to avoid TypeError.

Change-Id: Ie9105b5d01e7883213c1d3398cc5fe56782920d9
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 8786a17..c5696b7 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -295,7 +295,7 @@
             if len(body.keys()) > 1:
                 return body
             # Just return the "wrapped" element
-            first_key, first_item = body.items()[0]
+            first_key, first_item = six.next(six.iteritems(body))
             if isinstance(first_item, (dict, list)):
                 return first_item
         except (ValueError, IndexError):
diff --git a/tempest/tests/test_rest_client.py b/tempest/tests/test_rest_client.py
index e42fab7..30cf709 100644
--- a/tempest/tests/test_rest_client.py
+++ b/tempest/tests/test_rest_client.py
@@ -16,6 +16,7 @@
 
 import httplib2
 from oslotest import mockpatch
+import six
 
 from tempest.common import rest_client
 from tempest import config
@@ -94,7 +95,7 @@
 
     def _verify_headers(self, resp):
         self.assertEqual(self.rest_client._get_type(), self.TYPE)
-        resp = dict((k.lower(), v) for k, v in resp.iteritems())
+        resp = dict((k.lower(), v) for k, v in six.iteritems(resp))
         self.assertEqual(self.header_value, resp['accept'])
         self.assertEqual(self.header_value, resp['content-type'])