X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fcollector.py;h=f4ffba4853ad9f2a2d0ea0d01c2624ee95a3e098;hb=refs%2Fchanges%2F83%2F7283%2F1;hp=8b0d425913704ce094a427c01b046577d10bd7bc;hpb=616fde7e4671be3da07ea59765c311c26bfe2e16;p=osm%2FMON.git diff --git a/osm_mon/collector/collector.py b/osm_mon/collector/collector.py index 8b0d425..f4ffba4 100644 --- a/osm_mon/collector/collector.py +++ b/osm_mon/collector/collector.py @@ -27,10 +27,12 @@ import time import peewee from osm_mon.collector.backends.prometheus import PrometheusBackend +from osm_mon.collector.infra_collectors.onos import OnosInfraCollector from osm_mon.collector.infra_collectors.openstack import OpenstackInfraCollector from osm_mon.collector.vnf_collectors.juju import VCACollector from osm_mon.collector.vnf_collectors.openstack import OpenstackCollector from osm_mon.collector.vnf_collectors.vmware import VMwareCollector +from osm_mon.collector.vnf_collectors.vio import VIOCollector from osm_mon.core.common_db import CommonDbClient from osm_mon.core.config import Config from osm_mon.core.database import DatabaseManager @@ -39,11 +41,15 @@ log = logging.getLogger(__name__) VIM_COLLECTORS = { "openstack": OpenstackCollector, - "vmware": VMwareCollector + "vmware": VMwareCollector, + "vio": VIOCollector } VIM_INFRA_COLLECTORS = { "openstack": OpenstackInfraCollector } +SDN_INFRA_COLLECTORS = { + "onos": OnosInfraCollector +} METRIC_BACKENDS = [ PrometheusBackend ] @@ -72,7 +78,7 @@ class Collector: log.exception("Error collecting metrics") def _collect_vim_metrics(self, vnfr: dict, vim_account_id: str): - # TODO(diazb) Add support for vrops and aws + # TODO(diazb) Add support for aws database_manager = DatabaseManager(self.conf) vim_type = database_manager.get_vim_type(vim_account_id) if vim_type in VIM_COLLECTORS: @@ -94,6 +100,17 @@ class Collector: else: log.debug("vimtype %s is not supported.", vim_type) + def _collect_sdnc_infra_metrics(self, sdnc_id: str): + common_db = CommonDbClient(self.conf) + sdn_type = common_db.get_sdnc(sdnc_id)['type'] + if sdn_type in SDN_INFRA_COLLECTORS: + collector = SDN_INFRA_COLLECTORS[sdn_type](self.conf, sdnc_id) + metrics = collector.collect() + for metric in metrics: + self.queue.put(metric) + else: + log.debug("sdn_type %s is not supported.", sdn_type) + def _collect_vca_metrics(self, vnfr: dict): log.debug('_collect_vca_metrics') log.debug('vnfr: %s', vnfr) @@ -123,6 +140,12 @@ class Collector: args=(vim['_id'],)) processes.append(p) p.start() + sdncs = self.common_db.get_sdncs() + for sdnc in sdncs: + p = multiprocessing.Process(target=self._collect_sdnc_infra_metrics, + args=(sdnc['_id'],)) + processes.append(p) + p.start() for process in processes: process.join(timeout=10) metrics = []