Change fixed/floating ip clients to return one value and update tests
Add ResponseBodyData for cases like delete_floating_ips_bulk where a
string is returned as the body. The client has to dereference the data
but I think this is a bit cleaner than having some methods return two values.
Partially implements: blueprint clients-return-one-value
Change-Id: I87b092b2dd2a231049fc39312038f2a2d5101028
diff --git a/tempest/services/compute/json/floating_ips_client.py b/tempest/services/compute/json/floating_ips_client.py
index 9c586e3..441f185 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -32,7 +32,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.list_floating_ips, resp, body)
- return resp, body['floating_ips']
+ return service_client.ResponseBodyList(resp, body['floating_ips'])
def get_floating_ip_details(self, floating_ip_id):
"""Get the details of a floating IP."""
@@ -42,7 +42,7 @@
if resp.status == 404:
raise exceptions.NotFound(body)
self.validate_response(schema.floating_ip, resp, body)
- return resp, body['floating_ip']
+ return service_client.ResponseBody(resp, body['floating_ip'])
def create_floating_ip(self, pool_name=None):
"""Allocate a floating IP to the project."""
@@ -52,14 +52,14 @@
resp, body = self.post(url, post_body)
body = json.loads(body)
self.validate_response(schema.floating_ip, resp, body)
- return resp, body['floating_ip']
+ return service_client.ResponseBody(resp, body['floating_ip'])
def delete_floating_ip(self, floating_ip_id):
"""Deletes the provided floating IP from the project."""
url = "os-floating-ips/%s" % str(floating_ip_id)
resp, body = self.delete(url)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def associate_floating_ip_to_server(self, floating_ip, server_id):
"""Associate the provided floating IP to a specific server."""
@@ -73,7 +73,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def disassociate_floating_ip_from_server(self, floating_ip, server_id):
"""Disassociate the provided floating IP from a specific server."""
@@ -87,7 +87,7 @@
post_body = json.dumps(post_body)
resp, body = self.post(url, post_body)
self.validate_response(schema.add_remove_floating_ip, resp, body)
- return resp, body
+ return service_client.ResponseBody(resp, body)
def is_resource_deleted(self, id):
try:
@@ -110,7 +110,7 @@
resp, body = self.get(url)
body = json.loads(body)
self.validate_response(schema.floating_ip_pools, resp, body)
- return resp, body['floating_ip_pools']
+ return service_client.ResponseBodyList(resp, body['floating_ip_pools'])
def create_floating_ips_bulk(self, ip_range, pool, interface):
"""Allocate floating IPs in bulk."""
@@ -123,14 +123,15 @@
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 resp, body['floating_ips_bulk_create']
+ return service_client.ResponseBody(resp,
+ body['floating_ips_bulk_create'])
def list_floating_ips_bulk(self):
"""Returns a list of all floating IPs bulk."""
resp, body = self.get('os-floating-ips-bulk')
body = json.loads(body)
self.validate_response(schema.list_floating_ips_bulk, resp, body)
- return resp, body['floating_ip_info']
+ return service_client.ResponseBodyList(resp, body['floating_ip_info'])
def delete_floating_ips_bulk(self, ip_range):
"""Deletes the provided floating IPs bulk."""
@@ -138,4 +139,5 @@
resp, body = self.put('os-floating-ips-bulk/delete', post_body)
body = json.loads(body)
self.validate_response(schema.delete_floating_ips_bulk, resp, body)
- return resp, body['floating_ips_bulk_delete']
+ data = body['floating_ips_bulk_delete']
+ return service_client.ResponseBodyData(resp, data)