X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fvnf_collectors%2Fvio.py;h=e84f5e77682ddf3d1db36616d00060f89451aaad;hb=09bcf03e83c5863c3c0bcf47a457e70162fca94e;hp=84cebe0b6cadbe3aadb93c6f00d150f89cfdaae0;hpb=7233ad262f6c5436c713784a443596c0aa919b04;p=osm%2FMON.git diff --git a/osm_mon/collector/vnf_collectors/vio.py b/osm_mon/collector/vnf_collectors/vio.py index 84cebe0..e84f5e7 100644 --- a/osm_mon/collector/vnf_collectors/vio.py +++ b/osm_mon/collector/vnf_collectors/vio.py @@ -21,14 +21,12 @@ # contact: osslegalrouting@vmware.com ## -import json import logging -from osm_mon.collector.utils.collector import CollectorUtils from osm_mon.collector.vnf_collectors.base_vim import BaseVimCollector +from osm_mon.collector.vnf_collectors.vrops.vrops_helper import vROPS_Helper from osm_mon.core.common_db import CommonDbClient from osm_mon.core.config import Config -from osm_mon.collector.vnf_collectors.vrops.vrops_helper import vROPS_Helper log = logging.getLogger(__name__) @@ -43,13 +41,22 @@ class VIOCollector(BaseVimCollector): vrops_password=cfg['vrops_password']) def get_vim_account(self, vim_account_id: str): - vim_account_info = CollectorUtils.get_credentials(vim_account_id) - return json.loads(vim_account_info.config) + vim_account_info = self.common_db.get_vim_account(vim_account_id) + return vim_account_info['config'] def collect(self, vnfr: dict): vnfd = self.common_db.get_vnfd(vnfr['vnfd-id']) vdu_mappings = {} + # Populate extra tags for metrics + nsr_id = vnfr['nsr-id-ref'] + tags = {} + tags['ns_name'] = self.common_db.get_nsr(nsr_id)['name'] + if vnfr['_admin']['projects_read']: + tags['project_id'] = vnfr['_admin']['projects_read'][0] + else: + tags['project_id'] = '' + # Fetch the list of all known resources from vROPS. resource_list = self.vrops.get_vm_resource_list_from_vrops() @@ -61,7 +68,7 @@ class VIOCollector(BaseVimCollector): vdu = next( filter(lambda vdu: vdu['id'] == vdur['vdu-id-ref'], vnfd['vdu']) ) - if 'monitoring-param' not in vdu: + if 'monitoring-parameter' not in vdu: continue vim_id = vdur['vim-id'] @@ -77,7 +84,9 @@ class VIOCollector(BaseVimCollector): if len(vdu_mappings) != 0: return self.vrops.get_metrics(vdu_mappings=vdu_mappings, - monitoring_params=vdu['monitoring-param'], - vnfr=vnfr) + monitoring_params=vdu['monitoring-parameter'], + vnfr=vnfr, + tags=tags + ) else: return []