3232from powerapi .cli .parsing_manager import RootConfigParsingManager , SubgroupConfigParsingManager
3333from powerapi .cli .config_parser import store_true , extract_file_names
3434from powerapi .cli .config_parser import MissingValueException
35- from powerapi .database .prometheus .prometheus_db import DEFAULT_METRIC_DESCRIPTION , DEFAULT_MODEL_VALUE , DEFAULT_PUSHER_NAME , \
36- DEFAULT_ADDRESS
3735from powerapi .exception import BadTypeException , BadContextException , UnknownArgException
3836
3937POWERAPI_ENVIRONMENT_VARIABLE_PREFIX = 'POWERAPI_'
4240POWERAPI_PRE_PROCESSOR_ENVIRONMENT_VARIABLE_PREFIX = POWERAPI_ENVIRONMENT_VARIABLE_PREFIX + 'PRE_PROCESSOR_'
4341POWERAPI_POST_PROCESSOR_ENVIRONMENT_VARIABLE_PREFIX = POWERAPI_ENVIRONMENT_VARIABLE_PREFIX + 'POST_PROCESSOR'
4442
45- TAGS_ARGUMENT_HELP_TEXT = 'specify report tags'
46-
4743
4844class CommonCLIParsingManager (RootConfigParsingManager ):
4945 """
@@ -143,7 +139,7 @@ def __init__(self):
143139 "files" ,
144140 help_text = "specify input csv files with this format : file1,file2,file3" ,
145141 action = extract_file_names ,
146- default_value = [],
142+ is_mandatory = True
147143 )
148144 subparser_csv_input .add_argument (
149145 "m" ,
@@ -159,6 +155,12 @@ def __init__(self):
159155 subgroup_parser = subparser_csv_input
160156 )
161157
158+ subparser_json_input = SubgroupConfigParsingManager ("json" )
159+ subparser_json_input .add_argument ("n" , "name" , help_text = "Name of the puller" , default_value = "puller_json" )
160+ subparser_json_input .add_argument ("m" , "model" , help_text = "Expected report type" )
161+ subparser_json_input .add_argument ("f" , "filepath" , help_text = "Input file path" )
162+ self .add_subgroup_parser ("input" , subparser_json_input )
163+
162164 subparser_mongo_output = SubgroupConfigParsingManager ("mongodb" )
163165 subparser_mongo_output .add_argument ("u" , "uri" , help_text = "specify MongoDB uri" )
164166 subparser_mongo_output .add_argument (
@@ -183,30 +185,40 @@ def __init__(self):
183185 )
184186
185187 subparser_prometheus_output = SubgroupConfigParsingManager ("prometheus" )
186- subparser_prometheus_output .add_argument ("t" , "tags" , help_text = TAGS_ARGUMENT_HELP_TEXT )
187- subparser_prometheus_output .add_argument ("u" , "uri" , help_text = "specify server uri" ,
188- default_value = DEFAULT_ADDRESS )
189188 subparser_prometheus_output .add_argument (
190- "p" , "port" , help_text = "specify server port" , argument_type = int
189+ "n" , "name" ,
190+ help_text = "Name of the pusher" ,
191+ default_value = "pusher_prometheus"
191192 )
192193 subparser_prometheus_output .add_argument (
193- "M" , "metric-name" , help_text = "specify metric name"
194+ "m" , "model" ,
195+ help_text = "Input report type" ,
196+ default_value = "PowerReport"
194197 )
195198 subparser_prometheus_output .add_argument (
196- "d" ,
197- "metric-description" ,
198- help_text = "specify metric description" ,
199- default_value = DEFAULT_METRIC_DESCRIPTION
199+ "u" , "addr" ,
200+ help_text = "Address the HTTP server should listen on" ,
201+ default_value = "localhost"
200202 )
201-
202203 subparser_prometheus_output .add_argument (
203- "m" ,
204- "model" ,
205- help_text = "specify data type that will be stored in the database" ,
206- default_value = DEFAULT_MODEL_VALUE ,
204+ "p" , "port" ,
205+ help_text = "Port number the HTTP server should listen on" ,
206+ argument_type = int ,
207+ default_value = 8000
208+ )
209+ subparser_prometheus_output .add_argument (
210+ "M" , "metric-name" ,
211+ help_text = "Exposed metric name" ,
212+ default_value = "power_estimation_watts"
207213 )
208214 subparser_prometheus_output .add_argument (
209- "n" , "name" , help_text = "specify pusher name" , default_value = DEFAULT_PUSHER_NAME
215+ "d" , "metric-description" ,
216+ help_text = "Set the exposed metric short description" ,
217+ default_value = "Estimated power consumption of the target"
218+ )
219+ subparser_prometheus_output .add_argument (
220+ "t" , "tags" ,
221+ help_text = "List of metadata tags that will be exposed with the metrics"
210222 )
211223 self .add_subgroup_parser (
212224 subgroup_name = "output" ,
@@ -218,6 +230,7 @@ def __init__(self):
218230 "d" ,
219231 "directory" ,
220232 help_text = "specify directory where where output csv files will be writen" ,
233+ is_mandatory = True
221234 )
222235 subparser_csv_output .add_argument (
223236 "m" ,
@@ -226,7 +239,7 @@ def __init__(self):
226239 default_value = "PowerReport" ,
227240 )
228241
229- subparser_csv_output .add_argument ("t" , "tags" , help_text = TAGS_ARGUMENT_HELP_TEXT )
242+ subparser_csv_output .add_argument ("t" , "tags" , help_text = "List of tags that should be kept" )
230243 subparser_csv_output .add_argument (
231244 "n" , "name" , help_text = "specify pusher name" , default_value = "pusher_csv"
232245 )
@@ -235,6 +248,12 @@ def __init__(self):
235248 subgroup_parser = subparser_csv_output
236249 )
237250
251+ subparser_json_output = SubgroupConfigParsingManager ("json" )
252+ subparser_json_output .add_argument ("n" , "name" , help_text = "Name of the pusher" , default_value = "pusher_json" )
253+ subparser_json_output .add_argument ("m" , "model" , help_text = "Report type to be exported" )
254+ subparser_json_output .add_argument ("f" , "filepath" , help_text = "Output file path" )
255+ self .add_subgroup_parser ("output" , subparser_json_output )
256+
238257 subparser_opentsdb_output = SubgroupConfigParsingManager ("opentsdb" )
239258 subparser_opentsdb_output .add_argument ("u" , "uri" , help_text = "specify openTSDB host" )
240259 subparser_opentsdb_output .add_argument (
@@ -260,14 +279,14 @@ def __init__(self):
260279
261280 subparser_influx2_output = SubgroupConfigParsingManager ("influxdb2" )
262281 subparser_influx2_output .add_argument ("u" , "uri" , help_text = "specify InfluxDB uri" )
263- subparser_influx2_output .add_argument ("t" , "tags" , help_text = TAGS_ARGUMENT_HELP_TEXT )
282+ subparser_influx2_output .add_argument ("t" , "tags" , help_text = "List of tags that should be kept" )
264283 subparser_influx2_output .add_argument ("k" , "token" ,
265284 help_text = "specify token for accessing the database" )
266285 subparser_influx2_output .add_argument ("g" , "org" ,
267286 help_text = "specify organisation for accessing the database" )
268287
269288 subparser_influx2_output .add_argument (
270- "d " , "db " , help_text = "specify InfluxDB database name"
289+ "b " , "bucket " , help_text = "specify InfluxDB database name"
271290 )
272291 subparser_influx2_output .add_argument (
273292 "p" , "port" , help_text = "specify InfluxDB connection port" , argument_type = int
0 commit comments