Return complete response from floating_ips_bulk_client
Currently compute floating_ips_bulk_client returns Response by removing
top key from Response.
For example-
return service_client.ResponseBody(resp, body['floating_ips_bulk_create'])
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_bulk_client to return complete
Response body.
Change-Id: Ieabe7e207f9086cc7508eb52437b78ab083742cb
Implements: blueprint method-return-value-and-move-service-clients-to-lib
diff --git a/tempest/api/compute/admin/test_floating_ips_bulk.py b/tempest/api/compute/admin/test_floating_ips_bulk.py
index 4ac1915..c8ca938 100644
--- a/tempest/api/compute/admin/test_floating_ips_bulk.py
+++ b/tempest/api/compute/admin/test_floating_ips_bulk.py
@@ -45,7 +45,7 @@
@classmethod
def verify_unallocated_floating_ip_range(cls, ip_range):
# Verify whether configure floating IP range is not already allocated.
- body = cls.client.list_floating_ips_bulk()
+ body = cls.client.list_floating_ips_bulk()['floating_ip_info']
allocated_ips_list = map(lambda x: x['address'], body)
for ip_addr in netaddr.IPNetwork(ip_range).iter_hosts():
if str(ip_addr) in allocated_ips_list:
@@ -70,12 +70,13 @@
# anywhere. Using the below mentioned interface which is not ever
# expected to be used. Clean Up has been done for created IP range
interface = 'eth0'
- body = self.client.create_floating_ips_bulk(self.ip_range,
- pool,
- interface)
+ body = (self.client.create_floating_ips_bulk(self.ip_range,
+ pool,
+ interface)
+ ['floating_ips_bulk_create'])
self.addCleanup(self._delete_floating_ips_bulk, self.ip_range)
self.assertEqual(self.ip_range, body['ip_range'])
- ips_list = self.client.list_floating_ips_bulk()
+ ips_list = self.client.list_floating_ips_bulk()['floating_ip_info']
self.assertNotEqual(0, len(ips_list))
for ip in netaddr.IPNetwork(self.ip_range).iter_hosts():
self.assertIn(str(ip), map(lambda x: x['address'], ips_list))
diff --git a/tempest/services/compute/json/floating_ips_bulk_client.py b/tempest/services/compute/json/floating_ips_bulk_client.py
index 8b1c5a9..c51f77e 100644
--- a/tempest/services/compute/json/floating_ips_bulk_client.py
+++ b/tempest/services/compute/json/floating_ips_bulk_client.py
@@ -32,18 +32,17 @@
resp, body = self.post('os-floating-ips-bulk', post_body)
body = json.loads(body)
self.validate_response(schema.create_floating_ips_bulk, resp, body)
- return service_client.ResponseBody(resp,
- body['floating_ips_bulk_create'])
+ return service_client.ResponseBody(resp, body)
def list_floating_ips_bulk(self):
- """Returns a list of all floating IPs bulk."""
+ """Gets all floating IPs in bulk."""
resp, body = self.get('os-floating-ips-bulk')
body = json.loads(body)
self.validate_response(schema.list_floating_ips_bulk, resp, body)
- return service_client.ResponseBodyList(resp, body['floating_ip_info'])
+ return service_client.ResponseBody(resp, body)
def delete_floating_ips_bulk(self, ip_range):
- """Deletes the provided floating IPs bulk."""
+ """Deletes the provided floating IPs in bulk."""
post_body = json.dumps({'ip_range': ip_range})
resp, body = self.put('os-floating-ips-bulk/delete', post_body)
body = json.loads(body)