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
16 from functest.utils.constants import CONST
17 import functest.utils.functest_utils as ft_utils
26 if self.status(verbose=False) == 0:
27 answer = raw_input("It seems that the environment has been "
28 "already prepared. Do you want to do "
31 if answer.lower() in ["y", "yes"]:
32 os.remove(CONST.__getattribute__('env_active'))
34 elif answer.lower() in ["n", "no"]:
37 answer = raw_input("Invalid answer. Please type [y|n]\n")
39 cmd = ("python %s start" % pkg_resources.resource_filename(
40 'functest', 'ci/prepare_env.py'))
41 ft_utils.execute_command(cmd)
44 def _get_value(attr, default='Unknown'):
45 return attr if attr else default
47 install_type = _get_value(CONST.__getattribute__('INSTALLER_TYPE'))
48 installer_ip = _get_value(CONST.__getattribute__('INSTALLER_IP'))
49 installer_info = ("%s, %s" % (install_type, installer_ip))
50 scenario = _get_value(CONST.__getattribute__('DEPLOY_SCENARIO'))
51 node = _get_value(CONST.__getattribute__('NODE_NAME'))
52 is_debug = _get_value(CONST.__getattribute__('CI_DEBUG'), 'false')
53 build_tag = CONST.__getattribute__('BUILD_TAG')
54 if build_tag is not None:
55 build_tag = build_tag.lstrip(
56 "jenkins-").lstrip("functest").lstrip("-")
59 if self.status(verbose=False) == 0:
62 msg = prettytable.PrettyTable(
63 header_style='upper', padding_width=5,
64 field_names=['Functest Environment', 'value'])
65 msg.add_row(['INSTALLER', installer_info])
66 msg.add_row(['SCENARIO', scenario])
67 msg.add_row(['POD', node])
69 msg.add_row(['BUILD TAG', build_tag])
70 msg.add_row(['DEBUG FLAG', is_debug])
71 msg.add_row(['STATUS', STATUS])
72 click.echo(msg.get_string())
74 def status(self, verbose=True):
76 if not os.path.isfile(CONST.__getattribute__('env_active')):
78 click.echo("Functest environment is not installed.\n")
81 click.echo("Functest environment ready to run tests.\n")