aboutsummaryrefslogtreecommitdiffstats
path: root/utils/functest_utils.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-06-30 14:12:54 +0200
committerJose Lausuch <jose.lausuch@ericsson.com>2016-07-04 07:27:32 +0000
commitbbc47d487f06da2906116e5ade134e11c4221786 (patch)
treed52c4ded1b3774b449c8d89b961ab17b0d28e7c5 /utils/functest_utils.py
parent7388d059ff9f4efed594582ded843f795e56c9fa (diff)
Change OpenStack clean behaviour
JIRA: FUNCTEST-236 The openstack snapshot generation is now triggered before running a test case and removed from prepare_env Change-Id: I4d1bc95dedd7f59d4b1d5866f288e1c1a70ec69e Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'utils/functest_utils.py')
-rw-r--r--utils/functest_utils.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index 2e7a12238..285f887cf 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -8,23 +8,25 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
+""" global variables """
+
from datetime import datetime as dt
import json
import os
import os.path
import re
-import requests
import shutil
import socket
import subprocess
import sys
import urllib2
-import yaml
-from git import Repo
+
import functest.ci.tier_builder as tb
+from git import Repo
+import requests
+import yaml
-""" global variables """
REPOS_DIR = os.getenv('repos_dir')
FUNCTEST_REPO = ("%s/functest/" % REPOS_DIR)
@@ -300,3 +302,26 @@ def get_criteria_by_test(testname):
criteria = test.get_criteria()
return criteria
+
+
+# ----------------------------------------------------------
+#
+# YAML UTILS
+#
+# -----------------------------------------------------------
+def get_parameter_from_yaml(parameter):
+ """
+ Returns the value of a given parameter in config_functest.yaml
+ parameter must be given in string format with dots
+ Example: general.openstack.image_name
+ """
+ with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+ functest_yaml = yaml.safe_load(f)
+ f.close()
+ value = functest_yaml
+ for element in parameter.split("."):
+ value = value.get(element)
+ if value is None:
+ raise ValueError("The parameter %s is not defined in"
+ " config_functest.yaml" % parameter)
+ return value