X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Fvnf_collectors%2Fvmware.py;h=be34013a72a05713ae0999289804b7799362738b;hb=refs%2Fchanges%2F08%2F7708%2F1;hp=7402afbdb4eb12167ff63edd3a8196dc0528d407;hpb=b525e6c8619d494d4e254def394cf5b62de4df4a;p=osm%2FMON.git diff --git a/osm_mon/collector/vnf_collectors/vmware.py b/osm_mon/collector/vnf_collectors/vmware.py index 7402afb..be34013 100644 --- a/osm_mon/collector/vnf_collectors/vmware.py +++ b/osm_mon/collector/vnf_collectors/vmware.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ## -# Copyright 2016-2017 VMware Inc. +# Copyright 2016-2019 VMware Inc. # This file is part of ETSI OSM # All Rights Reserved. # @@ -32,15 +32,15 @@ import six 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_metric import VnfMetric -from osm_mon.core.auth import AuthManager from osm_mon.core.common_db import CommonDbClient -from osm_mon.core.settings import Config +from osm_mon.core.config import Config log = logging.getLogger(__name__) -API_VERSION = '5.9' +API_VERSION = '27.0' PERIOD_MSEC = {'HR': 3600000, 'DAY': 86400000, @@ -62,16 +62,11 @@ METRIC_MAPPINGS = { "packets_sent": "net:Aggregate of all instances|packetsTxPerSec", } -# Disable warnings from self-signed certificates. -requests.packages.urllib3.disable_warnings() - class VMwareCollector(BaseVimCollector): - def __init__(self, vim_account_id: str): - super().__init__(vim_account_id) - self.common_db = CommonDbClient() - self.auth_manager = AuthManager() - self.granularity = self._get_granularity(vim_account_id) + def __init__(self, config: Config, vim_account_id: str): + super().__init__(config, vim_account_id) + self.common_db = CommonDbClient(config) vim_account = self.get_vim_account(vim_account_id) self.vrops_site = vim_account['vrops_site'] self.vrops_user = vim_account['vrops_user'] @@ -92,12 +87,14 @@ class VMwareCollector(BaseVimCollector): log.info("Logging into vCD org as admin.") + admin_user = None try: host = self.vcloud_site admin_user = self.admin_username admin_passwd = self.admin_password org = 'System' client = Client(host, verify_ssl_certs=False) + client.set_highest_supported_version() client.set_credentials(BasicLoginCredentials(admin_user, org, admin_passwd)) return client @@ -116,7 +113,7 @@ class VMwareCollector(BaseVimCollector): return - dict with vim account details """ vim_account = {} - vim_account_info = self.auth_manager.get_credentials(vim_account_id) + vim_account_info = CollectorUtils.get_credentials(vim_account_id) vim_account['name'] = vim_account_info.name vim_account['vim_tenant_name'] = vim_account_info.tenant_name @@ -151,21 +148,13 @@ class VMwareCollector(BaseVimCollector): return vim_account - def _get_granularity(self, vim_account_id: str): - creds = self.auth_manager.get_credentials(vim_account_id) - vim_config = json.loads(creds.config) - if 'granularity' in vim_config: - return int(vim_config['granularity']) - else: - cfg = Config.instance() - return cfg.OS_DEFAULT_GRANULARITY - def get_vm_moref_id(self, vapp_uuid): """ Method to get the moref_id of given VM arg - vapp_uuid return - VM mored_id """ + vm_moref_id = None try: if vapp_uuid: vm_details = self.get_vapp_details_rest(vapp_uuid)