Create CLI template for Functest 55/13455/2
authorjose.lausuch <jose.lausuch@ericsson.com>
Fri, 29 Apr 2016 15:58:37 +0000 (17:58 +0200)
committerjose.lausuch <jose.lausuch@ericsson.com>
Mon, 2 May 2016 11:16:54 +0000 (13:16 +0200)
JIRA: FUNCTEST-235

Change-Id: I235a53781fbcde91ccf15d15ea52c96ee2ee9433
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
cli/__init__.py [new file with mode: 0644]
cli/cli_base.py [new file with mode: 0644]
cli/commands/__init__.py [new file with mode: 0644]
cli/commands/cli_env.py [new file with mode: 0644]
cli/commands/cli_testcase.py [new file with mode: 0644]
cli/commands/cli_tier.py [new file with mode: 0644]
cli/setup.py [new file with mode: 0644]
docker/Dockerfile

diff --git a/cli/__init__.py b/cli/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/cli/cli_base.py b/cli/cli_base.py
new file mode 100644 (file)
index 0000000..e8c1d19
--- /dev/null
@@ -0,0 +1,104 @@
+import click
+
+from functest.cli.commands.cli_env import CliEnv
+from functest.cli.commands.cli_testcase import CliTestcase
+from functest.cli.commands.cli_tier import CliTier
+
+CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
+
+
+@click.group(context_settings=CONTEXT_SETTINGS)
+@click.version_option(version='opnfv colorado.0.1 ')
+def cli():
+    pass
+
+_env = CliEnv()
+_testcase = CliTestcase()
+_tier = CliTier()
+
+
+@cli.group()
+@click.pass_context
+def env(ctx):
+    pass
+
+
+@cli.group()
+@click.pass_context
+def testcase(ctx):
+    pass
+
+
+@cli.group()
+@click.pass_context
+def tier(ctx):
+    pass
+
+
+@env.command('show', help="write the help here")
+def env_show():
+    _env.show()
+
+
+@env.command('status', help="write the help here")
+def env_status():
+    _env.status()
+
+
+@env.command('getrc', help="write the help here")
+def env_getrc():
+    _env.getrc()
+
+
+@env.command('sourcerc', help="write the help here")
+def env_sourcerc():
+    _env.sourcerc()
+
+
+@env.command('setdefaults', help="write the help here")
+def env_setdefaults():
+    _env.setdefaults()
+
+
+@env.command('getdefaults', help="write the help here")
+def env_getdefaults():
+    _env.getdefaults()
+
+
+@env.command('clean', help="write the help here")
+def env_clean():
+    _env.clean()
+
+
+@testcase.command('list', help="write the help here")
+def testcase_list():
+    _testcase.list()
+
+
+@testcase.command('show', help="write the help here")
+@click.argument('testname', type=click.STRING, required=True)
+def testcase_show(testname):
+    _testcase.show(testname)
+
+
+@testcase.command('run', help="write the help here")
+@click.argument('testname', type=click.STRING, required=True)
+def testcase_run(testname):
+    _testcase.run(testname)
+
+
+@tier.command('list', help="write the help here")
+def tier_list():
+    _tier.list()
+
+
+@tier.command('show', help="write the help here")
+@click.argument('tiername', type=click.STRING, required=True)
+def tier_show(tiername):
+    _tier.show(tiername)
+
+
+@tier.command('run', help="write the help here")
+@click.argument('tiername', type=click.STRING, required=True)
+def tier_run(tiername):
+    _tier.run(tiername)
diff --git a/cli/commands/__init__.py b/cli/commands/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/cli/commands/cli_env.py b/cli/commands/cli_env.py
new file mode 100644 (file)
index 0000000..b2570d3
--- /dev/null
@@ -0,0 +1,36 @@
+#!/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 click
+
+
+class CliEnv:
+    def __init__(self):
+        pass
+
+    def show(self):
+        click.echo("env show")
+
+    def status(self):
+        click.echo("env status")
+
+    def getrc(self):
+        click.echo("env getrc")
+
+    def sourcerc(self):
+        click.echo("env sourcerc")
+
+    def setdefaults(self):
+        click.echo("env setdefaults")
+
+    def getdefaults(self):
+        click.echo("env getdefaults")
+
+    def clean(self):
+        click.echo("env clean")
diff --git a/cli/commands/cli_testcase.py b/cli/commands/cli_testcase.py
new file mode 100644 (file)
index 0000000..71bfedd
--- /dev/null
@@ -0,0 +1,24 @@
+#!/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 click
+
+
+class CliTestcase:
+    def __init__(self):
+        pass
+
+    def list(self):
+        click.echo("testcase list")
+
+    def show(self, testname):
+        click.echo("testcase show %s" % testname)
+
+    def run(self, testname):
+        click.echo("testcase run %s" % testname)
diff --git a/cli/commands/cli_tier.py b/cli/commands/cli_tier.py
new file mode 100644 (file)
index 0000000..efb8ad5
--- /dev/null
@@ -0,0 +1,24 @@
+#!/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 click
+
+
+class CliTier:
+    def __init__(self):
+        pass
+
+    def list(self):
+        click.echo("tier list")
+
+    def show(self, tiername):
+        click.echo("tier show %s" % tiername)
+
+    def run(self, tiername):
+        click.echo("tier run %s" % tiername)
diff --git a/cli/setup.py b/cli/setup.py
new file mode 100644 (file)
index 0000000..21547e1
--- /dev/null
@@ -0,0 +1,15 @@
+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
+    ''',
+)
index 026c01f..b2560be 100644 (file)
@@ -109,3 +109,4 @@ RUN cd ${repos_dir}/promise && npm install
 RUN /bin/echo -e "set nocompatible\nset backspace=2" >> /home/opnfv/.vimrc
 RUN echo "set nocompatible" >> /home/opnfv/.exrc
 RUN echo "alias ll='ls -lh'" >> /home/opnfv/.bashrc
+RUN cd ${repos_dir}/functest/cli && pip install .
\ No newline at end of file