Merge "Download Functest's upper-constraints.txt"
[functest.git] / functest / ci / prepare_env.py
old mode 100755 (executable)
new mode 100644 (file)
index fd1f5db..da3e624
@@ -251,8 +251,7 @@ def update_db_url():
 def verify_deployment():
     print_separator()
     logger.info("Verifying OpenStack services...")
-    cmd = ("sh %s" % pkg_resources.resource_filename(
-        'functest', 'ci/check_os.sh'))
+    cmd = "check_os.sh"
 
     logger.debug("Executing command: %s" % cmd)
     p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
@@ -261,7 +260,7 @@ def verify_deployment():
         line = p.stdout.readline().rstrip()
         if "ERROR" in line:
             logger.error(line)
-            raise Exception("Problem while running 'check_os.sh'.")
+            raise Exception("Problem while running '{}'.".format(cmd))
         logger.info(line)
 
 
@@ -358,7 +357,7 @@ def print_deployment_info():
                     handler.get_deployment_info())
 
 
-def main(**kwargs):
+def prepare_env(**kwargs):
     try:
         if not (kwargs['action'] in actions):
             logger.error('Argument not valid.')
@@ -366,7 +365,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 +375,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:
@@ -386,9 +383,9 @@ def main(**kwargs):
     return 0
 
 
-if __name__ == '__main__':
+def main():
     logging.config.fileConfig(pkg_resources.resource_filename(
         'functest', 'ci/logging.ini'))
     parser = PrepareEnvParser()
     args = parser.parse_args(sys.argv[1:])
-    sys.exit(main(**args))
+    return prepare_env(**args)