Fix bug 1276: collect metric from gnocchi first then ceilometer if it fails 39/9939/3
authoragarwalat <atul.agarwal@altran.com>
Wed, 4 Nov 2020 05:18:46 +0000 (05:18 +0000)
committeragarwalat <atul.agarwal@altran.com>
Thu, 12 Nov 2020 13:07:51 +0000 (13:07 +0000)
Change-Id: I1313f24c9881071ae52adff7a4881ac4dcc38ee6
Signed-off-by: agarwalat <atul.agarwal@altran.com>
osm_mon/collector/vnf_collectors/openstack.py

index df0424b..7de93ec 100644 (file)
@@ -142,15 +142,15 @@ class OpenstackCollector(BaseVimCollector):
 
     def _get_backend(self, vim_account: dict):
         try:
-            ceilometer = CeilometerBackend(vim_account)
-            ceilometer.client.capabilities.get()
-            log.info("Using ceilometer backend to collect metric")
-            return ceilometer
-        except (HTTPException, EndpointNotFound):
             gnocchi = GnocchiBackend(vim_account)
             gnocchi.client.metric.list(limit=1)
             log.info("Using gnocchi backend to collect metric")
             return gnocchi
+        except (HTTPException, EndpointNotFound):
+            ceilometer = CeilometerBackend(vim_account)
+            ceilometer.client.capabilities.get()
+            log.info("Using ceilometer backend to collect metric")
+            return ceilometer
 
     def _get_metric_type(self, metric_name: str, interface_name: str) -> MetricType:
         if metric_name not in INTERFACE_METRICS: