aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
Diffstat (limited to 'functest')
-rw-r--r--functest/ci/config_functest.yaml6
-rwxr-xr-xfunctest/ci/prepare_env.py2
-rw-r--r--functest/core/feature.py18
-rwxr-xr-xfunctest/opnfv_tests/openstack/vping/vping_userdata.py2
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py8
-rw-r--r--functest/tests/unit/core/test_feature.py23
-rw-r--r--functest/tests/unit/utils/test_openstack_clean.py16
-rw-r--r--functest/tests/unit/utils/test_openstack_snapshot.py16
-rw-r--r--functest/tests/unit/utils/test_openstack_utils.py24
-rwxr-xr-xfunctest/utils/openstack_clean.py32
-rwxr-xr-xfunctest/utils/openstack_snapshot.py22
-rw-r--r--functest/utils/openstack_utils.py37
12 files changed, 127 insertions, 79 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 60270b6c..623092a5 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -62,9 +62,9 @@ general:
snaps:
use_keystone: True
use_floating_ips: True
-# images:
-# cirros:
-# disk_url: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
+ images:
+ cirros:
+ disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
# ARM
# disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
# kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 5326c50b..64fcc925 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -366,7 +366,6 @@ def main(**kwargs):
elif kwargs['action'] == "start":
logger.info("######### Preparing Functest environment #########\n")
check_env_variables()
- get_deployment_handler()
create_directories()
source_rc_file()
update_config_file()
@@ -377,7 +376,6 @@ def main(**kwargs):
with open(CONST.__getattribute__('env_active'), "w") as env_file:
env_file.write("1")
check_environment()
- print_deployment_info()
elif kwargs['action'] == "check":
check_environment()
except Exception as e:
diff --git a/functest/core/feature.py b/functest/core/feature.py
index d53eb7d0..010ff4bc 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -33,6 +33,24 @@ class Feature(base.TestCase):
super(Feature, self).__init__(**kwargs)
self.result_file = "{}/{}.log".format(
CONST.__getattribute__('dir_results'), self.case_name)
+ try:
+ module = kwargs['run']['module']
+ self.logger = logging.getLogger(module)
+ except KeyError:
+ self.__logger.warning(
+ "Cannot get module name %s. Using %s as fallback",
+ kwargs, self.case_name)
+ self.logger = logging.getLogger(self.case_name)
+ handler = logging.StreamHandler()
+ handler.setLevel(logging.WARN)
+ self.logger.addHandler(handler)
+ handler = logging.FileHandler(self.result_file)
+ handler.setLevel(logging.DEBUG)
+ self.logger.addHandler(handler)
+ formatter = logging.Formatter(
+ '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+ handler.setFormatter(formatter)
+ self.logger.addHandler(handler)
def execute(self, **kwargs):
"""Execute the Python method.
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index b69b3955..718f47f0 100755
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -97,7 +97,7 @@ class VPingUserdata(vping_base.VPingBase):
while True:
time.sleep(1)
- p_console = vm_creator.get_vm_inst().get_console_output()
+ p_console = vm_creator.get_os_vm_server_obj().get_console_output()
if "vPing OK" in p_console:
self.logger.info("vPing detected!")
exit_code = TestCase.EX_OK
diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py
index f3e15a01..69abd643 100644
--- a/functest/tests/unit/ci/test_prepare_env.py
+++ b/functest/tests/unit/ci/test_prepare_env.py
@@ -424,7 +424,6 @@ class PrepareEnvTesting(unittest.TestCase):
mock_logger_info.assert_any_call("Functest environment"
" is installed.")
- @mock.patch('functest.ci.prepare_env.print_deployment_info')
@mock.patch('functest.ci.prepare_env.check_environment')
@mock.patch('functest.ci.prepare_env.create_flavor')
@mock.patch('functest.ci.prepare_env.install_tempest')
@@ -433,21 +432,19 @@ class PrepareEnvTesting(unittest.TestCase):
@mock.patch('functest.ci.prepare_env.update_config_file')
@mock.patch('functest.ci.prepare_env.source_rc_file')
@mock.patch('functest.ci.prepare_env.create_directories')
- @mock.patch('functest.ci.prepare_env.get_deployment_handler')
@mock.patch('functest.ci.prepare_env.check_env_variables')
@mock.patch('functest.ci.prepare_env.logger.info')
- def test_main_start(self, mock_logger_info, mock_env_var, mock_dep_handler,
+ def test_main_start(self, mock_logger_info, mock_env_var,
mock_create_dir, mock_source_rc, mock_update_config,
mock_verify_depl, mock_install_rally,
mock_install_temp, mock_create_flavor,
- mock_check_env, mock_print_info):
+ mock_check_env):
with mock.patch("__builtin__.open", mock.mock_open()) as m:
args = {'action': 'start'}
self.assertEqual(prepare_env.main(**args), 0)
mock_logger_info.assert_any_call("######### Preparing Functest "
"environment #########\n")
self.assertTrue(mock_env_var.called)
- self.assertTrue(mock_dep_handler.called)
self.assertTrue(mock_create_dir.called)
self.assertTrue(mock_source_rc.called)
self.assertTrue(mock_update_config.called)
@@ -458,7 +455,6 @@ class PrepareEnvTesting(unittest.TestCase):
m.assert_called_once_with(
CONST.__getattribute__('env_active'), "w")
self.assertTrue(mock_check_env.called)
- self.assertTrue(mock_print_info.called)
@mock.patch('functest.ci.prepare_env.check_environment')
def test_main_check(self, mock_check_env):
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 0160c8e1..988981ef 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -38,12 +38,26 @@ class FeatureTestingBase(unittest.TestCase):
self.assertEqual(self.feature.start_time, 1)
self.assertEqual(self.feature.stop_time, 2)
+ def test_logger_module_ko(self):
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name)
+ self.assertEqual(self.feature.logger.name, self._case_name)
+
+ def test_logger_module(self):
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name,
+ run={'module': 'bar'})
+ self.assertEqual(self.feature.logger.name, 'bar')
+
class FeatureTesting(FeatureTestingBase):
def setUp(self):
- self.feature = feature.Feature(
- project_name=self._project_name, case_name=self._case_name)
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name)
def test_run_exc(self):
# pylint: disable=bad-continuation
@@ -60,8 +74,9 @@ class FeatureTesting(FeatureTestingBase):
class BashFeatureTesting(FeatureTestingBase):
def setUp(self):
- self.feature = feature.BashFeature(
- project_name=self._project_name, case_name=self._case_name)
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.BashFeature(
+ project_name=self._project_name, case_name=self._case_name)
@mock.patch("functest.utils.functest_utils.execute_command")
def test_run_no_cmd(self, mock_method=None):
diff --git a/functest/tests/unit/utils/test_openstack_clean.py b/functest/tests/unit/utils/test_openstack_clean.py
index fe7b50d4..6ae7faa4 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)
@@ -672,6 +677,7 @@ class OSCleanTesting(unittest.TestCase):
RegexMatch(" Removing "
"\s*\S+..."))
+ @mock.patch('functest.utils.openstack_clean.os_utils.get_glance_client')
@mock.patch('functest.utils.openstack_clean.os_utils.get_cinder_client')
@mock.patch('functest.utils.openstack_clean.os_utils'
'.get_keystone_client')
@@ -684,7 +690,7 @@ class OSCleanTesting(unittest.TestCase):
@mock.patch('functest.utils.openstack_clean.logger.debug')
def test_main_default(self, mock_logger_debug, mock_logger_info,
mock_creds, mock_nova, mock_neutron,
- mock_keystone, mock_cinder):
+ mock_keystone, mock_cinder, mock_glance):
with mock.patch('functest.utils.openstack_clean.remove_instances') \
as mock_remove_instances, \
diff --git a/functest/tests/unit/utils/test_openstack_snapshot.py b/functest/tests/unit/utils/test_openstack_snapshot.py
index d3f93994..33e74609 100644
--- a/functest/tests/unit/utils/test_openstack_snapshot.py
+++ b/functest/tests/unit/utils/test_openstack_snapshot.py
@@ -12,7 +12,7 @@ import unittest
from functest.utils import openstack_snapshot
-class OSTackerTesting(unittest.TestCase):
+class OSSnapshotTesting(unittest.TestCase):
def _get_instance(self, key):
mock_obj = mock.Mock()
@@ -26,6 +26,8 @@ class OSTackerTesting(unittest.TestCase):
self.test_list = [self._get_instance(1), self._get_instance(2)]
self.update_list = {'id1': 'name1', 'id2': 'name2'}
self.update_floatingips = {'id1': 'ip1', 'id2': 'ip2'}
+ self.floatingips_list = [{'id': 'id1', 'floating_ip_address': 'ip1'},
+ {'id': 'id2', 'floating_ip_address': 'ip2'}]
self.test_dict_list = [{'id': 'id1', 'name': 'name1', 'ip': 'ip1'},
{'id': 'id2', 'name': 'name2', 'ip': 'ip2'}]
@@ -138,8 +140,9 @@ class OSTackerTesting(unittest.TestCase):
@mock.patch('functest.utils.openstack_snapshot.logger.debug')
def test_get_floatingips(self, mock_logger_debug):
with mock.patch('functest.utils.openstack_snapshot.os_utils'
- '.get_floating_ips', return_value=self.test_list):
- resp = openstack_snapshot.get_floatinips(self.client)
+ '.get_floating_ips',
+ return_value=self.floatingips_list):
+ resp = openstack_snapshot.get_floatingips(self.client)
mock_logger_debug.assert_called_once_with("Getting Floating "
"IPs...")
self.assertDictEqual(resp, {'floatingips':
@@ -149,7 +152,7 @@ class OSTackerTesting(unittest.TestCase):
def test_get_floatingips_missing_floatingips(self, mock_logger_debug):
with mock.patch('functest.utils.openstack_snapshot.os_utils'
'.get_floating_ips', return_value=[]):
- resp = openstack_snapshot.get_floatinips(self.client)
+ resp = openstack_snapshot.get_floatingips(self.client)
mock_logger_debug.assert_called_once_with("Getting Floating "
"IPs...")
self.assertDictEqual(resp, {'floatingips': {}})
@@ -186,6 +189,7 @@ class OSTackerTesting(unittest.TestCase):
mock_logger_debug.assert_called_once_with("Getting tenants...")
self.assertDictEqual(resp, {'tenants': {}})
+ @mock.patch('functest.utils.openstack_clean.os_utils.get_glance_client')
@mock.patch('functest.utils.openstack_snapshot.os_utils.get_cinder_client')
@mock.patch('functest.utils.openstack_snapshot.os_utils'
'.get_keystone_client')
@@ -197,7 +201,7 @@ class OSTackerTesting(unittest.TestCase):
@mock.patch('functest.utils.openstack_snapshot.logger.debug')
def test_main_default(self, mock_logger_debug, mock_logger_info,
mock_creds, mock_nova, mock_neutron,
- mock_keystone, mock_cinder):
+ mock_keystone, mock_cinder, mock_glance):
with mock.patch('functest.utils.openstack_snapshot.get_instances',
return_value=self.update_list), \
mock.patch('functest.utils.openstack_snapshot.get_images',
@@ -212,7 +216,7 @@ class OSTackerTesting(unittest.TestCase):
return_value=self.update_list), \
mock.patch('functest.utils.openstack_snapshot.get_security_groups',
return_value=self.update_list), \
- mock.patch('functest.utils.openstack_snapshot.get_floatinips',
+ mock.patch('functest.utils.openstack_snapshot.get_floatingips',
return_value=self.update_floatingips), \
mock.patch('functest.utils.openstack_snapshot.get_users',
return_value=self.update_list), \
diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py
index 0f06b1e1..74b49aaa 100644
--- a/functest/tests/unit/utils/test_openstack_utils.py
+++ b/functest/tests/unit/utils/test_openstack_utils.py
@@ -27,7 +27,8 @@ class OSUtilsTesting(unittest.TestCase):
'OS_PROJECT_NAME': os_prefix + 'project_name',
'OS_ENDPOINT_TYPE': os_prefix + 'endpoint_type',
'OS_REGION_NAME': os_prefix + 'region_name',
- 'OS_CACERT': os_prefix + 'https_cacert'}
+ 'OS_CACERT': os_prefix + 'https_cacert',
+ 'OS_INSECURE': os_prefix + 'https_insecure'}
def _get_os_env_vars(self):
return {'username': 'test_username', 'password': 'test_password',
@@ -37,7 +38,8 @@ class OSUtilsTesting(unittest.TestCase):
'project_name': 'test_project_name',
'endpoint_type': 'test_endpoint_type',
'region_name': 'test_region_name',
- 'https_cacert': 'test_https_cacert'}
+ 'https_cacert': 'test_https_cacert',
+ 'https_insecure': 'test_https_insecure'}
def setUp(self):
self.env_vars = ['OS_AUTH_URL', 'OS_USERNAME', 'OS_PASSWORD']
@@ -75,9 +77,8 @@ class OSUtilsTesting(unittest.TestCase):
self.availability_zone = mock_obj
mock_obj = mock.Mock()
- attrs = {'id': 'floating_id',
- 'zoneName': 'test_floating_ip',
- 'status': 'ok'}
+ attrs = {'floating_network_id': 'floating_id',
+ 'floating_ip_address': 'test_floating_ip'}
mock_obj.configure_mock(**attrs)
self.floating_ip = mock_obj
@@ -113,8 +114,6 @@ class OSUtilsTesting(unittest.TestCase):
'aggregates.delete.return_value': mock.Mock(),
'availability_zones.list.return_value':
[self.availability_zone],
- 'floating_ips.list.return_value': [self.floating_ip],
- 'floating_ips.delete.return_value': mock.Mock(),
'hypervisors.list.return_value': [self.hypervisor],
'create.return_value': mock.Mock(),
'add_security_group.return_value': mock.Mock(),
@@ -271,7 +270,10 @@ class OSUtilsTesting(unittest.TestCase):
'create_security_group.return_value': {'security_group':
self.sec_group},
'update_quota.return_value': mock.Mock(),
- 'delete_security_group.return_value': mock.Mock()
+ 'delete_security_group.return_value': mock.Mock(),
+ 'list_floatingips.return_value': {'floatingips':
+ [self.floating_ip]},
+ 'delete_floatingip.return_value': mock.Mock(),
}
self.neutron_client.configure_mock(**attrs)
@@ -721,7 +723,7 @@ class OSUtilsTesting(unittest.TestCase):
def test_get_floating_ips_default(self):
self.assertEqual(openstack_utils.
- get_floating_ips(self.nova_client),
+ get_floating_ips(self.neutron_client),
[self.floating_ip])
@mock.patch('functest.utils.openstack_utils.logger.error')
@@ -867,7 +869,7 @@ class OSUtilsTesting(unittest.TestCase):
def test_delete_floating_ip_default(self):
self.assertTrue(openstack_utils.
- delete_floating_ip(self.nova_client,
+ delete_floating_ip(self.neutron_client,
'floating_ip_id'))
@mock.patch('functest.utils.openstack_utils.logger.error')
@@ -1472,7 +1474,7 @@ class OSUtilsTesting(unittest.TestCase):
def test_get_images_default(self):
self.assertEqual(openstack_utils.
- get_images(self.nova_client),
+ get_images(self.glance_client),
[self.image])
@mock.patch('functest.utils.openstack_utils.logger.error')
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index 0ce08798..e88245d6 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -80,22 +80,25 @@ def remove_instances(nova_client, default_instances):
break
-def remove_images(nova_client, default_images):
+def remove_images(glance_client, default_images):
logger.debug("Removing Glance images...")
- images = os_utils.get_images(nova_client)
- if images is None or len(images) == 0:
+ images = os_utils.get_images(glance_client)
+ if images is None:
+ return -1
+ images = {image.id: image.name for image in images}
+ if len(images) == 0:
logger.debug("No images found.")
return
for image in images:
- image_name = getattr(image, 'name')
- image_id = getattr(image, 'id')
+ image_id = image
+ image_name = images.get(image_id)
logger.debug("'%s', ID=%s " % (image_name, image_id))
if (image_id not in default_images and
image_name not in default_images.values()):
logger.debug("Removing image '%s', ID=%s ..."
% (image_name, image_id))
- if os_utils.delete_glance_image(nova_client, image_id):
+ if os_utils.delete_glance_image(glance_client, image_id):
logger.debug(" > Done!")
else:
logger.error("There has been a problem removing the"
@@ -135,9 +138,9 @@ def remove_volumes(cinder_client, default_volumes):
"NOT be deleted.")
-def remove_floatingips(nova_client, default_floatingips):
+def remove_floatingips(neutron_client, default_floatingips):
logger.debug("Removing floating IPs...")
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if floatingips is None or len(floatingips) == 0:
logger.debug("No floating IPs found.")
return
@@ -145,13 +148,13 @@ def remove_floatingips(nova_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()):
logger.debug("Removing floating IP %s ..." % fip_id)
- if os_utils.delete_floating_ip(nova_client, fip_id):
+ if os_utils.delete_floating_ip(neutron_client, fip_id):
logger.debug(" > Done!")
deleted += 1
else:
@@ -163,7 +166,7 @@ def remove_floatingips(nova_client, default_floatingips):
timeout = 50
while timeout > 0:
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
@@ -385,6 +388,7 @@ def main():
neutron_client = os_utils.get_neutron_client()
keystone_client = os_utils.get_keystone_client()
cinder_client = os_utils.get_cinder_client()
+ glance_client = os_utils.get_glance_client()
try:
with open(OS_SNAPSHOT_FILE) as f:
@@ -411,11 +415,11 @@ def main():
remove_instances(nova_client, default_instances)
separator()
- remove_images(nova_client, default_images)
+ remove_images(glance_client, default_images)
separator()
remove_volumes(cinder_client, default_volumes)
separator()
- remove_floatingips(nova_client, default_floatingips)
+ remove_floatingips(neutron_client, default_floatingips)
separator()
remove_networks(neutron_client, default_networks, default_routers)
separator()
diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py
index 233c316a..f4ef751c 100755
--- a/functest/utils/openstack_snapshot.py
+++ b/functest/utils/openstack_snapshot.py
@@ -48,13 +48,13 @@ def get_instances(nova_client):
return {'instances': dic_instances}
-def get_images(nova_client):
+def get_images(glance_client):
logger.debug("Getting images...")
dic_images = {}
- images = os_utils.get_images(nova_client)
- if not (images is None or len(images) == 0):
- for image in images:
- dic_images.update({getattr(image, 'id'): getattr(image, 'name')})
+ images = os_utils.get_images(glance_client)
+ if images is None:
+ return -1
+ dic_images.update({image.id: image.name for image in images})
return {'images': dic_images}
@@ -98,13 +98,14 @@ def get_security_groups(neutron_client):
return {'secgroups': dic_secgroups}
-def get_floatinips(nova_client):
+def get_floatingips(neutron_client):
logger.debug("Getting Floating IPs...")
dic_floatingips = {}
- floatingips = os_utils.get_floating_ips(nova_client)
+ floatingips = os_utils.get_floating_ips(neutron_client)
if not (floatingips is None or len(floatingips) == 0):
for floatingip in floatingips:
- dic_floatingips.update({floatingip.id: floatingip.ip})
+ dic_floatingips.update({floatingip['id']:
+ floatingip['floating_ip_address']})
return {'floatingips': dic_floatingips}
@@ -136,6 +137,7 @@ def main():
neutron_client = os_utils.get_neutron_client()
keystone_client = os_utils.get_keystone_client()
cinder_client = os_utils.get_cinder_client()
+ glance_client = os_utils.get_glance_client()
if not os_utils.check_credentials():
logger.error("Please source the openrc credentials and run the" +
@@ -144,12 +146,12 @@ def main():
snapshot = {}
snapshot.update(get_instances(nova_client))
- snapshot.update(get_images(nova_client))
+ snapshot.update(get_images(glance_client))
snapshot.update(get_volumes(cinder_client))
snapshot.update(get_networks(neutron_client))
snapshot.update(get_routers(neutron_client))
snapshot.update(get_security_groups(neutron_client))
- snapshot.update(get_floatinips(nova_client))
+ snapshot.update(get_floatingips(neutron_client))
snapshot.update(get_users(keystone_client))
snapshot.update(get_tenants(keystone_client))
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index a8966264..e7cdfc86 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -82,7 +82,8 @@ def get_env_cred_dict():
'OS_PROJECT_NAME': 'project_name',
'OS_ENDPOINT_TYPE': 'endpoint_type',
'OS_REGION_NAME': 'region_name',
- 'OS_CACERT': 'https_cacert'
+ 'OS_CACERT': 'https_cacert',
+ 'OS_INSECURE': 'https_insecure'
}
return env_cred_dict
@@ -150,10 +151,12 @@ def get_credentials_for_rally():
cred_key = env_cred_dict.get('OS_REGION_NAME')
rally_conf[cred_key] = region_name
- cacert = os.getenv('OS_CACERT')
- if cacert is not None:
- cred_key = env_cred_dict.get('OS_CACERT')
- rally_conf[cred_key] = cacert
+ cred_key = env_cred_dict.get('OS_CACERT')
+ rally_conf[cred_key] = os.getenv('OS_CACERT', '')
+
+ insecure_key = env_cred_dict.get('OS_INSECURE')
+ rally_conf[insecure_key] = os.getenv('OS_INSECURE', '').lower() == 'true'
+
return rally_conf
@@ -422,12 +425,12 @@ def get_or_create_flavor(flavor_name, ram, disk, vcpus, public=True):
return flavor_exists, flavor_id
-def get_floating_ips(nova_client):
+def get_floating_ips(neutron_client):
try:
- floating_ips = nova_client.floating_ips.list()
- return floating_ips
+ floating_ips = neutron_client.list_floatingips()
+ return floating_ips['floatingips']
except Exception as e:
- logger.error("Error [get_floating_ips(nova_client)]: %s" % e)
+ logger.error("Error [get_floating_ips(neutron_client)]: %s" % e)
return None
@@ -590,12 +593,12 @@ def delete_instance(nova_client, instance_id):
return False
-def delete_floating_ip(nova_client, floatingip_id):
+def delete_floating_ip(neutron_client, floatingip_id):
try:
- nova_client.floating_ips.delete(floatingip_id)
+ neutron_client.delete_floatingip(floatingip_id)
return True
except Exception as e:
- logger.error("Error [delete_floating_ip(nova_client, '%s')]: %s"
+ logger.error("Error [delete_floating_ip(neutron_client, '%s')]: %s"
% (floatingip_id, e))
return False
@@ -1188,9 +1191,9 @@ def delete_security_group(neutron_client, secgroup_id):
# *********************************************
# GLANCE
# *********************************************
-def get_images(nova_client):
+def get_images(glance_client):
try:
- images = nova_client.images.list()
+ images = glance_client.images.list()
return images
except Exception as e:
logger.error("Error [get_images]: %s" % e)
@@ -1254,12 +1257,12 @@ def get_or_create_image(name, path, format):
return image_exists, image_id
-def delete_glance_image(nova_client, image_id):
+def delete_glance_image(glance_client, image_id):
try:
- nova_client.images.delete(image_id)
+ glance_client.images.delete(image_id)
return True
except Exception as e:
- logger.error("Error [delete_glance_image(nova_client, '%s')]: %s"
+ logger.error("Error [delete_glance_image(glance_client, '%s')]: %s"
% (image_id, e))
return False