aboutsummaryrefslogtreecommitdiffstats
path: root/functest/cli
diff options
context:
space:
mode:
Diffstat (limited to 'functest/cli')
-rw-r--r--functest/cli/cli_base.py12
-rw-r--r--functest/cli/commands/cli_env.py39
-rw-r--r--functest/cli/commands/cli_os.py34
-rw-r--r--functest/cli/commands/cli_testcase.py9
-rw-r--r--functest/cli/commands/cli_tier.py9
-rw-r--r--functest/cli/setup.py15
6 files changed, 29 insertions, 89 deletions
diff --git a/functest/cli/cli_base.py b/functest/cli/cli_base.py
index 2104e125..54b3e72b 100644
--- a/functest/cli/cli_base.py
+++ b/functest/cli/cli_base.py
@@ -9,12 +9,12 @@
import click
import logging.config
+import pkg_resources
from functest.cli.commands.cli_env import CliEnv
from functest.cli.commands.cli_os import CliOpenStack
from functest.cli.commands.cli_testcase import CliTestcase
from functest.cli.commands.cli_tier import CliTier
-from functest.utils.constants import CONST
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@@ -23,8 +23,8 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
@click.group(context_settings=CONTEXT_SETTINGS)
@click.version_option(version='opnfv colorado.0.1 ')
def cli():
- logging.config.fileConfig(
- CONST.__getattribute__('dir_functest_logging_cfg'))
+ logging.config.fileConfig(pkg_resources.resource_filename(
+ 'functest', 'ci/logging.ini'))
_env = CliEnv()
@@ -86,12 +86,6 @@ def os_show_credentials():
_openstack.show_credentials()
-@openstack.command('fetch-rc', help="Fetch the OpenStack RC file from "
- "the installer.")
-def os_fetch_rc():
- _openstack.fetch_credentials()
-
-
@env.command('prepare', help="Prepares the Functest environment. This step is "
"needed run the tests.")
def env_prepare():
diff --git a/functest/cli/commands/cli_env.py b/functest/cli/commands/cli_env.py
index f5ba4b34..ce977572 100644
--- a/functest/cli/commands/cli_env.py
+++ b/functest/cli/commands/cli_env.py
@@ -8,9 +8,10 @@
#
import os
+import pkg_resources
import click
-import git
+import prettytable
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
@@ -35,8 +36,8 @@ class CliEnv(object):
else:
answer = raw_input("Invalid answer. Please type [y|n]\n")
- cmd = ("python %s/functest/ci/prepare_env.py start" %
- CONST.__getattribute__('dir_repo_functest'))
+ cmd = ("python %s start" % pkg_resources.resource_filename(
+ 'functest', 'ci/prepare_env.py'))
ft_utils.execute_command(cmd)
def show(self):
@@ -48,14 +49,6 @@ class CliEnv(object):
installer_info = ("%s, %s" % (install_type, installer_ip))
scenario = _get_value(CONST.__getattribute__('DEPLOY_SCENARIO'))
node = _get_value(CONST.__getattribute__('NODE_NAME'))
- repo_h = git.Repo(CONST.__getattribute__('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.__getattribute__('CI_DEBUG'), 'false')
build_tag = CONST.__getattribute__('BUILD_TAG')
if build_tag is not None:
@@ -66,21 +59,17 @@ class CliEnv(object):
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))
+ msg = prettytable.PrettyTable(
+ header_style='upper', padding_width=5,
+ field_names=['Functest Environment', 'value'])
+ msg.add_row(['INSTALLER', installer_info])
+ msg.add_row(['SCENARIO', scenario])
+ msg.add_row(['POD', node])
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("")
+ msg.add_row(['BUILD TAG', build_tag])
+ msg.add_row(['DEBUG FLAG', is_debug])
+ msg.add_row(['STATUS', STATUS])
+ click.echo(msg.get_string())
def status(self, verbose=True):
ret_val = 0
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
index 5e6e1109..875529f2 100644
--- a/functest/cli/commands/cli_os.py
+++ b/functest/cli/commands/cli_os.py
@@ -9,6 +9,7 @@
import os
+import pkg_resources
import click
@@ -47,39 +48,10 @@ class CliOpenStack(object):
if key.startswith('OS_'):
click.echo("{}={}".format(key, value))
- def fetch_credentials(self):
- if os.path.isfile(self.openstack_creds):
- answer = raw_input("It seems the RC file is already present. "
- "Do you want to overwrite it? [y|n]\n")
- while True:
- if answer.lower() in ["y", "yes"]:
- break
- elif answer.lower() in ["n", "no"]:
- return
- else:
- answer = raw_input("Invalid answer. Please type [y|n]\n")
-
- installer_type = CONST.__getattribute__('INSTALLER_TYPE')
- if installer_type is None:
- click.echo("The environment variable 'INSTALLER_TYPE' is not"
- "defined. Please export it")
- installer_ip = CONST.__getattribute__('INSTALLER_IP')
- if installer_ip is None:
- click.echo("The environment variable 'INSTALLER_IP' is not"
- "defined. Please export it")
- cmd = ("fetch_os_creds.sh -d %s -i %s -a %s"
- % (self.openstack_creds,
- installer_type,
- installer_ip))
- click.echo("Fetching credentials from installer node '%s' with IP=%s.."
- % (installer_type, installer_ip))
- ft_utils.execute_command(cmd, verbose=False)
-
def check(self):
self.ping_endpoint()
- cmd = os.path.join(CONST.__getattribute__('dir_repo_functest'),
- "functest/ci/check_os.sh")
- ft_utils.execute_command(cmd, verbose=False)
+ ft_utils.execute_command("sh %s" % pkg_resources.resource_filename(
+ 'functest', 'ci/check_os.sh'), verbose=False)
def snapshot_create(self):
self.ping_endpoint()
diff --git a/functest/cli/commands/cli_testcase.py b/functest/cli/commands/cli_testcase.py
index 3d3f1cb3..91904d87 100644
--- a/functest/cli/commands/cli_testcase.py
+++ b/functest/cli/commands/cli_testcase.py
@@ -10,6 +10,7 @@
""" global variables """
import os
+import pkg_resources
import click
@@ -25,7 +26,7 @@ class CliTestcase(object):
self.tiers = tb.TierBuilder(
CONST.__getattribute__('INSTALLER_TYPE'),
CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('functest_testcases_yaml'))
+ pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
def list(self):
summary = ""
@@ -59,8 +60,8 @@ class CliTestcase(object):
else:
tests = testname.split(",")
for test in tests:
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
+ cmd = ("python %s %s -t %s" %
+ (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'),
flags, test))
ft_utils.execute_command(cmd)
diff --git a/functest/cli/commands/cli_tier.py b/functest/cli/commands/cli_tier.py
index 531f0ff9..48e9f542 100644
--- a/functest/cli/commands/cli_tier.py
+++ b/functest/cli/commands/cli_tier.py
@@ -10,6 +10,7 @@
""" global variables """
import os
+import pkg_resources
import click
@@ -24,7 +25,7 @@ class CliTier(object):
self.tiers = tb.TierBuilder(
CONST.__getattribute__('INSTALLER_TYPE'),
CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('functest_testcases_yaml'))
+ pkg_resources.resource_filename('functest', 'ci/testcases.yaml'))
def list(self):
summary = ""
@@ -67,8 +68,6 @@ class CliTier(object):
click.echo("Functest environment is not ready. "
"Run first 'functest env prepare'")
else:
- cmd = ("python %s/functest/ci/run_tests.py "
- "%s -t %s" %
- (CONST.__getattribute__('dir_repo_functest'),
- flags, tiername))
+ cmd = ("python %s %s -t %s" % (pkg_resources.resource_filename(
+ 'functest', 'ci/run_tests.py'), flags, tiername))
ft_utils.execute_command(cmd)
diff --git a/functest/cli/setup.py b/functest/cli/setup.py
deleted file mode 100644
index 21547e15..00000000
--- a/functest/cli/setup.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from setuptools import setup
-
-setup(
- name='functest',
- version='colorado.0.1',
- py_modules=['cli_base'],
- include_package_data=True,
- install_requires=[
- 'click',
- ],
- entry_points='''
- [console_scripts]
- functest=cli_base:cli
- ''',
-)