aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2017-06-26 17:44:47 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2017-06-26 22:46:21 +0200
commitd7fc6fb2603beb6fc4e8be498763459a33900e26 (patch)
treef61a0657b7899a756f3e185fb70987f469e93709
parent6efef3438c236ed0e522809c0c9acce5f0c81374 (diff)
Fix floating ips issue in openstack_clean
floatingips is a list of dictionaries where the attributes are a bit different than in the previous implementation. Change-Id: I8e8429b1819bba35a4a829f274c60b77ab2eea7e Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rw-r--r--functest/tests/unit/utils/test_openstack_clean.py13
-rwxr-xr-xfunctest/utils/openstack_clean.py4
2 files changed, 11 insertions, 6 deletions
diff --git a/functest/tests/unit/utils/test_openstack_clean.py b/functest/tests/unit/utils/test_openstack_clean.py
index 5feed167c..6ae7faa4a 100644
--- a/functest/tests/unit/utils/test_openstack_clean.py
+++ b/functest/tests/unit/utils/test_openstack_clean.py
@@ -61,6 +61,8 @@ class OSCleanTesting(unittest.TestCase):
{'id': 'id2', 'name': 'name2', 'ip': 'ip2',
'router:external': False,
'external_gateway_info': None}]
+ self.floatingips_list = [{'id': 'id1', 'floating_ip_address': 'ip1'},
+ {'id': 'id2', 'floating_ip_address': 'ip2'}]
self.routers = [mock.Mock()]
self.ports = [mock.Mock()]
@@ -254,7 +256,8 @@ class OSCleanTesting(unittest.TestCase):
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_floatingips(self, mock_logger_debug):
with mock.patch('functest.utils.openstack_clean.os_utils'
- '.get_floating_ips', return_value=self.test_list):
+ '.get_floating_ips',
+ return_value=self.floatingips_list):
openstack_clean.remove_floatingips(self.client, self.update_list)
mock_logger_debug.assert_any_call("Removing floating IPs...")
mock_logger_debug.assert_any_call(" > this is a default "
@@ -272,9 +275,10 @@ class OSCleanTesting(unittest.TestCase):
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_remove_floatingips_delete_success(self, mock_logger_debug):
with mock.patch('functest.utils.openstack_clean.os_utils'
- '.get_floating_ips', return_value=self.test_list), \
+ '.get_floating_ips',
+ return_value=self.floatingips_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
- '.delete_volume', return_value=True):
+ '.delete_floating_ip', return_value=True):
openstack_clean.remove_floatingips(self.client, self.remove_list)
mock_logger_debug.assert_any_call("Removing floating IPs...")
mock_logger_debug.assert_any_call(" > Done!")
@@ -287,7 +291,8 @@ class OSCleanTesting(unittest.TestCase):
def test_remove_floatingips_delete_failed(self, mock_logger_debug,
mock_logger_error):
with mock.patch('functest.utils.openstack_clean.os_utils'
- '.get_floating_ips', return_value=self.test_list), \
+ '.get_floating_ips',
+ return_value=self.floatingips_list), \
mock.patch('functest.utils.openstack_clean.os_utils'
'.delete_floating_ip', return_value=False):
openstack_clean.remove_floatingips(self.client, self.remove_list)
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index b51678936..e88245d61 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -148,8 +148,8 @@ def remove_floatingips(neutron_client, default_floatingips):
init_len = len(floatingips)
deleted = 0
for fip in floatingips:
- fip_id = getattr(fip, 'id')
- fip_ip = getattr(fip, 'ip')
+ fip_id = fip['id']
+ fip_ip = fip['floating_ip_address']
logger.debug("'%s', ID=%s " % (fip_ip, fip_id))
if (fip_id not in default_floatingips and
fip_ip not in default_floatingips.values()):