[odl-sfc] Fix bug when getting the params for create_vnf
[functest.git] / functest / cli / cli_base.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
10 import click
11
12 from functest.cli.commands.cli_env import CliEnv
13 from functest.cli.commands.cli_os import CliOpenStack
14 from functest.cli.commands.cli_testcase import CliTestcase
15 from functest.cli.commands.cli_tier import CliTier
16
17 CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
18
19
20 @click.group(context_settings=CONTEXT_SETTINGS)
21 @click.version_option(version='opnfv colorado.0.1 ')
22 def cli():
23     pass
24
25
26 _env = CliEnv()
27 _openstack = CliOpenStack()
28 _testcase = CliTestcase()
29 _tier = CliTier()
30
31
32 @cli.group()
33 @click.pass_context
34 def env(ctx):
35     pass
36
37
38 @cli.group()
39 @click.pass_context
40 def openstack(ctx):
41     pass
42
43
44 @cli.group()
45 @click.pass_context
46 def testcase(ctx):
47     pass
48
49
50 @cli.group()
51 @click.pass_context
52 def tier(ctx):
53     pass
54
55
56 @openstack.command('check', help="Checks connectivity and status "
57                    "to the OpenStack deployment.")
58 def os_check():
59     _openstack.check()
60
61
62 @openstack.command('snapshot-create', help="Generates a snapshot of the "
63                    "current OpenStack resources.")
64 def os_snapshot_create():
65     _openstack.snapshot_create()
66
67
68 @openstack.command('snapshot-show', help="Prints the OpenStack snapshot.")
69 def os_snapshot_show():
70     _openstack.snapshot_show()
71
72
73 @openstack.command('clean',
74                    help="Cleans the OpenStack resources except the snapshot.")
75 def os_clean():
76     _openstack.clean()
77
78
79 @openstack.command('show-credentials',
80                    help="Prints the OpenStack credentials.")
81 def os_show_credentials():
82     _openstack.show_credentials()
83
84
85 @openstack.command('fetch-rc', help="Fetch the OpenStack RC file from "
86                    "the installer.")
87 def os_fetch_rc():
88     _openstack.fetch_credentials()
89
90
91 @env.command('prepare', help="Prepares the Functest environment. This step is "
92              "needed run the tests.")
93 def env_prepare():
94     _env.prepare()
95
96
97 @env.command('show', help="Shows information about the current environment.")
98 def env_show():
99     _env.show()
100
101
102 @env.command('status', help="Checks if the Functest environment is ready to "
103              "run the tests.")
104 def env_status():
105     _env.status()
106
107
108 @testcase.command('list', help="Lists the available testcases.")
109 def testcase_list():
110     _testcase.list()
111
112
113 @testcase.command('show', help="Shows information about a test case.")
114 @click.argument('testname', type=click.STRING, required=True)
115 def testcase_show(testname):
116     _testcase.show(testname)
117
118
119 @testcase.command('run', help="Executes a test case.")
120 @click.argument('testname', type=click.STRING, required=True)
121 @click.option('-n', '--noclean', is_flag=True, default=False,
122               help='The created openstack resources by the test'
123               'will not be cleaned after the execution.')
124 @click.option('-r', '--report', is_flag=True, default=False,
125               help='Push results to the results DataBase. Only CI Pods'
126               'have rights to do that.')
127 def testcase_run(testname, noclean, report):
128     _testcase.run(testname, noclean, report)
129
130
131 @tier.command('list', help="Lists the available tiers.")
132 def tier_list():
133     _tier.list()
134
135
136 @tier.command('show', help="Shows information about a tier.")
137 @click.argument('tiername', type=click.STRING, required=True)
138 def tier_show(tiername):
139     _tier.show(tiername)
140
141
142 @tier.command('get-tests', help="Prints the tests in a tier.")
143 @click.argument('tiername', type=click.STRING, required=True)
144 def tier_gettests(tiername):
145     _tier.gettests(tiername)
146
147
148 @tier.command('run', help="Executes all the tests within a tier.")
149 @click.argument('tiername', type=click.STRING, required=True)
150 @click.option('-n', '--noclean', is_flag=True, default=False,
151               help='The created openstack resources by the tests'
152               'will not be cleaned after the execution.')
153 @click.option('-r', '--report', is_flag=True, default=False,
154               help='Push results to the results DataBase. Only CI Pods'
155               'have rights to do that.')
156 def tier_run(tiername, noclean, report):
157     _tier.run(tiername, noclean, report)