aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
Diffstat (limited to 'functest/utils')
-rw-r--r--functest/utils/env.py2
-rwxr-xr-xfunctest/utils/functest_logger.py4
-rw-r--r--functest/utils/functest_utils.py9
-rw-r--r--functest/utils/openstack_tacker.py42
4 files changed, 41 insertions, 16 deletions
diff --git a/functest/utils/env.py b/functest/utils/env.py
index fa5245fb..7e4df2ea 100644
--- a/functest/utils/env.py
+++ b/functest/utils/env.py
@@ -3,7 +3,7 @@ import re
default_envs = {
'NODE_NAME': 'unknown_pod',
- 'CI_DEBUG': 'true',
+ 'CI_DEBUG': 'false',
'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha',
'DEPLOY_TYPE': 'virt',
'INSTALLER_TYPE': None,
diff --git a/functest/utils/functest_logger.py b/functest/utils/functest_logger.py
index 0cba8c52..022211cb 100755
--- a/functest/utils/functest_logger.py
+++ b/functest/utils/functest_logger.py
@@ -29,10 +29,12 @@ import json
from functest.utils.constants import CONST
-class Logger:
+class Logger(object):
+
def __init__(self, logger_name):
self.setup_logging()
self.logger = logging.getLogger(logger_name)
+ logging.getLogger("paramiko").setLevel(logging.WARNING)
def getLogger(self):
return self.logger
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index b2c36cff..dbed811a 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -291,6 +291,13 @@ def get_ci_envvars():
return ci_env_var
+def execute_command_raise(cmd, info=False, error_msg="",
+ verbose=True, output_file=None):
+ ret = execute_command(cmd, info, error_msg, verbose, output_file)
+ if ret != 0:
+ raise Exception(error_msg)
+
+
def execute_command(cmd, info=False, error_msg="",
verbose=True, output_file=None):
if not error_msg:
@@ -362,7 +369,7 @@ def get_parameter_from_yaml(parameter, file):
value = value.get(element)
if value is None:
raise ValueError("The parameter %s is not defined in"
- " config_functest.yaml" % parameter)
+ " %s" % (parameter, file))
return value
diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py
index 1c02e040..8327fdbe 100644
--- a/functest/utils/openstack_tacker.py
+++ b/functest/utils/openstack_tacker.py
@@ -48,9 +48,8 @@ def get_vnfd_id(tacker_client, vnfd_name):
def get_vnf_id(tacker_client, vnf_name, timeout=5):
vnf_id = None
while vnf_id is None and timeout >= 0:
- try:
- vnf_id = get_id_from_name(tacker_client, 'vnf', vnf_name)
- except:
+ vnf_id = get_id_from_name(tacker_client, 'vnf', vnf_name)
+ if vnf_id is None:
logger.info("Could not retrieve ID for vnf with name [%s]."
" Retrying." % vnf_name)
time.sleep(1)
@@ -145,27 +144,44 @@ def create_vnf(tacker_client, vnf_name, vnfd_id=None,
return None
-def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None, timeout=60):
+def get_vnf(tacker_client, vnf_id=None, vnf_name=None):
try:
if vnf_id is None and vnf_name is None:
raise Exception('You must specify vnf_id or vnf_name')
+
_id = get_vnf_id(tacker_client, vnf_name) if vnf_id is None else vnf_id
- vnf = next((v for v in list_vnfs(tacker_client, verbose=True)['vnfs']
- if v['id'] == _id), None)
+ if _id is not None:
+ all_vnfs = list_vnfs(tacker_client, verbose=True)['vnfs']
+ return next((vnf for vnf in all_vnfs if vnf['id'] == _id), None)
+ else:
+ raise Exception('Could not retrieve ID from name [%s]' % vnf_name)
+
+ except Exception, e:
+ logger.error("Could not retrieve VNF [vnf_id=%s, vnf_name=%s] - %s"
+ % (vnf_id, vnf_name, e))
+ return None
+
+
+def wait_for_vnf(tacker_client, vnf_id=None, vnf_name=None, timeout=60):
+ try:
+ vnf = get_vnf(tacker_client, vnf_id, vnf_name)
if vnf is None:
- raise Exception("Could not retrieve VNF with ID [%s]" % _id)
+ raise Exception("Could not retrieve VNF - id='%s', name='%s'"
+ % vnf_id, vnf_name)
logger.info('Waiting for vnf {0}'.format(str(vnf)))
- while True and timeout >= 0:
+ while vnf['status'] != 'ACTIVE' and timeout >= 0:
if vnf['status'] == 'ERROR':
- raise Exception('Error when booting vnf %s' % _id)
+ raise Exception('Error when booting vnf %s' % vnf['id'])
elif vnf['status'] == 'PENDING_CREATE':
time.sleep(3)
timeout -= 3
- continue
- else:
- break
- return _id
+ vnf = get_vnf(tacker_client, vnf_id, vnf_name)
+
+ if (timeout < 0):
+ raise Exception('Timeout when booting vnf %s' % vnf['id'])
+
+ return vnf['id']
except Exception, e:
logger.error("error [wait_for_vnf(tacker_client, '%s', '%s')]: %s"
% (vnf_id, vnf_name, e))