Fixed the usage of self signed certificates 38/8038/1 feature5837 feature7928
authorAntonio Marsico <antonio.marsico@bt.com>
Wed, 9 Oct 2019 09:02:42 +0000 (09:02 +0000)
committerAntonio Marsico <antonio.marsico@bt.com>
Wed, 9 Oct 2019 16:04:39 +0000 (16:04 +0000)
Change-Id: I5962256da90fabd1332527d7cba422204549f7a0
Signed-off-by: Antonio Marsico <antonio.marsico@bt.com>
osm_mon/collector/infra_collectors/base_osinfra.py
osm_mon/collector/utils/openstack.py
osm_mon/collector/vnf_collectors/openstack.py

index 3b6003a..3541dbd 100644 (file)
@@ -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)
index 3a2b1b9..2ec85be 100644 (file)
@@ -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:
index 58721a9..16b9152 100644 (file)
@@ -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.metric.list(limit=1)
             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: