Add local node resource for IPMI pollsters

Each pollster should have some resources for polling, but IPMI
pollster is an exception that talk with local IPMI HW directly by
ipmitool. Local node resource is faked resource that stands for
endpoint of localhost. With it, IPMI pollsters can be handled in the
same way as others.

Change-Id: Icda81ffa2334b764e7b508f26efd031f2a863e64
This commit is contained in:
Edwin Zhai 2015-01-29 17:16:41 +08:00
parent 0bcbaf6d93
commit b7426c545c
5 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,21 @@
# Copyright 2015 Intel
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from ceilometer.agent import plugin_base
class LocalNodeDiscovery(plugin_base.DiscoveryBase):
def discover(self, manager, param=None):
"""Return local node as resource."""
return ['local_host']

View File

@ -36,7 +36,7 @@ class _Base(plugin_base.PollsterBase):
@property
def default_discovery(self):
return None
return 'local_node'
@abc.abstractmethod
def read_data(self):

View File

@ -39,7 +39,7 @@ class SensorPollster(plugin_base.PollsterBase):
@property
def default_discovery(self):
return None
return 'local_node'
@staticmethod
def _get_sensor_types(data, sensor_type):

View File

@ -58,7 +58,7 @@ class TestPollsterBase(base.BaseTestCase):
def _verify_metering(self, length, expected_vol=None, node=None):
cache = {}
resources = {}
resources = ['local_host']
samples = list(self.pollster.get_samples(self.mgr, cache, resources))
self.assertEqual(length, len(samples))

View File

@ -97,6 +97,7 @@ ceilometer.discover =
local_instances = ceilometer.compute.discovery:InstanceDiscovery
endpoint = ceilometer.agent.discovery.endpoint:EndpointDiscovery
tenant = ceilometer.agent.discovery.tenant:TenantDiscovery
local_node = ceilometer.agent.discovery.localnode:LocalNodeDiscovery
lb_pools = ceilometer.network.services.discovery:LBPoolsDiscovery
lb_vips = ceilometer.network.services.discovery:LBVipsDiscovery
lb_members = ceilometer.network.services.discovery:LBMembersDiscovery