Make create_floating_ip use **kwargs
As we discussed on
http://lists.openstack.org/pipermail/openstack-dev/2015-July/068864.html
All http POST/PUT methods need to contain **kwargs as their arguments.
This patch makes create_floating_ip use **kwargs.
NOTE: "create floating ip" Nova API does the same behavior if passing
{"pool": None} or {} on its request body. This changes the default
value from {"pool": None} to {}, and it changes some floating-ip
tests. However this is necessary because tempest-lib needs to
provide flexibility as the library.
Partially implements blueprint consistent-service-method-names
Change-Id: Ib7886438228f31142dd23d9ca3205e7d2b434c92
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 64aac80..0223c0d 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
@@ -60,7 +60,7 @@
# to a project should fail
self.assertRaises(lib_exc.NotFound,
self.client.create_floating_ip,
- "non_exist_pool")
+ pool="non_exist_pool")
@test.attr(type=['negative'])
@test.idempotent_id('ae1c55a8-552b-44d4-bfb6-2a115a15d0ba')
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 64f9e31..24877f4 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -616,7 +616,7 @@
"""Create a floating IP and associates to a server on Nova"""
floating_ip = (self.compute_floating_ips_client.
- create_floating_ip(pool_name)['floating_ip'])
+ create_floating_ip(pool=pool_name)['floating_ip'])
self.addCleanup(self.delete_wrapper,
self.compute_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 69d06a3..b3e2f2f 100644
--- a/tempest/services/compute/json/floating_ips_client.py
+++ b/tempest/services/compute/json/floating_ips_client.py
@@ -42,11 +42,14 @@
self.validate_response(schema.create_get_floating_ip, resp, body)
return service_client.ResponseBody(resp, body)
- def create_floating_ip(self, pool_name=None):
- """Allocate a floating IP to the project."""
+ def create_floating_ip(self, **kwargs):
+ """Allocate a floating IP to the project.
+
+ Available params: see http://developer.openstack.org/
+ api-ref-compute-v2.1.html#createFloatingIP
+ """
url = 'os-floating-ips'
- post_body = {'pool': pool_name}
- post_body = json.dumps(post_body)
+ post_body = json.dumps(kwargs)
resp, body = self.post(url, post_body)
body = json.loads(body)
self.validate_response(schema.create_get_floating_ip, resp, body)