Remove duplicate ubuntu trusty/14.04 os image
[functest.git] / functest / cli / commands / cli_env.py
1 #!/usr/bin/env python
2 #
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
8
9 # pylint: disable=missing-docstring
10
11 import click
12 import prettytable
13 import six
14
15 from functest.utils import env
16
17
18 class Env(object):  # pylint: disable=too-few-public-methods
19
20     @staticmethod
21     def show():
22         install_type = env.get('INSTALLER_TYPE')
23         scenario = env.get('DEPLOY_SCENARIO')
24         node = env.get('NODE_NAME')
25         build_tag = env.get('BUILD_TAG')
26         if build_tag:
27             build_tag = build_tag.lstrip(
28                 "jenkins-").lstrip("functest").lstrip("-")
29
30         env_info = {'INSTALLER': install_type,
31                     'SCENARIO': scenario,
32                     'POD': node,
33                     'BUILD_TAG': build_tag}
34
35         return env_info
36
37
38 class CliEnv(object):  # pylint: disable=too-few-public-methods
39
40     @staticmethod
41     def show():
42         env_info = Env.show()
43         msg = prettytable.PrettyTable(
44             header_style='upper', padding_width=5,
45             field_names=['Functest Environment', 'value'])
46         for key, value in six.iteritems(env_info):
47             if key is not None:
48                 msg.add_row([key, value])
49         click.echo(msg.get_string())