X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Finfra_collectors%2Fvmware.py;h=0f40d4858d777ca1e8636c1baaa6f9ff6b83eec8;hb=c2a005ed542b4bc3bdb7bd47bf3b34b1110e1e0d;hp=00f9bf7e026d7cac534938e42448566ec20e9b8b;hpb=059f91127fe77c40681f4bfcb4ceb4158914807d;p=osm%2FMON.git diff --git a/osm_mon/collector/infra_collectors/vmware.py b/osm_mon/collector/infra_collectors/vmware.py index 00f9bf7..0f40d48 100644 --- a/osm_mon/collector/infra_collectors/vmware.py +++ b/osm_mon/collector/infra_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. # @@ -23,24 +23,23 @@ import logging from typing import List - from xml.etree import ElementTree as XmlElementTree + +import requests from pyvcloud.vcd.client import BasicLoginCredentials from pyvcloud.vcd.client import Client -from osm_mon.collector.utils import CollectorUtils from osm_mon.collector.infra_collectors.base_vim import BaseVimInfraCollector from osm_mon.collector.metric import Metric from osm_mon.core.common_db import CommonDbClient from osm_mon.core.config import Config -import requests -import json log = logging.getLogger(__name__) API_VERSION = '27.0' class VMwareInfraCollector(BaseVimInfraCollector): + def __init__(self, config: Config, vim_account_id: str): super().__init__(config, vim_account_id) self.vim_account_id = vim_account_id @@ -70,6 +69,7 @@ class VMwareInfraCollector(BaseVimInfraCollector): 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 @@ -84,19 +84,23 @@ class VMwareInfraCollector(BaseVimInfraCollector): return - dict with vim account details """ vim_account = {} - 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 - vim_account['vim_type'] = vim_account_info.type - vim_account['vim_url'] = vim_account_info.url - vim_account['org_user'] = vim_account_info.user - vim_account['org_password'] = vim_account_info.password - vim_account['vim_uuid'] = vim_account_info.uuid - - vim_config = json.loads(vim_account_info.config) + vim_account_info = self.common_db.get_vim_account(vim_account_id) + + vim_account['name'] = vim_account_info['name'] + vim_account['vim_tenant_name'] = vim_account_info['vim_tenant_name'] + vim_account['vim_type'] = vim_account_info['vim_type'] + vim_account['vim_url'] = vim_account_info['vim_url'] + vim_account['org_user'] = vim_account_info['vim_user'] + vim_account['org_password'] = self.common_db.decrypt_vim_password(vim_account_info['vim_password'], + vim_account_info['schema_version'], + vim_account_id) + vim_account['vim_uuid'] = vim_account_info['_id'] + + vim_config = vim_account_info['config'] vim_account['admin_username'] = vim_config['admin_username'] - vim_account['admin_password'] = vim_config['admin_password'] + vim_account['admin_password'] = self.common_db.decrypt_vim_password(vim_config['admin_password'], + vim_account_info['schema_version'], + vim_account_id) if vim_config['orgname'] is not None: vim_account['orgname'] = vim_config['orgname']