Merge "Add tempest tests for os-host/{host-name} api"
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index af76ad0..19d7973 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -15,6 +15,7 @@
 #    under the License.
 
 from tempest.api.compute import base
+from tempest.common.utils.data_utils import rand_name
 from tempest import exceptions
 from tempest.test import attr
 
@@ -71,6 +72,30 @@
         self.assertRaises(exceptions.Unauthorized,
                           self.non_admin_client.list_hosts)
 
+    @attr(type='gate')
+    def test_show_host_detail(self):
+        resp, hosts = self.client.list_hosts()
+        self.assertEqual(200, resp.status)
+        self.assertTrue(len(hosts) >= 1)
+        hostname = hosts[0]['host_name']
+
+        resp, resources = self.client.show_host_detail(hostname)
+        self.assertEqual(200, resp.status)
+        self.assertTrue(len(resources) >= 1)
+        host_resource = resources[0]['resource']
+        self.assertIsNotNone(host_resource)
+        self.assertIsNotNone(host_resource['cpu'])
+        self.assertIsNotNone(host_resource['disk_gb'])
+        self.assertIsNotNone(host_resource['memory_mb'])
+        self.assertIsNotNone(host_resource['project'])
+        self.assertEqual(hostname, host_resource['host'])
+
+    @attr(type='negative')
+    def test_show_host_detail_with_nonexist_hostname(self):
+        hostname = rand_name('rand_hostname')
+        self.assertRaises(exceptions.NotFound,
+                          self.client.show_host_detail, hostname)
+
 
 class HostsAdminTestXML(HostsAdminTestJSON):
     _interface = 'xml'
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index 8093d19..30a3f7b 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -37,3 +37,10 @@
         resp, body = self.get(url)
         body = json.loads(body)
         return resp, body['hosts']
+
+    def show_host_detail(self, hostname):
+        """Show detail information for the host."""
+
+        resp, body = self.get("os-hosts/%s" % str(hostname))
+        body = json.loads(body)
+        return resp, body['host']
diff --git a/tempest/services/compute/xml/hosts_client.py b/tempest/services/compute/xml/hosts_client.py
index 70aeb48..9743143 100644
--- a/tempest/services/compute/xml/hosts_client.py
+++ b/tempest/services/compute/xml/hosts_client.py
@@ -39,3 +39,11 @@
         node = etree.fromstring(body)
         body = [xml_to_json(x) for x in node.getchildren()]
         return resp, body
+
+    def show_host_detail(self, hostname):
+        """Show detail information for the host."""
+
+        resp, body = self.get("os-hosts/%s" % str(hostname), self.headers)
+        node = etree.fromstring(body)
+        body = [xml_to_json(x) for x in node.getchildren()]
+        return resp, body