X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fservice.py;h=f329918fc77ce4f0ffca28b031555d6f423792bb;hb=4de60c537b56d7bf9767a8b3b027793c76bf02b5;hp=29ca13230b78b7d7dc5bae58b662de7be03ba3a4;hpb=416a753c60f1ba9545f4aa36fb45e1730046e4b2;p=osm%2FMON.git diff --git a/osm_mon/collector/service.py b/osm_mon/collector/service.py index 29ca132..f329918 100644 --- a/osm_mon/collector/service.py +++ b/osm_mon/collector/service.py @@ -61,8 +61,7 @@ class CollectorService: def _collect_vim_metrics(self, vnfr: dict, vim_account_id: str): # TODO(diazb) Add support for aws - common_db = CommonDbClient(self.conf) - vim_type = common_db.get_vim_account(vim_account_id)['vim_type'] + vim_type = self._get_vim_type(vim_account_id) if vim_type in VIM_COLLECTORS: collector = VIM_COLLECTORS[vim_type](self.conf, vim_account_id) metrics = collector.collect(vnfr) @@ -72,8 +71,7 @@ class CollectorService: log.debug("vimtype %s is not supported.", vim_type) def _collect_vim_infra_metrics(self, vim_account_id: str): - common_db = CommonDbClient(self.conf) - vim_type = common_db.get_vim_account(vim_account_id)['vim_type'] + vim_type = self._get_vim_type(vim_account_id) if vim_type in VIM_INFRA_COLLECTORS: collector = VIM_INFRA_COLLECTORS[vim_type](self.conf, vim_account_id) metrics = collector.collect() @@ -134,3 +132,11 @@ class CollectorService: while not self.queue.empty(): metrics.append(self.queue.get()) return metrics + + def _get_vim_type(self, vim_account_id: str) -> str: + common_db = CommonDbClient(self.conf) + vim_account = common_db.get_vim_account(vim_account_id) + vim_type = vim_account['vim_type'] + if 'config' in vim_account and 'vim_type' in vim_account['config']: + vim_type = vim_account['config']['vim_type'].lower() + return vim_type