Refactor ipmi agent manager

Refactor ipmi agent manager since central/compute agents have been merged.

Change-Id: I13492895dbcfcdf930e9a9407e73a86490893a03
This commit is contained in:
Lianhao Lu 2015-01-15 16:22:25 +08:00
parent c485b753b8
commit d2afd5d5cb
6 changed files with 10 additions and 103 deletions

View File

@ -1,23 +0,0 @@
#
# Copyright 2014 OpenStack Foundation
#
# 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.ipmi import manager
from ceilometer.openstack.common import service as os_service
from ceilometer import service
def main():
service.prepare_service()
os_service.launch(manager.AgentManager()).wait()

View File

@ -39,11 +39,10 @@ class MultiChoicesOpt(cfg.Opt):
kwargs['choices'] = choices
return kwargs
# todo(dbelova): add ipmi agent here as well
CLI_OPTS = [
MultiChoicesOpt('polling-namespaces',
default=['compute', 'central'],
choices=['compute', 'central'],
choices=['compute', 'central', 'ipmi'],
dest='polling_namespaces',
help='Polling namespace(s) to be used while '
'resource polling'),
@ -73,3 +72,8 @@ def main_compute():
def main_central():
service.prepare_service()
os_service.launch(manager.AgentManager(['central'])).wait()
def main_ipmi():
service.prepare_service()
os_service.launch(manager.AgentManager(['ipmi'])).wait()

View File

@ -1,23 +0,0 @@
# Copyright 2014 Intel
#
# Author: Zhai Edwin <edwin.zhai@intel.com>
#
# 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 manager
class AgentManager(manager.AgentManager):
def __init__(self):
super(AgentManager, self).__init__('ipmi')

View File

@ -20,8 +20,8 @@ import mock
from oslotest import mockpatch
import six
from ceilometer.ipmi import manager
import ceilometer.tests.base as base
from ceilometer.agent import manager
from ceilometer.tests import base
@six.add_metaclass(abc.ABCMeta)
@ -54,7 +54,7 @@ class TestPollsterBase(base.BaseTestCase):
'ceilometer.ipmi.platform.ipmi_sensor.IPMISensor',
return_value=nm))
self.mgr = manager.AgentManager()
self.mgr = manager.AgentManager(['ipmi'])
self.pollster = self.make_pollster()

View File

@ -1,51 +0,0 @@
# Copyright 2014 Intel Corp.
#
# Author: Zhai Edwin <edwin.zhai@intel.com>
#
# 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.
"""Tests for ceilometer/ipmi/manager.py
"""
from ceilometer.ipmi import manager
import mock
from oslotest import base
from ceilometer.tests.agent import agentbase
class TestManager(base.BaseTestCase):
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
mock.Mock(return_value=None))
@mock.patch('ceilometer.ipmi.pollsters.sensor.SensorPollster.__init__',
mock.Mock(return_value=None))
def test_load_plugins(self):
mgr = manager.AgentManager()
self.assertIsNotNone(list(mgr.extensions))
class TestRunTasks(agentbase.BaseAgentManagerTestCase):
@staticmethod
@mock.patch('ceilometer.ipmi.pollsters.node._Base.__init__',
mock.Mock(return_value=None))
@mock.patch('ceilometer.ipmi.pollsters.sensor.SensorPollster.__init__',
mock.Mock(return_value=None))
def create_manager():
return manager.AgentManager()
def setUp(self):
self.source_resources = True
super(TestRunTasks, self).setUp()

View File

@ -294,7 +294,7 @@ console_scripts =
ceilometer-agent-compute = ceilometer.cmd.polling:main_compute
ceilometer-polling = ceilometer.cmd.polling:main
ceilometer-agent-notification = ceilometer.cmd.agent_notification:main
ceilometer-agent-ipmi = ceilometer.cmd.agent_ipmi:main
ceilometer-agent-ipmi = ceilometer.cmd.polling:main_ipmi
ceilometer-send-sample = ceilometer.cli:send_sample
ceilometer-dbsync = ceilometer.cmd.storage:dbsync
ceilometer-expirer = ceilometer.cmd.storage:expirer