Cinder storage pools tests

Cinder allows to lists all back-end storage pools that are known
to the scheduler service.

Added cinder api for show_pool command
Add a testcase:
 - Create a volume
 - Verify that pool name matches to volume host attribute

Change-Id: I6b4a1f8b909764cd7c42dd06bea1d41655b29a52
diff --git a/tempest/api/volume/admin/test_volume_pools.py b/tempest/api/volume/admin/test_volume_pools.py
new file mode 100644
index 0000000..c662e8c
--- /dev/null
+++ b/tempest/api/volume/admin/test_volume_pools.py
@@ -0,0 +1,43 @@
+# Copyright 2016 OpenStack Foundation
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from tempest.api.volume import base
+from tempest import test
+
+
+class VolumePoolsAdminV2TestsJSON(base.BaseVolumeAdminTest):
+
+    @classmethod
+    def resource_setup(cls):
+        super(VolumePoolsAdminV2TestsJSON, cls).resource_setup()
+        # Create a test shared volume for tests
+        cls.volume = cls.create_volume()
+
+    @test.idempotent_id('0248a46c-e226-4933-be10-ad6fca8227e7')
+    def test_get_pools_without_details(self):
+        volume_info = self.admin_volume_client. \
+            show_volume(self.volume['id'])['volume']
+        cinder_pools = self.admin_volume_client.show_pools()['pools']
+        self.assertIn(volume_info['os-vol-host-attr:host'],
+                      [pool['name'] for pool in cinder_pools])
+
+    @test.idempotent_id('d4bb61f7-762d-4437-b8a4-5785759a0ced')
+    def test_get_pools_with_details(self):
+        volume_info = self.admin_volume_client. \
+            show_volume(self.volume['id'])['volume']
+        cinder_pools = self.admin_volume_client.\
+            show_pools(detail=True)['pools']
+        self.assertIn(volume_info['os-vol-host-attr:host'],
+                      [pool['name'] for pool in cinder_pools])
diff --git a/tempest/services/volume/base/base_volumes_client.py b/tempest/services/volume/base/base_volumes_client.py
index 4344802..6237745 100644
--- a/tempest/services/volume/base/base_volumes_client.py
+++ b/tempest/services/volume/base/base_volumes_client.py
@@ -62,6 +62,17 @@
         self.expected_success(200, resp.status)
         return rest_client.ResponseBody(resp, body)
 
+    def show_pools(self, detail=False):
+        # List all the volumes pools (hosts)
+        url = 'scheduler-stats/get_pools'
+        if detail:
+            url += '?detail=True'
+
+        resp, body = self.get(url)
+        body = json.loads(body)
+        self.expected_success(200, resp.status)
+        return rest_client.ResponseBody(resp, body)
+
     def show_volume(self, volume_id):
         """Returns the details of a single volume."""
         url = "volumes/%s" % str(volume_id)