@@ -125,7 +125,7 @@ def __init__(self):
125125 help_str = 'specify a database output : --db_output database_name ARG1 ARG2 ...' )
126126
127127 subparser_prom_output = ComponentSubParser ('prom' )
128- subparser_prom_output .add_argument ('a ' , 'addr ' , help = 'specify server address ' )
128+ subparser_prom_output .add_argument ('u ' , 'uri ' , help = 'specify server uri ' )
129129 subparser_prom_output .add_argument ('p' , 'port' , help = 'specify server port' , type = int )
130130 subparser_prom_output .add_argument ('M' , 'metric_name' , help = 'speify metric name' )
131131 subparser_prom_output .add_argument ('d' , 'metric_description' , help = 'specify metric description' , default = 'energy consumption' )
@@ -138,7 +138,7 @@ def __init__(self):
138138 help_str = 'specify a database output : --db_output database_name ARG1 ARG2 ...' )
139139
140140 subparser_direct_prom_output = ComponentSubParser ('direct_prom' )
141- subparser_direct_prom_output .add_argument ('a' , 'addr ' , help = 'specify server address ' )
141+ subparser_direct_prom_output .add_argument ('a' , 'uri ' , help = 'specify server uri ' )
142142 subparser_direct_prom_output .add_argument ('p' , 'port' , help = 'specify server port' , type = int )
143143 subparser_direct_prom_output .add_argument ('M' , 'metric_name' , help = 'speify metric name' )
144144 subparser_direct_prom_output .add_argument ('d' , 'metric_description' , help = 'specify metric description' , default = 'energy consumption' )
@@ -221,19 +221,19 @@ def generate(self, config):
221221
222222 actors = {}
223223
224- for component_type , components_list in config [self .component_group_name ].items ():
225- for component_name , component_config in components_list . items ():
226- try :
227- actors [component_name ] = self ._gen_actor (component_type , component_config , config )
228- except KeyError as exn :
229- msg = 'CLI error : argument ' + exn .args [0 ]
230- msg += ' needed with --output ' + component_type
231- print (msg , file = sys .stderr )
232- sys .exit ()
224+ for component_name , component_config in config [self .component_group_name ].items ():
225+ component_type = component_config [ 'type' ]
226+ try :
227+ actors [component_name ] = self ._gen_actor (component_type , component_config , config , component_name )
228+ except KeyError as exn :
229+ msg = 'CLI error : argument ' + exn .args [0 ]
230+ msg += ' needed with --output ' + component_type
231+ print (msg , file = sys .stderr )
232+ sys .exit ()
233233
234234 return actors
235235
236- def _gen_actor (self , component_name , component_config , main_config ):
236+ def _gen_actor (self , component_type , component_config , main_config , component_name ):
237237 raise NotImplementedError ()
238238
239239
@@ -289,9 +289,9 @@ def __init__(self, component_group_name):
289289 files = [] if 'files' not in db_config else db_config ['files' ]),
290290 'influxdb' : lambda db_config : InfluxDB (db_config ['uri' ], db_config ['port' ], db_config ['db' ]),
291291 'opentsdb' : lambda db_config : OpenTSDB (db_config ['uri' ], db_config ['port' ], db_config ['metric_name' ]),
292- 'prom' : lambda db_config : PrometheusDB (db_config ['port' ], db_config ['addr ' ], db_config ['metric_name' ],
292+ 'prom' : lambda db_config : PrometheusDB (db_config ['port' ], db_config ['uri ' ], db_config ['metric_name' ],
293293 db_config ['metric_description' ], self .model_factory [db_config ['model' ]], db_config ['aggregation_period' ]),
294- 'direct_prom' : lambda db_config : DirectPrometheusDB (db_config ['port' ], db_config ['addr ' ], db_config ['metric_name' ],
294+ 'direct_prom' : lambda db_config : DirectPrometheusDB (db_config ['port' ], db_config ['uri ' ], db_config ['metric_name' ],
295295 db_config ['metric_description' ], self .model_factory [db_config ['model' ]]),
296296 'virtiofs' : lambda db_config : VirtioFSDB (db_config ['vm_name_regexp' ], db_config ['root_directory_name' ], db_config ['vm_directory_name_prefix' ], db_config ['vm_directory_name_suffix' ]),
297297 }
@@ -320,11 +320,10 @@ def _generate_db(self, db_name, db_config, main_config):
320320 return self .db_factory [db_name ](db_config )
321321
322322
323- def _gen_actor (self , db_name , db_config , main_config ):
323+ def _gen_actor (self , db_name , db_config , main_config , actor_name ):
324324 db = self ._generate_db (db_name , db_config , main_config )
325325 model = self .model_factory [db_config ['model' ]]
326- name = db_config ['name' ]
327- return self ._actor_factory (name , db , model , main_config ['stream' ], main_config ['verbose' ])
326+ return self ._actor_factory (actor_name , db , model , main_config ['stream' ], main_config ['verbose' ])
328327
329328 def _actor_factory (self , name , db , model , stream_mode , level_logger ):
330329 raise NotImplementedError ()
0 commit comments