From: Antonio Marsico Date: Wed, 9 Oct 2019 09:02:42 +0000 (+0000) Subject: Fixed the usage of self signed certificates X-Git-Tag: v6.0.4rc1~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=08b9710289f14638fb9e84dea2010b5116a52816;p=osm%2FMON.git Fixed the usage of self signed certificates Change-Id: I5962256da90fabd1332527d7cba422204549f7a0 Signed-off-by: Antonio Marsico --- diff --git a/osm_mon/collector/infra_collectors/base_osinfra.py b/osm_mon/collector/infra_collectors/base_osinfra.py index 3b6003a..3541dbd 100644 --- a/osm_mon/collector/infra_collectors/base_osinfra.py +++ b/osm_mon/collector/infra_collectors/base_osinfra.py @@ -24,7 +24,6 @@ from typing import List from keystoneclient.v3 import client as keystone_client from novaclient import client as nova_client -from novaclient import v2 as nova_client_v2 from osm_mon.collector.infra_collectors.base_vim import BaseVimInfraCollector from osm_mon.collector.metric import Metric @@ -88,6 +87,6 @@ class BaseOpenStackInfraCollector(BaseVimInfraCollector): sess = OpenstackUtils.get_session(vim_account) return keystone_client.Client(session=sess) - def _build_nova_client(self, vim_account: dict) -> nova_client_v2.Client: + def _build_nova_client(self, vim_account: dict) -> nova_client.Client: sess = OpenstackUtils.get_session(vim_account) return nova_client.Client("2", session=sess) diff --git a/osm_mon/collector/utils/openstack.py b/osm_mon/collector/utils/openstack.py index 3a2b1b9..2ec85be 100644 --- a/osm_mon/collector/utils/openstack.py +++ b/osm_mon/collector/utils/openstack.py @@ -35,7 +35,10 @@ class OpenstackUtils: user_domain_name = 'Default' if 'config' in creds: vim_config = creds['config'] - verify_ssl = False if 'insecure' in vim_config and vim_config['insecure'] else True + if 'insecure' in vim_config and vim_config['insecure']: + verify_ssl = False + if 'ca_cert' in vim_config: + verify_ssl = vim_config['ca_cert'] if 'project_domain_name' in vim_config: project_domain_name = vim_config['project_domain_name'] if 'user_domain_name' in vim_config: diff --git a/osm_mon/collector/vnf_collectors/openstack.py b/osm_mon/collector/vnf_collectors/openstack.py index f63d0b2..787321a 100644 --- a/osm_mon/collector/vnf_collectors/openstack.py +++ b/osm_mon/collector/vnf_collectors/openstack.py @@ -24,9 +24,9 @@ from enum import Enum from typing import List import gnocchiclient.exceptions -from ceilometerclient.v2 import client as ceilometer_client +from ceilometerclient import client as ceilometer_client +from ceilometerclient.exc import HTTPException from gnocchiclient.v1 import client as gnocchi_client -from keystoneauth1.exceptions.catalog import EndpointNotFound from keystoneclient.v3 import client as keystone_client from neutronclient.v2_0 import client as neutron_client @@ -120,7 +120,7 @@ class OpenstackCollector(BaseVimCollector): ceilometer = CeilometerBackend(vim_account) ceilometer.client.capabilities.get() return ceilometer - except EndpointNotFound: + except HTTPException: gnocchi = GnocchiBackend(vim_account) gnocchi.client.status.get() return gnocchi @@ -220,7 +220,7 @@ class CeilometerBackend(OpenstackBackend): def _build_ceilometer_client(self, vim_account: dict) -> ceilometer_client.Client: sess = OpenstackUtils.get_session(vim_account) - return ceilometer_client.Client(session=sess) + return ceilometer_client.Client("2", session=sess) def collect_metric(self, metric_type: MetricType, metric_name: str, resource_id: str, interface_name: str): if metric_type != MetricType.INSTANCE: