3 # jose.lausuch@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
15 from functest.utils.constants import CONST
16 import functest.utils.functest_utils as ft_utils
25 if self.status(verbose=False) == 0:
26 answer = raw_input("It seems that the environment has been "
27 "already prepared. Do you want to do "
30 if answer.lower() in ["y", "yes"]:
31 os.remove(CONST.__getattribute__('env_active'))
33 elif answer.lower() in ["n", "no"]:
36 answer = raw_input("Invalid answer. Please type [y|n]\n")
38 cmd = ("python %s/functest/ci/prepare_env.py start" %
39 CONST.__getattribute__('dir_repo_functest'))
40 ft_utils.execute_command(cmd)
43 def _get_value(attr, default='Unknown'):
44 return attr if attr else default
46 install_type = _get_value(CONST.__getattribute__('INSTALLER_TYPE'))
47 installer_ip = _get_value(CONST.__getattribute__('INSTALLER_IP'))
48 installer_info = ("%s, %s" % (install_type, installer_ip))
49 scenario = _get_value(CONST.__getattribute__('DEPLOY_SCENARIO'))
50 node = _get_value(CONST.__getattribute__('NODE_NAME'))
51 is_debug = _get_value(CONST.__getattribute__('CI_DEBUG'), 'false')
52 build_tag = CONST.__getattribute__('BUILD_TAG')
53 if build_tag is not None:
54 build_tag = build_tag.lstrip(
55 "jenkins-").lstrip("functest").lstrip("-")
58 if self.status(verbose=False) == 0:
61 msg = prettytable.PrettyTable(
62 header_style='upper', padding_width=5,
63 field_names=['Functest Environment', 'value'])
64 msg.add_row(['INSTALLER', installer_info])
65 msg.add_row(['SCENARIO', scenario])
66 msg.add_row(['POD', node])
68 msg.add_row(['BUILD TAG', build_tag])
69 msg.add_row(['DEBUG FLAG', is_debug])
70 msg.add_row(['STATUS', STATUS])
71 click.echo(msg.get_string())
73 def status(self, verbose=True):
75 if not os.path.isfile(CONST.__getattribute__('env_active')):
77 click.echo("Functest environment is not installed.\n")
80 click.echo("Functest environment ready to run tests.\n")