aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
Diffstat (limited to 'functest/utils')
-rw-r--r--functest/utils/functest_utils.py11
-rw-r--r--functest/utils/openstack_tacker.py22
-rwxr-xr-xfunctest/utils/openstack_utils.py15
3 files changed, 26 insertions, 22 deletions
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index 2bf87a05..04055464 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -96,8 +96,9 @@ def get_scenario():
try:
scenario = os.environ['DEPLOY_SCENARIO']
except KeyError:
- logger.error("Impossible to retrieve the scenario")
- scenario = "Unknown_scenario"
+ logger.info("Impossible to retrieve the scenario."
+ "Use default os-nosdn-nofeature-noha")
+ scenario = "os-nosdn-nofeature-noha"
return scenario
@@ -128,7 +129,7 @@ def get_pod_name():
try:
return os.environ['NODE_NAME']
except KeyError:
- logger.error(
+ logger.info(
"Unable to retrieve the POD name from environment. " +
"Using pod name 'unknown-pod'")
return "unknown-pod"
@@ -141,8 +142,8 @@ def get_build_tag():
try:
build_tag = os.environ['BUILD_TAG']
except KeyError:
- logger.error("Impossible to retrieve the build tag")
- build_tag = "unknown_build_tag"
+ logger.info("Impossible to retrieve the build tag")
+ build_tag = "none"
return build_tag
diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py
index f17b421e..c7ac89af 100644
--- a/functest/utils/openstack_tacker.py
+++ b/functest/utils/openstack_tacker.py
@@ -20,9 +20,9 @@ import time
logger = ft_logger.Logger("tacker_utils").getLogger()
-def get_tacker_client():
- creds_tacker = os_utils.get_credentials()
- return tackerclient.Client(**creds_tacker)
+def get_tacker_client(other_creds={}):
+ sess = os_utils.get_session(other_creds)
+ return tackerclient.Client(session=sess)
# *********************************************
@@ -74,12 +74,12 @@ def create_vnfd(tacker_client, tosca_file=None):
if tosca_file is not None:
with open(tosca_file) as tosca_fd:
vnfd_body = tosca_fd.read()
- logger.error(vnfd_body)
+ logger.info('VNFD template:\n{0}'.format(vnfd_body))
return tacker_client.create_vnfd(
body={"vnfd": {"attributes": {"vnfd": vnfd_body}}})
except Exception, e:
- logger.exception("Error [create_vnfd(tacker_client, '%s')]: %s"
- % (tosca_file, e))
+ logger.error("Error [create_vnfd(tacker_client, '%s')]: %s"
+ % (tosca_file, e))
return None
@@ -124,7 +124,8 @@ def create_vnf(tacker_client, vnf_name, vnfd_id=None, vnfd_name=None):
vnf_body['vnf']['vnfd_id'] = get_vnfd_id(tacker_client, vnfd_name)
return tacker_client.create_vnf(body=vnf_body)
except Exception, e:
- logger.error("error [create_vnf(tacker_client, '%s', '%s', '%s')]: %s"
+ logger.error("error [create_vnf(tacker_client,"
+ " '%s', '%s', '%s')]: %s"
% (vnf_name, vnfd_id, vnfd_name, e))
return None
@@ -206,7 +207,8 @@ def create_sfc(tacker_client, sfc_name,
for name in chain_vnf_names]
return tacker_client.create_sfc(body=sfc_body)
except Exception, e:
- logger.error("error [create_sfc(tacker_client, '%s', '%s', '%s')]: %s"
+ logger.error("error [create_sfc(tacker_client,"
+ " '%s', '%s', '%s')]: %s"
% (sfc_name, chain_vnf_ids, chain_vnf_names, e))
return None
@@ -263,8 +265,8 @@ def create_sfc_classifier(tacker_client, sfc_clf_name, sfc_id=None,
tacker_client, sfc_name)
return tacker_client.create_sfc_classifier(body=sfc_clf_body)
except Exception, e:
- logger.error("error [create_sfc_classifier(tacker_client, '%s', '%s',"
- " '%s', '%s')]: '%s'"
+ logger.error("error [create_sfc_classifier(tacker_client,"
+ " '%s', '%s','%s', '%s')]: '%s'"
% (sfc_clf_name, sfc_id, sfc_name, str(match), e))
return None
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index 64f18504..c21ed818 100755
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -10,7 +10,7 @@
import os
import os.path
-import subprocess
+import re
import sys
import time
@@ -112,12 +112,13 @@ def get_credentials(other_creds={}):
def source_credentials(rc_file):
- pipe = subprocess.Popen(". %s; env" % rc_file, stdout=subprocess.PIPE,
- shell=True)
- output = pipe.communicate()[0]
- env = dict((line.split("=", 1) for line in output.splitlines()))
- os.environ.update(env)
- return env
+ with open(rc_file, "r") as f:
+ for line in f:
+ var = line.rstrip('"\n').replace(
+ 'export ', '').replace("'", "").split("=")
+ key = re.sub(r'^ *| *$', '', var[0])
+ value = re.sub(r'^[" ]*|[ "]*$', '', "".join(var[1:]))
+ os.environ[key] = value
def get_credentials_for_rally():