aboutsummaryrefslogtreecommitdiffstats
path: root/requirements.txt
blob: 28b3fed3ea84f3daeef6aba0d224052aed61582e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
pyyaml==3.10
gitpython==1.0.1
python-openstackclient==2.3.0
python-ceilometerclient==2.6.2
python-keystoneclient==3.5.0
python-neutronclient==6.0.0
python-congressclient==1.5.0
virtualenv==15.1.0
pexpect==4.0
requests>=2.8.0
robotframework==2.9.1
robotframework-requests==0.3.8
robotframework-sshlibrary==2.1.1
configObj==5.0.6
Flask==0.10.1
xmltodict==0.9.2
scp==0.10.2
paramiko==1.16.0
subprocess32
shyaml
dnspython
Pillow==3.3.0
click==6.6
#aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#!/usr/bin/env python
#
# jose.lausuch@ericsson.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#

import os

import click
import git

from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils


class CliEnv(object):

    def __init__(self):
        pass

    def prepare(self):
        if self.status(verbose=False) == 0:
            answer = raw_input("It seems that the environment has been "
                               "already prepared. Do you want to do "
                               "it again? [y|n]\n")
            while True:
                if answer.lower() in ["y", "yes"]:
                    os.remove(CONST.env_active)
                    break
                elif answer.lower() in ["n", "no"]:
                    return
                else:
                    answer = raw_input("Invalid answer. Please type [y|n]\n")

        cmd = ("python %s/functest/ci/prepare_env.py start" %
               CONST.dir_repo_functest)
        ft_utils.execute_command(cmd)

    def show(self):
        def _get_value(attr, default='Unknown'):
            return attr if attr else default

        install_type = _get_value(CONST.INSTALLER_TYPE)
        installer_ip = _get_value(CONST.INSTALLER_IP)
        installer_info = ("%s, %s" % (install_type, installer_ip))
        scenario = _get_value(CONST.DEPLOY_SCENARIO)
        node = _get_value(CONST.NODE_NAME)
        repo_h = git.Repo(CONST.dir_repo_functest).head
        if repo_h.is_detached:
            git_branch = 'detached from FETCH_HEAD'
            git_hash = repo_h.commit.hexsha
        else:
            branch = repo_h.reference
            git_branch = branch.name
            git_hash = branch.commit.hexsha
        is_debug = _get_value(CONST.CI_DEBUG, 'false')
        build_tag = CONST.BUILD_TAG
        if build_tag is not None:
            build_tag = build_tag.lstrip(
                "jenkins-").lstrip("functest").lstrip("-")

        STATUS = "not ready"
        if self.status(verbose=False) == 0:
            STATUS = "ready"

        click.echo("+======================================================+")
        click.echo("| Functest Environment info                            |")
        click.echo("+======================================================+")
        click.echo("|  INSTALLER: %s|" % installer_info.ljust(41))
        click.echo("|   SCENARIO: %s|" % scenario.ljust(41))
        click.echo("|        POD: %s|" % node.ljust(41))
        click.echo("| GIT BRACNH: %s|" % git_branch.ljust(41))
        click.echo("|   GIT HASH: %s|" % git_hash.ljust(41))
        if build_tag:
            click.echo("|  BUILD TAG: %s|" % build_tag.ljust(41))
        click.echo("| DEBUG FLAG: %s|" % is_debug.ljust(41))
        click.echo("+------------------------------------------------------+")
        click.echo("|     STATUS: %s|" % STATUS.ljust(41))
        click.echo("+------------------------------------------------------+")
        click.echo("")

    def status(self, verbose=True):
        ret_val = 0
        if not os.path.isfile(CONST.env_active):
            if verbose:
                click.echo("Functest environment is not installed.\n")
            ret_val = 1
        elif verbose:
            click.echo("Functest environment ready to run tests.\n")

        return ret_val