+
+ def _build_client(self, vim_account_id):
+ if self.backend == 'ceilometer':
+ return self._build_ceilometer_client(vim_account_id)
+ elif self.backend == 'gnocchi':
+ return self._build_gnocchi_client(vim_account_id)
+ else:
+ raise Exception('Unknown metric backend: %s', self.backend)
+
+ def _get_backend(self, vim_account_id):
+ try:
+ gnocchi = self._build_gnocchi_client(vim_account_id)
+ gnocchi.resource.list(limit=1)
+ return 'gnocchi'
+ except EndpointNotFound:
+ try:
+ ceilometer = self._build_ceilometer_client(vim_account_id)
+ ceilometer.resources.list(limit=1)
+ return 'ceilometer'
+ except Exception:
+ log.exception('Error trying to determine metric backend')
+ raise Exception('Could not determine metric backend')