Apply a naming rule of GET to compute clients(h*)
[GET /resources] methods should be "list_<resource name>s"
or "show_<resource name>", so this patch applies the rule
to compute clients which names are "h*".
Partially implements blueprint consistent-service-method-names
Change-Id: Id2346a6c65cd931b8876d6597fbb82361d1f5839
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index a91c9bf..9fee2a1 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -69,7 +69,7 @@
for host in hosts:
hostname = host['host_name']
- resources = self.client.show_host_detail(hostname)
+ resources = self.client.show_host(hostname)
self.assertTrue(len(resources) >= 1)
host_resource = resources[0]['resource']
self.assertIsNotNone(host_resource)
diff --git a/tempest/api/compute/admin/test_hosts_negative.py b/tempest/api/compute/admin/test_hosts_negative.py
index 042d1fb..930d686 100644
--- a/tempest/api/compute/admin/test_hosts_negative.py
+++ b/tempest/api/compute/admin/test_hosts_negative.py
@@ -48,7 +48,7 @@
def test_show_host_detail_with_nonexistent_hostname(self):
nonexitent_hostname = data_utils.rand_name('rand_hostname')
self.assertRaises(lib_exc.NotFound,
- self.client.show_host_detail, nonexitent_hostname)
+ self.client.show_host, nonexitent_hostname)
@test.attr(type=['negative'])
@test.idempotent_id('19ebe09c-bfd4-4b7c-81a2-e2e0710f59cc')
@@ -56,7 +56,7 @@
hostname = self._get_host_name()
self.assertRaises(lib_exc.Forbidden,
- self.non_admin_client.show_host_detail,
+ self.non_admin_client.show_host,
hostname)
@test.attr(type=['negative'])
diff --git a/tempest/api/compute/admin/test_hypervisor.py b/tempest/api/compute/admin/test_hypervisor.py
index 9483f52..47f66af 100644
--- a/tempest/api/compute/admin/test_hypervisor.py
+++ b/tempest/api/compute/admin/test_hypervisor.py
@@ -30,7 +30,7 @@
def _list_hypervisors(self):
# List of hypervisors
- hypers = self.client.get_hypervisor_list()
+ hypers = self.client.list_hypervisors()
return hypers
def assertHypervisors(self, hypers):
@@ -45,7 +45,7 @@
@test.idempotent_id('1e7fdac2-b672-4ad1-97a4-bad0e3030118')
def test_get_hypervisor_list_details(self):
# Display the details of the all hypervisor
- hypers = self.client.get_hypervisor_list_details()
+ hypers = self.client.list_hypervisors(detail=True)
self.assertHypervisors(hypers)
@test.idempotent_id('94ff9eae-a183-428e-9cdb-79fde71211cc')
@@ -54,7 +54,7 @@
hypers = self._list_hypervisors()
self.assertHypervisors(hypers)
- details = self.client.get_hypervisor_show_details(hypers[0]['id'])
+ details = self.client.show_hypervisor(hypers[0]['id'])
self.assertTrue(len(details) > 0)
self.assertEqual(details['hypervisor_hostname'],
hypers[0]['hypervisor_hostname'])
@@ -66,13 +66,13 @@
self.assertHypervisors(hypers)
hostname = hypers[0]['hypervisor_hostname']
- hypervisors = self.client.get_hypervisor_servers(hostname)
+ hypervisors = self.client.list_servers_on_hypervisor(hostname)
self.assertTrue(len(hypervisors) > 0)
@test.idempotent_id('797e4f28-b6e0-454d-a548-80cc77c00816')
def test_get_hypervisor_stats(self):
# Verify the stats of the all hypervisor
- stats = self.client.get_hypervisor_stats()
+ stats = self.client.show_hypervisor_statistics()
self.assertTrue(len(stats) > 0)
@test.idempotent_id('91a50d7d-1c2b-4f24-b55a-a1fe20efca70')
@@ -88,7 +88,7 @@
ironic_only = True
hypers_without_ironic = []
for hyper in hypers:
- details = self.client.get_hypervisor_show_details(hypers[0]['id'])
+ details = self.client.show_hypervisor(hypers[0]['id'])
if details['hypervisor_type'] != 'ironic':
hypers_without_ironic.append(hyper)
ironic_only = False
@@ -102,7 +102,7 @@
# because hypervisors might be disabled, this loops looking
# for any good hit.
try:
- uptime = self.client.get_hypervisor_uptime(hyper['id'])
+ uptime = self.client.show_hypervisor_uptime(hyper['id'])
if len(uptime) > 0:
has_valid_uptime = True
break
diff --git a/tempest/api/compute/admin/test_hypervisor_negative.py b/tempest/api/compute/admin/test_hypervisor_negative.py
index 24b0090..a5c2f0d 100644
--- a/tempest/api/compute/admin/test_hypervisor_negative.py
+++ b/tempest/api/compute/admin/test_hypervisor_negative.py
@@ -36,7 +36,7 @@
def _list_hypervisors(self):
# List of hypervisors
- hypers = self.client.get_hypervisor_list()
+ hypers = self.client.list_hypervisors()
return hypers
@test.attr(type=['negative'])
@@ -46,7 +46,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_show_details,
+ self.client.show_hypervisor,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -57,7 +57,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_show_details,
+ self.non_adm_client.show_hypervisor,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -68,7 +68,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_servers,
+ self.non_adm_client.list_servers_on_hypervisor,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -78,7 +78,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_servers,
+ self.client.list_servers_on_hypervisor,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -86,7 +86,7 @@
def test_get_hypervisor_stats_with_non_admin_user(self):
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_stats)
+ self.non_adm_client.show_hypervisor_statistics)
@test.attr(type=['negative'])
@test.idempotent_id('f60aa680-9a3a-4c7d-90e1-fae3a4891303')
@@ -95,7 +95,7 @@
self.assertRaises(
lib_exc.NotFound,
- self.client.get_hypervisor_uptime,
+ self.client.show_hypervisor_uptime,
nonexistent_hypervisor_id)
@test.attr(type=['negative'])
@@ -106,7 +106,7 @@
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_uptime,
+ self.non_adm_client.show_hypervisor_uptime,
hypers[0]['id'])
@test.attr(type=['negative'])
@@ -115,7 +115,7 @@
# List of hypervisor and available services with non admin user
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_list)
+ self.non_adm_client.list_hypervisors)
@test.attr(type=['negative'])
@test.idempotent_id('dc02db05-e801-4c5f-bc8e-d915290ab345')
@@ -123,7 +123,7 @@
# List of hypervisor details and available services with non admin user
self.assertRaises(
lib_exc.Forbidden,
- self.non_adm_client.get_hypervisor_list_details)
+ self.non_adm_client.list_hypervisors, detail=True)
@test.attr(type=['negative'])
@test.idempotent_id('19a45cc1-1000-4055-b6d2-28e8b2ec4faa')
diff --git a/tempest/services/compute/json/hosts_client.py b/tempest/services/compute/json/hosts_client.py
index 287482f..223b80f 100644
--- a/tempest/services/compute/json/hosts_client.py
+++ b/tempest/services/compute/json/hosts_client.py
@@ -34,7 +34,7 @@
self.validate_response(schema.list_hosts, resp, body)
return service_client.ResponseBodyList(resp, body['hosts'])
- def show_host_detail(self, hostname):
+ def show_host(self, hostname):
"""Show detail information for the host."""
resp, body = self.get("os-hosts/%s" % str(hostname))
diff --git a/tempest/services/compute/json/hypervisor_client.py b/tempest/services/compute/json/hypervisor_client.py
index 49ac266..2f9f701 100644
--- a/tempest/services/compute/json/hypervisor_client.py
+++ b/tempest/services/compute/json/hypervisor_client.py
@@ -21,42 +21,41 @@
class HypervisorClientJSON(service_client.ServiceClient):
- def get_hypervisor_list(self):
+ def list_hypervisors(self, detail=False):
"""List hypervisors information."""
- resp, body = self.get('os-hypervisors')
+ url = 'os-hypervisors'
+ _schema = schema.list_search_hypervisors
+ if detail:
+ url += '/detail'
+ _schema = schema.list_hypervisors_detail
+
+ resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.list_search_hypervisors, resp, body)
+ self.validate_response(_schema, resp, body)
return service_client.ResponseBodyList(resp, body['hypervisors'])
- def get_hypervisor_list_details(self):
- """Show detailed hypervisors information."""
- resp, body = self.get('os-hypervisors/detail')
- body = json.loads(body)
- self.validate_response(schema.list_hypervisors_detail, resp, body)
- return service_client.ResponseBodyList(resp, body['hypervisors'])
-
- def get_hypervisor_show_details(self, hyper_id):
+ def show_hypervisor(self, hyper_id):
"""Display the details of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s' % hyper_id)
body = json.loads(body)
self.validate_response(schema.get_hypervisor, resp, body)
return service_client.ResponseBody(resp, body['hypervisor'])
- def get_hypervisor_servers(self, hyper_name):
+ def list_servers_on_hypervisor(self, hyper_name):
"""List instances belonging to the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/servers' % hyper_name)
body = json.loads(body)
self.validate_response(schema.get_hypervisors_servers, resp, body)
return service_client.ResponseBodyList(resp, body['hypervisors'])
- def get_hypervisor_stats(self):
+ def show_hypervisor_statistics(self):
"""Get hypervisor statistics over all compute nodes."""
resp, body = self.get('os-hypervisors/statistics')
body = json.loads(body)
self.validate_response(schema.get_hypervisor_statistics, resp, body)
return service_client.ResponseBody(resp, body['hypervisor_statistics'])
- def get_hypervisor_uptime(self, hyper_id):
+ def show_hypervisor_uptime(self, hyper_id):
"""Display the uptime of the specified hypervisor."""
resp, body = self.get('os-hypervisors/%s/uptime' % hyper_id)
body = json.loads(body)