Merge "Return complete response from floating_ips_client"

This commit is contained in:
Jenkins
2015-08-25 05:57:46 +00:00
committed by Gerrit Code Review
16 changed files with 40 additions and 30 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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'])

View File

@@ -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()

View File

@@ -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

View File

@@ -878,7 +878,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)

View File

@@ -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

View File

@@ -521,7 +521,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'])

View File

@@ -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']

View File

@@ -83,7 +83,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'])

View File

@@ -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'])

View File

@@ -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'])

View File

@@ -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."""

View File

@@ -108,7 +108,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
@@ -148,7 +149,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,

View File

@@ -71,7 +71,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
@@ -100,7 +101,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,

View File

@@ -58,7 +58,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: