aboutsummaryrefslogtreecommitdiffstats
path: root/functest/ci/prepare_env.py
diff options
context:
space:
mode:
Diffstat (limited to 'functest/ci/prepare_env.py')
-rwxr-xr-xfunctest/ci/prepare_env.py66
1 files changed, 40 insertions, 26 deletions
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 3df3a0e0..74c751af 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -29,12 +29,6 @@ import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
actions = ['start', 'check']
-parser = argparse.ArgumentParser()
-parser.add_argument("action", help="Possible actions are: "
- "'{d[0]}|{d[1]}' ".format(d=actions))
-parser.add_argument("-d", "--debug", help="Debug mode", action="store_true")
-args = parser.parse_args()
-
""" logging configuration """
logger = ft_logger.Logger("prepare_env").getLogger()
@@ -48,6 +42,19 @@ with open(CONFIG_PATCH_PATH) as f:
functest_patch_yaml = yaml.safe_load(f)
+class PrepareEnvParser():
+
+ def __init__(self):
+ self.parser = argparse.ArgumentParser()
+ self.parser.add_argument("action", help="Possible actions are: "
+ "'{d[0]}|{d[1]}' ".format(d=actions))
+ self.parser.add_argument("-d", "--debug", help="Debug mode",
+ action="store_true")
+
+ def parse_args(self, argv=[]):
+ return vars(self.parser.parse_args(argv))
+
+
def print_separator():
logger.info("==============================================")
@@ -227,32 +234,36 @@ def install_rally():
rally_conf = os_utils.get_credentials_for_rally()
with open('rally_conf.json', 'w') as fp:
json.dump(rally_conf, fp)
- cmd = "rally deployment create --file=rally_conf.json --name="
- cmd += CONST.rally_deployment_name
- ft_utils.execute_command(cmd,
- error_msg="Problem creating Rally deployment")
-
- logger.info("Installing tempest from existing repo...")
- cmd = ("rally verify install --source " +
- CONST.dir_repo_tempest +
- " --system-wide")
+ cmd = ("rally deployment create "
+ "--file=rally_conf.json --name={}"
+ .format(CONST.rally_deployment_name))
ft_utils.execute_command(cmd,
- error_msg="Problem installing Tempest.")
+ error_msg=("Problem while creating "
+ "Rally deployment"))
cmd = "rally deployment check"
ft_utils.execute_command(cmd,
error_msg=("OpenStack not responding or "
"faulty Rally deployment."))
- cmd = "rally show images"
+ cmd = "rally deployment list"
ft_utils.execute_command(cmd,
error_msg=("Problem while listing "
- "OpenStack images."))
+ "Rally deployment."))
- cmd = "rally show flavors"
+ cmd = "rally plugin list | head -5"
ft_utils.execute_command(cmd,
error_msg=("Problem while showing "
- "OpenStack flavors."))
+ "Rally plugins."))
+
+
+def install_tempest():
+ logger.info("Installing tempest from existing repo...")
+ cmd = ("rally verify create-verifier --source {0} "
+ "--name {1} --type tempest"
+ .format(CONST.dir_repo_tempest, CONST.tempest_deployment_name))
+ ft_utils.execute_command(cmd,
+ error_msg="Problem while installing Tempest.")
def check_environment():
@@ -267,15 +278,15 @@ def check_environment():
logger.error(msg_not_active)
sys.exit(1)
- logger.info("Functest environment installed.")
+ logger.info("Functest environment is installed.")
-def main():
- if not (args.action in actions):
+def main(**kwargs):
+ if not (kwargs['action'] in actions):
logger.error('Argument not valid.')
sys.exit()
- if args.action == "start":
+ if kwargs['action'] == "start":
logger.info("######### Preparing Functest environment #########\n")
check_env_variables()
create_directories()
@@ -283,17 +294,20 @@ def main():
patch_config_file()
verify_deployment()
install_rally()
+ install_tempest()
with open(CONST.env_active, "w") as env_file:
env_file.write("1")
check_environment()
- if args.action == "check":
+ if kwargs['action'] == "check":
check_environment()
exit(0)
if __name__ == '__main__':
- main()
+ parser = PrepareEnvParser()
+ args = parser.parse_args(sys.argv[1:])
+ main(**args)