X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_mon%2Fcollector%2Fservice.py;h=f329918fc77ce4f0ffca28b031555d6f423792bb;hb=4de60c537b56d7bf9767a8b3b027793c76bf02b5;hp=072482234d785448feca029b3fb191063bd37b21;hpb=a97bdb3eafa4f3d07d61d32635f7f36f5cc36c58;p=osm%2FMON.git diff --git a/osm_mon/collector/service.py b/osm_mon/collector/service.py index 0724822..f329918 100644 --- a/osm_mon/collector/service.py +++ b/osm_mon/collector/service.py @@ -1,11 +1,34 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Whitestack, LLC +# ************************************************************* + +# This file is part of OSM Monitoring module +# All Rights Reserved to Whitestack, LLC + +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# For those usages not covered by the Apache License, Version 2.0 please +# contact: bdiaz@whitestack.com or glavado@whitestack.com +## import logging import multiprocessing from typing import List from osm_mon.collector.infra_collectors.onos import OnosInfraCollector from osm_mon.collector.infra_collectors.openstack import OpenstackInfraCollector +from osm_mon.collector.infra_collectors.vio import VIOInfraCollector +from osm_mon.collector.infra_collectors.vmware import VMwareInfraCollector from osm_mon.collector.metric import Metric -from osm_mon.collector.utils import CollectorUtils from osm_mon.collector.vnf_collectors.juju import VCACollector from osm_mon.collector.vnf_collectors.openstack import OpenstackCollector from osm_mon.collector.vnf_collectors.vio import VIOCollector @@ -21,7 +44,9 @@ VIM_COLLECTORS = { "vio": VIOCollector } VIM_INFRA_COLLECTORS = { - "openstack": OpenstackInfraCollector + "openstack": OpenstackInfraCollector, + "vmware": VMwareInfraCollector, + "vio": VIOInfraCollector } SDN_INFRA_COLLECTORS = { "onos": OnosInfraCollector @@ -36,7 +61,7 @@ class CollectorService: def _collect_vim_metrics(self, vnfr: dict, vim_account_id: str): # TODO(diazb) Add support for aws - vim_type = CollectorUtils.get_vim_type(vim_account_id) + 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) @@ -46,7 +71,7 @@ class CollectorService: log.debug("vimtype %s is not supported.", vim_type) def _collect_vim_infra_metrics(self, vim_account_id: str): - vim_type = CollectorUtils.get_vim_type(vim_account_id) + 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() @@ -107,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