Add CLI framework for Bottlenecks 27/24927/5
authoryuyang <Gabriel.yuyang@huawei.com>
Sat, 26 Nov 2016 15:07:41 +0000 (23:07 +0800)
committeryuyang <Gabriel.yuyang@huawei.com>
Mon, 28 Nov 2016 11:29:38 +0000 (19:29 +0800)
JIRA: BOTTLENECK-65

Adding cli framwork for Bottlenecks.

Usage:
bottlenecks testcase run <testcase>

Currently only the cli framwork and testcase command group is added.
run, list, etc., commands and openstack command group
will added afterwards.

Two setup entries are added. One is within the top directory and the
other is within the cli directory.

Change-Id: I304f6f2e9b29b9f582953c2739806c1fb3e87fed
Signed-off-by: yuyang <Gabriel.yuyang@huawei.com>
__init__.py [new file with mode: 0644]
cli/__init__.py [new file with mode: 0644]
cli/bottlenecks_cli.py [new file with mode: 0644]
cli/command_group/__init__.py [new file with mode: 0644]
cli/command_group/testcase.py [new file with mode: 0644]
cli/setup.py [new file with mode: 0644]
setup.py [new file with mode: 0644]

diff --git a/__init__.py b/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/cli/__init__.py b/cli/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/cli/bottlenecks_cli.py b/cli/bottlenecks_cli.py
new file mode 100644 (file)
index 0000000..0328578
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+
+from command_group.testcase import Testcase
+
+CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
+
+
+@click.group(context_settings=CONTEXT_SETTINGS)
+@click.version_option(version='0.1')
+@click.pass_context
+def main(ctx):
+    """cli for bottlenecks project
+
+       commands:
+       bottlenecks testcase run <testcase>
+    """
+    pass
+
+_testcase = Testcase()
+
+@main.group()
+@click.pass_context
+def testcase(ctx):
+    """testcase cli group for bottlenecks project"""
+    pass
+
+@testcase.command('run', help="To execute a test case.")
+@click.argument('testname', type=click.STRING, required=True)
+@click.option('-n', '--noclean', is_flag=True, default=False,
+              help='Openstack resources created by the test'
+              'will not be cleaned after the testcase execution.')
+def testcase_run(testname, noclean):
+    _testcase.run(testname, noclean)
diff --git a/cli/command_group/__init__.py b/cli/command_group/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/cli/command_group/testcase.py b/cli/command_group/testcase.py
new file mode 100644 (file)
index 0000000..1fe0fba
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+
+
+class Testcase(object):
+    """Test command group.
+
+       Set of commnads to execute and list testcases
+    """
+
+    def __init__(self):
+        self.test_case_path = '/home/opnfv/bottlenecks/testsuites/'
+        self.test_case_list = []
+
+    def run(self, testname, noclean=False):
+        if testname == 'posca':
+            os.system('bash /home/opnfv/bottlenecks/run_tests.sh -s posca')
diff --git a/cli/setup.py b/cli/setup.py
new file mode 100644 (file)
index 0000000..2831491
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+
+from setuptools import setup
+
+setup(
+    name='bottlenecks',
+    version='0.1',
+    py_modules=['bottlenecks_cli'],
+    include_package_data=True,
+    install_requires=[
+        'click',
+    ],
+    entry_points='''
+        [console_scripts]
+        bottlenecks=bottlenecks_cli:main
+    ''',
+)
+
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..38b8546
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+
+from setuptools import setup, find_packages
+
+
+setup(
+    name="bottlenecks",
+    version="master",
+    py_modules=['bottlenecks_cli'],
+    packages=find_packages(),
+    include_package_data=True,
+    package_data={
+    },
+    url="https://www.opnfv.org",
+    install_requires=["click"],
+    entry_points={
+        'console_scripts': [
+            'bottlenecks=cli.bottlenecks_cli:main'
+        ],
+    },
+)