Apply a naming rule of GET to orchestration client

[GET /resources] methods should be "list_<resource name>s"
or "show_<resource name>", so this patch applies the rule
to orchestration client.

Partially implements blueprint consistent-service-method-names

Change-Id: I5a0d046d3811d48d3e4bddae8b0f022762c621c8
This commit is contained in:
Ken'ichi Ohmichi 2015-04-06 02:52:11 +00:00
parent 35798fb10a
commit e06f0e7b25
8 changed files with 37 additions and 32 deletions

View File

@ -199,5 +199,5 @@ class BaseOrchestrationTest(tempest.test.BaseTestCase):
for r in resources)
def get_stack_output(self, stack_identifier, output_key):
body = self.client.get_stack(stack_identifier)
body = self.client.show_stack(stack_identifier)
return self.stack_output(body, output_key)

View File

@ -81,8 +81,8 @@ class NeutronResourcesTestJSON(base.BaseOrchestrationTest):
# attempt to log the server console to help with debugging
# the cause of the server not signalling the waitcondition
# to heat.
body = cls.client.get_resource(cls.stack_identifier,
'Server')
body = cls.client.show_resource(cls.stack_identifier,
'Server')
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
output = cls.servers_client.get_console_output(

View File

@ -66,7 +66,7 @@ class StacksTestJSON(base.BaseOrchestrationTest):
@test.idempotent_id('992f96e3-41ee-4ff6-91c7-bcfb670c0919')
def test_stack_show(self):
"""Getting details about created stack should be possible."""
stack = self.client.get_stack(self.stack_name)
stack = self.client.show_stack(self.stack_name)
self.assertIsInstance(stack, dict)
self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
'parameters', 'outputs', 'disable_rollback',
@ -105,8 +105,8 @@ class StacksTestJSON(base.BaseOrchestrationTest):
@test.idempotent_id('2aba03b3-392f-4237-900b-1f5a5e9bd962')
def test_show_resource(self):
"""Getting details about created resource should be possible."""
resource = self.client.get_resource(self.stack_identifier,
self.resource_name)
resource = self.client.show_resource(self.stack_identifier,
self.resource_name)
self.assertIsInstance(resource, dict)
self.assert_fields_in_dict(resource, 'resource_name', 'description',
'links', 'logical_resource_id',

View File

@ -73,7 +73,7 @@ class NovaKeyPairResourcesYAMLTest(base.BaseOrchestrationTest):
@test.attr(type='gate')
@test.idempotent_id('8d77dec7-91fd-45a6-943d-5abd45e338a4')
def test_stack_keypairs_output(self):
stack = self.client.get_stack(self.stack_name)
stack = self.client.show_stack(self.stack_name)
self.assertIsInstance(stack, dict)
output_map = {}

View File

@ -32,7 +32,7 @@ class ResourceTypesTest(base.BaseOrchestrationTest):
self.assertNotEmpty(resource_types)
for resource_type in resource_types:
type_schema = self.client.get_resource_type(resource_type)
type_schema = self.client.show_resource_type(resource_type)
self.assert_fields_in_dict(type_schema, 'properties',
'attributes', 'resource_type')
self.assertEqual(resource_type, type_schema['resource_type'])
@ -41,7 +41,7 @@ class ResourceTypesTest(base.BaseOrchestrationTest):
@test.idempotent_id('8401821d-65fe-4d43-9fa3-57d5ce3a35c7')
def test_resource_type_template(self):
"""Verify it is possible to get template about resource types."""
type_template = self.client.get_resource_type_template(
type_template = self.client.show_resource_type_template(
'OS::Nova::Server')
self.assert_fields_in_dict(
type_template,

View File

@ -71,28 +71,28 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
self.client.delete_software_deploy(deploy_id)
# Testing that it is really gone
self.assertRaises(
lib_exc.NotFound, self.client.get_software_deploy,
lib_exc.NotFound, self.client.show_software_deployment,
self.deployment_id)
def _config_delete(self, config_id):
self.client.delete_software_config(config_id)
# Testing that it is really gone
self.assertRaises(
lib_exc.NotFound, self.client.get_software_config, config_id)
lib_exc.NotFound, self.client.show_software_config, config_id)
@test.attr(type='smoke')
@test.idempotent_id('136162ed-9445-4b9c-b7fc-306af8b5da99')
def test_get_software_config(self):
"""Testing software config get."""
for conf in self.configs:
api_config = self.client.get_software_config(conf['id'])
api_config = self.client.show_software_config(conf['id'])
self._validate_config(conf, api_config)
@test.attr(type='smoke')
@test.idempotent_id('1275c835-c967-4a2c-8d5d-ad533447ed91')
def test_get_deployment_list(self):
"""Getting a list of all deployments"""
deploy_list = self.client.get_software_deploy_list()
deploy_list = self.client.list_software_deployments()
deploy_ids = [deploy['id'] for deploy in
deploy_list['software_deployments']]
self.assertIn(self.deployment_id, deploy_ids)
@ -101,12 +101,13 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
@test.idempotent_id('fe7cd9f9-54b1-429c-a3b7-7df8451db913')
def test_get_deployment_metadata(self):
"""Testing deployment metadata get"""
metadata = self.client.get_software_deploy_meta(self.server_id)
metadata = self.client.show_software_deployment_metadata(
self.server_id)
conf_ids = [conf['id'] for conf in metadata['metadata']]
self.assertIn(self.configs[0]['id'], conf_ids)
def _validate_deployment(self, action, status, reason, config_id):
deployment = self.client.get_software_deploy(self.deployment_id)
deployment = self.client.show_software_deployment(self.deployment_id)
self.assertEqual(action, deployment['software_deployment']['action'])
self.assertEqual(status, deployment['software_deployment']['status'])
self.assertEqual(reason,
@ -131,7 +132,8 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
@test.idempotent_id('2ac43ab3-34f2-415d-be2e-eabb4d14ee32')
def test_software_deployment_update_no_metadata_change(self):
"""Testing software deployment update without metadata change."""
metadata = self.client.get_software_deploy_meta(self.server_id)
metadata = self.client.show_software_deployment_metadata(
self.server_id)
# Updating values without changing the configuration ID
new_action = 'ACTION_1'
new_status = 'STATUS_1'
@ -145,7 +147,8 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
new_reason, self.configs[0]['id'])
# Metadata should not be changed at this point
test_metadata = self.client.get_software_deploy_meta(self.server_id)
test_metadata = self.client.show_software_deployment_metadata(
self.server_id)
for key in metadata['metadata'][0]:
self.assertEqual(
metadata['metadata'][0][key],
@ -155,7 +158,8 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
@test.idempotent_id('92c48944-d79d-4595-a840-8e1a581c1a72')
def test_software_deployment_update_with_metadata_change(self):
"""Testing software deployment update with metadata change."""
metadata = self.client.get_software_deploy_meta(self.server_id)
metadata = self.client.show_software_deployment_metadata(
self.server_id)
self.client.update_software_deploy(
self.deployment_id, self.server_id, self.configs[1]['id'],
self.action, self.status, self.input_values,
@ -163,7 +167,8 @@ class TestSoftwareConfig(base.BaseOrchestrationTest):
self._validate_deployment(self.action, self.status,
self.status_reason, self.configs[1]['id'])
# Metadata should now be changed
new_metadata = self.client.get_software_deploy_meta(self.server_id)
new_metadata = self.client.show_software_deployment_metadata(
self.server_id)
# Its enough to test the ID in this case
meta_id = metadata['metadata'][0]['id']
test_id = new_metadata['metadata'][0]['id']

View File

@ -52,15 +52,15 @@ class StacksTestJSON(base.BaseOrchestrationTest):
self.assertIn(stack_id, list_ids)
# fetch the stack
stack = self.client.get_stack(stack_identifier)
stack = self.client.show_stack(stack_identifier)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by name
stack = self.client.get_stack(stack_name)
stack = self.client.show_stack(stack_name)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by id
stack = self.client.get_stack(stack_id)
stack = self.client.show_stack(stack_id)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# delete the stack

View File

@ -105,7 +105,7 @@ class OrchestrationClient(service_client.ServiceClient):
headers['X-Auth-User'] = self.user
return headers, body
def get_stack(self, stack_identifier):
def show_stack(self, stack_identifier):
"""Returns the details of a single stack."""
url = "stacks/%s" % stack_identifier
resp, body = self.get(url)
@ -137,7 +137,7 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBodyList(resp, body['resources'])
def get_resource(self, stack_identifier, resource_name):
def show_resource(self, stack_identifier, resource_name):
"""Returns the details of a single resource."""
url = "stacks/%s/resources/%s" % (stack_identifier, resource_name)
resp, body = self.get(url)
@ -159,7 +159,7 @@ class OrchestrationClient(service_client.ServiceClient):
while True:
try:
body = self.get_resource(
body = self.show_resource(
stack_identifier, resource_name)
except lib_exc.NotFound:
# ignore this, as the resource may not have
@ -195,7 +195,7 @@ class OrchestrationClient(service_client.ServiceClient):
while True:
try:
body = self.get_stack(stack_identifier)
body = self.show_stack(stack_identifier)
except lib_exc.NotFound:
if status == 'DELETE_COMPLETE':
return
@ -295,14 +295,14 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBodyList(resp, body['resource_types'])
def get_resource_type(self, resource_type_name):
def show_resource_type(self, resource_type_name):
"""Return the schema of a resource type."""
url = 'resource_types/%s' % resource_type_name
resp, body = self.get(url)
self.expected_success(200, resp.status)
return service_client.ResponseBody(resp, json.loads(body))
def get_resource_type_template(self, resource_type_name):
def show_resource_type_template(self, resource_type_name):
"""Return the template of a resource type."""
url = 'resource_types/%s/template' % resource_type_name
resp, body = self.get(url)
@ -320,7 +320,7 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBody(resp, body)
def get_software_config(self, conf_id):
def show_software_config(self, conf_id):
"""Returns a software configuration resource."""
url = 'software_configs/%s' % str(conf_id)
resp, body = self.get(url)
@ -365,7 +365,7 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBody(resp, body)
def get_software_deploy_list(self):
def list_software_deployments(self):
"""Returns a list of all deployments."""
url = 'software_deployments'
resp, body = self.get(url)
@ -373,7 +373,7 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBody(resp, body)
def get_software_deploy(self, deploy_id):
def show_software_deployment(self, deploy_id):
"""Returns a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, body = self.get(url)
@ -381,7 +381,7 @@ class OrchestrationClient(service_client.ServiceClient):
body = json.loads(body)
return service_client.ResponseBody(resp, body)
def get_software_deploy_meta(self, server_id):
def show_software_deployment_metadata(self, server_id):
"""Return a config metadata for a specific server."""
url = 'software_deployments/metadata/%s' % server_id
resp, body = self.get(url)