X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fvnf_collectors%2Fvmware.py;h=b974d76ee42d83bd3421f3b1c00ef49a1e0a18ed;hb=4b9f79e2820a011f6ebbba7fb92cdc120b364650;hp=329d61d880fa3ffa8b491bd6d8e12a5ded625180;hpb=7233ad262f6c5436c713784a443596c0aa919b04;p=osm%2FMON.git diff --git a/osm_mon/collector/vnf_collectors/vmware.py b/osm_mon/collector/vnf_collectors/vmware.py index 329d61d..b974d76 100644 --- a/osm_mon/collector/vnf_collectors/vmware.py +++ b/osm_mon/collector/vnf_collectors/vmware.py @@ -21,7 +21,6 @@ # contact: osslegalrouting@vmware.com ## -import json import logging import traceback from xml.etree import ElementTree as XmlElementTree @@ -30,11 +29,10 @@ import requests from pyvcloud.vcd.client import BasicLoginCredentials from pyvcloud.vcd.client import Client -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__) @@ -86,11 +84,11 @@ class VMwareCollector(BaseVimCollector): return - dict with vim account details """ vim_account = {} - vim_account_info = CollectorUtils.get_credentials(vim_account_id) + vim_account_info = self.common_db.get_vim_account(vim_account_id) - vim_account['vim_url'] = vim_account_info.url + vim_account['vim_url'] = vim_account_info['vim_url'] - vim_config = json.loads(vim_account_info.config) + vim_config = vim_account_info['config'] vim_account['admin_username'] = vim_config['admin_username'] vim_account['admin_password'] = vim_config['admin_password'] vim_account['vrops_site'] = vim_config['vrops_site'] @@ -182,6 +180,15 @@ class VMwareCollector(BaseVimCollector): 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() @@ -216,6 +223,8 @@ class VMwareCollector(BaseVimCollector): if len(vdu_mappings) != 0: return self.vrops.get_metrics(vdu_mappings=vdu_mappings, monitoring_params=vdu['monitoring-param'], - vnfr=vnfr) + vnfr=vnfr, + tags=tags + ) else: return []