diff options
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/config_functest.py | 23 | ||||
-rw-r--r-- | testcases/functest_utils.py | 2 |
2 files changed, 22 insertions, 3 deletions
diff --git a/testcases/config_functest.py b/testcases/config_functest.py index a106f07bc..3c608344a 100644 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -8,9 +8,11 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import re, json, os, urllib2, argparse, logging, shutil, subprocess, yaml, sys +import re, json, os, urllib2, argparse, logging, shutil, subprocess, yaml, sys, getpass import functest_utils from git import Repo +from os import stat +from pwd import getpwuid actions = ['start', 'check', 'clean'] parser = argparse.ArgumentParser() @@ -71,6 +73,10 @@ def action_start(): """ Start the functest environment installation """ + if not check_permissions(): + logger.error("Bad Python cache directory ownership.") + exit(-1) + if not functest_utils.check_internet_connectivity(): logger.error("There is no Internet connectivity. Please check the network configuration.") exit(-1) @@ -219,6 +225,18 @@ def action_clean(): +def check_permissions(): + current_user = getpass.getuser() + cache_dir = HOME+".cache/pip" + logger.info("Checking permissions of '%s'..." %cache_dir) + logger.debug("Current user is '%s'" %current_user) + cache_user = getpwuid(stat(cache_dir).st_uid).pw_name + logger.debug("Cache directory owner is '%s'" %cache_user) + if cache_user != current_user: + logger.info("The owner of '%s' is '%s'. Please run 'sudo chown -R %s %s'." %(cache_dir, cache_user, current_user, cache_dir)) + return False + + return True def install_rally(): @@ -231,7 +249,8 @@ def install_rally(): logger.debug("Executing %s./install_rally.sh..." %RALLY_REPO_DIR) install_script = RALLY_REPO_DIR + "install_rally.sh" - functest_utils.execute_command(install_script,logger) + cmd = 'sudo ' + install_script + functest_utils.execute_command(cmd,logger) logger.debug("Creating Rally environment...") cmd = "rally deployment create --fromenv --name=opnfv-arno-rally" diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index 838b09c4b..e146db1cd 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -203,7 +203,7 @@ def check_internet_connectivity(url='http://www.opnfv.org/'): try: urllib2.urlopen(url, timeout=5) return True - except urllib.request.URLError: + except urllib.URLError: return False |