diff --git a/neutron/services/metering/agents/metering_agent.py b/neutron/services/metering/agents/metering_agent.py index a586a65437..8bbda5fed7 100644 --- a/neutron/services/metering/agents/metering_agent.py +++ b/neutron/services/metering/agents/metering_agent.py @@ -45,6 +45,11 @@ LOG = logging.getLogger(__name__) class MeteringPluginRpc(object): def __init__(self, host): + # NOTE(yamamoto): super.__init__() call here is not only for + # aesthetics. Because of multiple inheritances in MeteringAgent, + # it's actually necessary to initialize parent classes of + # manager.Manager correctly. + super(MeteringPluginRpc, self).__init__() target = messaging.Target(topic=topics.METERING_PLUGIN, version='1.0') self.client = n_rpc.get_client(target) diff --git a/neutron/tests/unit/services/metering/test_metering_agent.py b/neutron/tests/unit/services/metering/test_metering_agent.py index aee7f2c0c1..74bdfbac96 100644 --- a/neutron/tests/unit/services/metering/test_metering_agent.py +++ b/neutron/tests/unit/services/metering/test_metering_agent.py @@ -158,3 +158,9 @@ class TestMeteringDriver(base.BaseTestCase): {'driver': self.noop_driver, 'func': 'add_metering_label'}) + + def test_init_chain(self): + with mock.patch('neutron.openstack.common.' + 'periodic_task.PeriodicTasks.__init__') as init: + metering_agent.MeteringAgent('my agent', cfg.CONF) + init.assert_called_once_with()