4 ## Copyright (c) 2020 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
10 ## http://www.apache.org/licenses/LICENSE-2.0
12 ## Unless required by applicable law or agreed to in writing, software
13 ## distributed under the License is distributed on an "AS IS" BASIS,
14 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ## See the License for the specific language governing permissions and
16 ## limitations under the License.
22 class RapidCli(object):
24 Class to deal with runrapid cli
27 def usage(test_params):
28 print("usage: runrapid [--version] [-v]")
29 print(" [--env ENVIRONMENT_NAME]")
30 print(" [--test TEST_NAME]")
31 print(" [--map MACHINE_MAP_FILE]")
32 print(" [--runtime TIME_FOR_TEST]")
33 print(" [--configonly False|True]")
34 print(" [--log DEBUG|INFO|WARNING|ERROR|CRITICAL]")
35 print(" [-h] [--help]")
37 print("Command-line interface to runrapid")
39 print("optional arguments:")
40 print(" -v, --version Show program's version number and exit")
41 print(" --env ENVIRONMENT_NAME Parameters will be read from ENVIRONMENT_NAME. Default is %s."%test_params['environment_file'])
42 print(" --test TEST_NAME Test cases will be read from TEST_NAME. Default is %s."%test_params['test_file'])
43 print(" --map MACHINE_MAP_FILE Machine mapping will be read from MACHINE_MAP_FILE. Default is %s."%test_params['machine_map_file'])
44 print(" --runtime Specify time in seconds for 1 test run")
45 print(" --configonly If this option is specified, only upload all config files to the VMs, do not run the tests")
46 print(" --log Specify logging level for log file output, default is DEBUG")
47 print(" --screenlog Specify logging level for screen output, default is INFO")
48 print(" -h, --help Show help message and exit.")
52 def process_cli(test_params):
54 opts, args = getopt.getopt(sys.argv[1:], "vh", ["version","help", "env=", "test=", "map=", "runtime=","configonly","log=","screenlog="])
55 except getopt.GetoptError as err:
56 print("===========================================")
58 print("===========================================")
59 RapidCli.usage(test_params)
62 RapidCli.usage(test_params)
65 if opt in ["-h", "--help"]:
66 RapidCli.usage(test_params)
68 if opt in ["-v", "--version"]:
69 print("Rapid Automated Performance Indication for Dataplane "+test_params['version'])
72 test_params['environment_file'] = arg
74 test_params['test_file'] = arg
76 test_params['machine_map_file'] = arg
77 if opt in ["--runtime"]:
78 test_params['runtime'] = int(arg)
79 if opt in ["--configonly"]:
80 test_params['configonly'] = True
81 print('No actual runs, only uploading configuration files')
83 test_params['loglevel'] = arg
84 print ("Log level: "+ test_params['loglevel'])
85 if opt in ["--screenlog"]:
86 test_params['screenloglevel'] = arg
87 print ("Screen Log level: "+ test_params['screenloglevel'])
88 print ("Using '"+test_params['environment_file']+"' as name for the environment")
89 print ("Using '"+test_params['test_file']+"' for test case definition")
90 print ("Using '"+test_params['machine_map_file']+"' for machine mapping")
91 print ("Runtime: "+ str(test_params['runtime']))