Beispiel #1
0
 def get_samples(self, manager, cache, resources):
     self._inspection_duration = self._record_poll_time()
     for instance in resources:
         try:
             polled_time, result = self._inspect_cached(
                 cache, instance, self._inspection_duration)
             if not result:
                 continue
             for stats in self.aggregate_method(result):
                 yield self._stats_to_sample(instance, stats, polled_time)
         except NoVolumeException:
             # FIXME(sileht): This should be a removed... but I will
             # not change the test logic for now
             LOG.warning("%(name)s statistic in not available for "
                         "instance %(instance_id)s" % {
                             'name': self.sample_name,
                             'instance_id': instance.id
                         })
         except virt_inspector.InstanceNotFoundException as err:
             # Instance was deleted while getting samples. Ignore it.
             LOG.debug('Exception while getting samples %s', err)
         except virt_inspector.InstanceShutOffException as e:
             LOG.debug(
                 'Instance %(instance_id)s was shut off while '
                 'getting sample of %(name)s: %(exc)s', {
                     'instance_id': instance.id,
                     'name': self.sample_name,
                     'exc': e
                 })
         except virt_inspector.NoDataException as e:
             LOG.warning(
                 'Cannot inspect data of %(pollster)s for '
                 '%(instance_id)s, non-fatal reason: %(exc)s', {
                     'pollster': self.__class__.__name__,
                     'instance_id': instance.id,
                     'exc': e
                 })
             raise plugin_base.PollsterPermanentError(resources)
         except ceilometer.NotImplementedError:
             # Selected inspector does not implement this pollster.
             LOG.debug(
                 '%(inspector)s does not provide data for '
                 '%(pollster)s', {
                     'inspector': self.inspector.__class__.__name__,
                     'pollster': self.__class__.__name__
                 })
             raise plugin_base.PollsterPermanentError(resources)
         except Exception as err:
             LOG.error('Could not get %(name)s events for %(id)s: %(e)s', {
                 'name': self.sample_name,
                 'id': instance.id,
                 'e': err
             },
                       exc_info=True)
Beispiel #2
0
    def get_samples(self, manager, cache, resources):
        # Only one resource for Node Manager pollster
        try:
            stats = self.read_data(cache)
        except nmexcept.IPMIException:
            self.polling_failures += 1
            LOG.warning(_('Polling %(name)s failed for %(cnt)s times!')
                        % ({'name': self.NAME,
                            'cnt': self.polling_failures}))
            if 0 <= self.conf.ipmi.polling_retry < self.polling_failures:
                LOG.warning(_('Pollster for %s is disabled!') % self.NAME)
                raise plugin_base.PollsterPermanentError(resources)
            else:
                return

        self.polling_failures = 0

        metadata = {
            'node': self.conf.host
        }

        if stats:
            data = self.get_value(stats)

            yield sample.Sample(
                name=self.NAME,
                type=self.TYPE,
                unit=self.UNIT,
                volume=data,
                user_id=None,
                project_id=None,
                resource_id=self.conf.host,
                resource_metadata=metadata)
Beispiel #3
0
    def get_samples(self, manager, cache, resources):
        func = super(TestPollsterPollingException, self).get_samples
        sample = func(manager=manager, cache=cache, resources=resources)

        # Raise polling exception after 2 times
        self.polling_failures += 1
        if self.polling_failures > 2:
            raise plugin_base.PollsterPermanentError(resources)

        return sample
Beispiel #4
0
    def get_samples(self, manager, cache, resources):
        # Only one resource for IPMI pollster
        try:
            stats = self.ipmi.read_sensor_any(self.METRIC)
        except ipmiexcept.IPMIException:
            self.polling_failures += 1
            LOG.warning(_(
                'Polling %(mtr)s sensor failed for %(cnt)s times!')
                % ({'mtr': self.METRIC,
                    'cnt': self.polling_failures}))
            if 0 <= self.conf.ipmi.polling_retry < self.polling_failures:
                LOG.warning(_('Pollster for %s is disabled!') % self.METRIC)
                raise plugin_base.PollsterPermanentError(resources)
            else:
                return

        self.polling_failures = 0

        sensor_type_data = self._get_sensor_types(stats, self.METRIC)

        for sensor_data in sensor_type_data:
            # Continue if sensor_data is not parseable.
            try:
                sensor_reading = sensor_data['Sensor Reading']
                sensor_id = sensor_data['Sensor ID']
            except KeyError:
                continue

            if not parser.validate_reading(sensor_reading):
                continue

            try:
                volume, unit = parser.parse_reading(sensor_reading)
            except parser.InvalidSensorData:
                continue

            resource_id = '%(host)s-%(sensor-id)s' % {
                'host': self.conf.host,
                'sensor-id': parser.transform_id(sensor_id)
            }

            metadata = {
                'node': self.conf.host
            }

            yield sample.Sample(
                name='hardware.ipmi.%s' % self.METRIC.lower(),
                type=sample.TYPE_GAUGE,
                unit=unit,
                volume=volume,
                user_id=None,
                project_id=None,
                resource_id=resource_id,
                resource_metadata=metadata)
Beispiel #5
0
    def _get_account_info(self, ksclient, tenants):
        endpoint = self._get_endpoint(self.conf, ksclient)
        if not endpoint:
            raise StopIteration()

        try:
            from ceilometer.objectstore import rgw_client as c_rgw_client
            rgw_client = c_rgw_client.RGWAdminClient(endpoint,
                                                     self.access_key,
                                                     self.secret)
        except ImportError:
            raise plugin_base.PollsterPermanentError(tenants)

        for t in tenants:
            api_method = 'get_%s' % self.METHOD
            yield t.id, getattr(rgw_client, api_method)(t.id)