From 9a3a9a2ee824f43609020f12e2c391aed0852b29 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Tue, 18 Aug 2015 17:03:55 +0900 Subject: [PATCH] Return complete response from floating_ips_client Currently compute floating_ips_client returns Response by removing top key from Response. For example- return service_client.ResponseBody(resp, body['floating_ip']) As service clients are in direction to move to Tempest-lib, all service clients should return Response without any truncation. One good example is Resource pagination links which are lost with current way of return value. Resource pagination links are present in parallel (not inside) to top key of Response. This patch makes compute floating_ips_lient to return complete Response body. Implements: blueprint method-return-value-and-move-service-clients-to-lib Change-Id: Ib11e815a944321589dd618c7696249f0e0eb3938 --- .../floating_ips/test_floating_ips_actions.py | 15 ++++++++------- .../test_floating_ips_actions_negative.py | 2 +- .../floating_ips/test_list_floating_ips.py | 8 ++++---- tempest/api/compute/servers/test_server_rescue.py | 2 +- tempest/cmd/cleanup_service.py | 2 +- tempest/cmd/javelin.py | 2 +- tempest/common/validation_resources.py | 3 +-- tempest/scenario/manager.py | 3 ++- tempest/scenario/test_baremetal_basic_ops.py | 3 ++- tempest/scenario/test_server_basic_ops.py | 3 ++- tempest/scenario/test_shelve_instance.py | 3 ++- tempest/scenario/test_volume_boot_pattern.py | 3 ++- .../services/compute/json/floating_ips_client.py | 6 +++--- tempest/stress/actions/ssh_floating.py | 6 ++++-- tempest/stress/actions/volume_attach_verify.py | 6 ++++-- tempest/stress/cleanup.py | 3 ++- 16 files changed, 40 insertions(+), 30 deletions(-) diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py index 8bb4faca64..5b906412d0 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py @@ -39,7 +39,7 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): server = cls.create_test_server(wait_until='ACTIVE') cls.server_id = server['id'] # Floating IP creation - body = cls.client.create_floating_ip() + body = cls.client.create_floating_ip()['floating_ip'] cls.floating_ip_id = body['id'] cls.floating_ip = body['ip'] @@ -63,14 +63,14 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): def test_allocate_floating_ip(self): # Positive test:Allocation of a new floating IP to a project # should be successful - body = self.client.create_floating_ip() + body = self.client.create_floating_ip()['floating_ip'] floating_ip_id_allocated = body['id'] self.addCleanup(self.client.delete_floating_ip, floating_ip_id_allocated) - floating_ip_details = \ - self.client.show_floating_ip(floating_ip_id_allocated) + floating_ip_details = self.client.show_floating_ip( + floating_ip_id_allocated)['floating_ip'] # Checking if the details of allocated IP is in list of floating IP - body = self.client.list_floating_ips() + body = self.client.list_floating_ips()['floating_ips'] self.assertIn(floating_ip_details, body) @test.idempotent_id('de45e989-b5ca-4a9b-916b-04a52e7bbb8b') @@ -79,7 +79,7 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): # Positive test:Deletion of valid floating IP from project # should be successful # Creating the floating IP that is to be deleted in this method - floating_ip_body = self.client.create_floating_ip() + floating_ip_body = self.client.create_floating_ip()['floating_ip'] self.addCleanup(self._try_delete_floating_ip, floating_ip_body['id']) # Deleting the floating IP from the project self.client.delete_floating_ip(floating_ip_body['id']) @@ -98,7 +98,8 @@ class FloatingIPsTestJSON(base.BaseFloatingIPsTest): self.server_id) # Check instance_id in the floating_ip body - body = self.client.show_floating_ip(self.floating_ip_id) + body = (self.client.show_floating_ip(self.floating_ip_id) + ['floating_ip']) self.assertEqual(self.server_id, body['instance_id']) # Disassociation of floating IP that was associated in this method diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py index c07af729d4..64aac8074c 100644 --- a/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py +++ b/tempest/api/compute/floating_ips/test_floating_ips_actions_negative.py @@ -42,7 +42,7 @@ class FloatingIPsNegativeTestJSON(base.BaseFloatingIPsTest): cls.server_id = server['id'] # Generating a nonexistent floatingIP id cls.floating_ip_ids = [] - body = cls.client.list_floating_ips() + body = cls.client.list_floating_ips()['floating_ips'] for i in range(len(body)): cls.floating_ip_ids.append(body[i]['id']) while True: diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py index d26a5e56b6..30e2e508a9 100644 --- a/tempest/api/compute/floating_ips/test_list_floating_ips.py +++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py @@ -31,7 +31,7 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest): cls.floating_ip = [] cls.floating_ip_id = [] for i in range(3): - body = cls.client.create_floating_ip() + body = cls.client.create_floating_ip()['floating_ip'] cls.floating_ip.append(body) cls.floating_ip_id.append(body['id']) @@ -45,7 +45,7 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest): @test.services('network') def test_list_floating_ips(self): # Positive test:Should return the list of floating IPs - body = self.client.list_floating_ips() + body = self.client.list_floating_ips()['floating_ips'] floating_ips = body self.assertNotEqual(0, len(floating_ips), "Expected floating IPs. Got zero.") @@ -57,14 +57,14 @@ class FloatingIPDetailsTestJSON(base.BaseV2ComputeTest): def test_get_floating_ip_details(self): # Positive test:Should be able to GET the details of floatingIP # Creating a floating IP for which details are to be checked - body = self.client.create_floating_ip() + body = self.client.create_floating_ip()['floating_ip'] floating_ip_id = body['id'] self.addCleanup(self.client.delete_floating_ip, floating_ip_id) floating_ip_instance_id = body['instance_id'] floating_ip_ip = body['ip'] floating_ip_fixed_ip = body['fixed_ip'] - body = self.client.show_floating_ip(floating_ip_id) + body = self.client.show_floating_ip(floating_ip_id)['floating_ip'] # Comparing the details of floating IP self.assertEqual(floating_ip_instance_id, body['instance_id']) diff --git a/tempest/api/compute/servers/test_server_rescue.py b/tempest/api/compute/servers/test_server_rescue.py index 7e090961e8..1ebf1170ce 100644 --- a/tempest/api/compute/servers/test_server_rescue.py +++ b/tempest/api/compute/servers/test_server_rescue.py @@ -41,7 +41,7 @@ class ServerRescueTestJSON(base.BaseV2ComputeTest): super(ServerRescueTestJSON, cls).resource_setup() # Floating IP creation - body = cls.floating_ips_client.create_floating_ip() + body = cls.floating_ips_client.create_floating_ip()['floating_ip'] cls.floating_ip_id = str(body['id']).strip() cls.floating_ip = str(body['ip']).strip() diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py index 2e96c81e87..5396a68c69 100644 --- a/tempest/cmd/cleanup_service.py +++ b/tempest/cmd/cleanup_service.py @@ -297,7 +297,7 @@ class FloatingIpService(BaseService): def list(self): client = self.client - floating_ips = client.list_floating_ips() + floating_ips = client.list_floating_ips()['floating_ips'] LOG.debug("List count, %s Floating IPs" % len(floating_ips)) return floating_ips diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py index aef42be542..0865eee30e 100755 --- a/tempest/cmd/javelin.py +++ b/tempest/cmd/javelin.py @@ -877,7 +877,7 @@ def create_servers(servers): if CONF.compute.use_floatingip_for_ssh: floating_ip_pool = server.get('floating_ip_pool') floating_ip = client.floating_ips.create_floating_ip( - pool_name=floating_ip_pool) + pool_name=floating_ip_pool)['floating_ip'] client.floating_ips.associate_floating_ip_to_server( floating_ip['ip'], server_id) diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py index 14730cf326..b8baebf6b2 100644 --- a/tempest/common/validation_resources.py +++ b/tempest/common/validation_resources.py @@ -59,8 +59,7 @@ def create_validation_resources(os, validation_resources=None): create_ssh_security_group(os, add_rule) if validation_resources['floating_ip']: floating_client = os.floating_ips_client - validation_data['floating_ip'] = \ - floating_client.create_floating_ip() + validation_data.update(floating_client.create_floating_ip()) return validation_data diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index e9530a27f4..4779435145 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -516,7 +516,8 @@ class ScenarioTest(tempest.test.BaseTestCase): Nova clients """ - floating_ip = self.floating_ips_client.create_floating_ip(pool_name) + floating_ip = (self.floating_ips_client.create_floating_ip(pool_name) + ['floating_ip']) self.addCleanup(self.delete_wrapper, self.floating_ips_client.delete_floating_ip, floating_ip['id']) diff --git a/tempest/scenario/test_baremetal_basic_ops.py b/tempest/scenario/test_baremetal_basic_ops.py index 346f56ba75..b63fccac7a 100644 --- a/tempest/scenario/test_baremetal_basic_ops.py +++ b/tempest/scenario/test_baremetal_basic_ops.py @@ -108,7 +108,8 @@ class BaremetalBasicOps(manager.BaremetalScenarioTest): return int(ephemeral) def add_floating_ip(self): - floating_ip = self.floating_ips_client.create_floating_ip() + floating_ip = (self.floating_ips_client.create_floating_ip() + ['floating_ip']) self.floating_ips_client.associate_floating_ip_to_server( floating_ip['ip'], self.instance['id']) return floating_ip['ip'] diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py index f61b151580..9f2c34ab8b 100644 --- a/tempest/scenario/test_server_basic_ops.py +++ b/tempest/scenario/test_server_basic_ops.py @@ -82,7 +82,8 @@ class TestServerBasicOps(manager.ScenarioTest): def verify_ssh(self): if self.run_ssh: # Obtain a floating IP - self.floating_ip = self.floating_ips_client.create_floating_ip() + self.floating_ip = (self.floating_ips_client.create_floating_ip() + ['floating_ip']) self.addCleanup(self.delete_wrapper, self.floating_ips_client.delete_floating_ip, self.floating_ip['id']) diff --git a/tempest/scenario/test_shelve_instance.py b/tempest/scenario/test_shelve_instance.py index 02ee7b9808..022306e40f 100644 --- a/tempest/scenario/test_shelve_instance.py +++ b/tempest/scenario/test_shelve_instance.py @@ -82,7 +82,8 @@ class TestShelveInstance(manager.ScenarioTest): create_kwargs=create_kwargs) if CONF.compute.use_floatingip_for_ssh: - floating_ip = self.floating_ips_client.create_floating_ip() + floating_ip = (self.floating_ips_client.create_floating_ip() + ['floating_ip']) self.addCleanup(self.delete_wrapper, self.floating_ips_client.delete_floating_ip, floating_ip['id']) diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py index 38098318a0..3135ee342f 100644 --- a/tempest/scenario/test_volume_boot_pattern.py +++ b/tempest/scenario/test_volume_boot_pattern.py @@ -98,7 +98,8 @@ class TestVolumeBootPattern(manager.ScenarioTest): def _ssh_to_server(self, server, keypair): if CONF.compute.use_floatingip_for_ssh: - floating_ip = self.floating_ips_client.create_floating_ip() + floating_ip = (self.floating_ips_client.create_floating_ip() + ['floating_ip']) self.addCleanup(self.delete_wrapper, self.floating_ips_client.delete_floating_ip, floating_ip['id']) diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py index 2193949774..69d06a39f4 100644 --- a/tempest/services/compute/json/floating_ips_client.py +++ b/tempest/services/compute/json/floating_ips_client.py @@ -32,7 +32,7 @@ class FloatingIPsClient(service_client.ServiceClient): resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.list_floating_ips, resp, body) - return service_client.ResponseBodyList(resp, body['floating_ips']) + return service_client.ResponseBody(resp, body) def show_floating_ip(self, floating_ip_id): """Get the details of a floating IP.""" @@ -40,7 +40,7 @@ class FloatingIPsClient(service_client.ServiceClient): resp, body = self.get(url) body = json.loads(body) self.validate_response(schema.create_get_floating_ip, resp, body) - return service_client.ResponseBody(resp, body['floating_ip']) + return service_client.ResponseBody(resp, body) def create_floating_ip(self, pool_name=None): """Allocate a floating IP to the project.""" @@ -50,7 +50,7 @@ class FloatingIPsClient(service_client.ServiceClient): resp, body = self.post(url, post_body) body = json.loads(body) self.validate_response(schema.create_get_floating_ip, resp, body) - return service_client.ResponseBody(resp, body['floating_ip']) + return service_client.ResponseBody(resp, body) def delete_floating_ip(self, floating_ip_id): """Deletes the provided floating IP from the project.""" diff --git a/tempest/stress/actions/ssh_floating.py b/tempest/stress/actions/ssh_floating.py index 09e6d88668..e01075fc76 100644 --- a/tempest/stress/actions/ssh_floating.py +++ b/tempest/stress/actions/ssh_floating.py @@ -107,7 +107,8 @@ class FloatingStress(stressaction.StressAction): def _create_floating_ip(self): floating_cli = self.manager.floating_ips_client - self.floating = floating_cli.create_floating_ip(self.floating_pool) + self.floating = (floating_cli.create_floating_ip(self.floating_pool) + ['floating_ip']) def _destroy_floating_ip(self): cli = self.manager.floating_ips_client @@ -147,7 +148,8 @@ class FloatingStress(stressaction.StressAction): cli = self.manager.floating_ips_client def func(): - floating = cli.show_floating_ip(self.floating['id']) + floating = (cli.show_floating_ip(self.floating['id']) + ['floating_ip']) return floating['instance_id'] is None if not tempest.test.call_until_true(func, self.check_timeout, diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py index e30ca0ce19..9815bd0977 100644 --- a/tempest/stress/actions/volume_attach_verify.py +++ b/tempest/stress/actions/volume_attach_verify.py @@ -69,7 +69,8 @@ class VolumeVerifyStress(stressaction.StressAction): def _create_floating_ip(self): floating_cli = self.manager.floating_ips_client - self.floating = floating_cli.create_floating_ip(self.floating_pool) + self.floating = (floating_cli.create_floating_ip(self.floating_pool) + ['floating_ip']) def _destroy_floating_ip(self): cli = self.manager.floating_ips_client @@ -98,7 +99,8 @@ class VolumeVerifyStress(stressaction.StressAction): cli = self.manager.floating_ips_client def func(): - floating = cli.show_floating_ip(self.floating['id']) + floating = (cli.show_floating_ip(self.floating['id']) + ['floating_ip']) return floating['instance_id'] is None if not tempest.test.call_until_true(func, CONF.compute.build_timeout, diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py index b785156d7c..2626a33733 100644 --- a/tempest/stress/cleanup.py +++ b/tempest/stress/cleanup.py @@ -56,7 +56,8 @@ def cleanup(): except Exception: pass - floating_ips = admin_manager.floating_ips_client.list_floating_ips() + floating_ips = (admin_manager.floating_ips_client.list_floating_ips() + ['floating_ips']) LOG.info("Cleanup::remove %s floating ips" % len(floating_ips)) for f in floating_ips: try: