Fix metering iptables driver doesn't read root_helper param
With this patch the iptables driver instantiates the iptables_manager with the correct root_helper value. Change-Id: I9a37bae92dc12a8a78ea2d1b9fc5e995321ca322 Closes-bug: #1256036
This commit is contained in:
parent
b074d56412
commit
b2008b5fdb
@ -77,7 +77,7 @@ class RouterWithMetering(object):
|
||||
self.router = router
|
||||
self.root_helper = config.get_root_helper(self.conf)
|
||||
self.iptables_manager = iptables_manager.IptablesManager(
|
||||
root_helper=self.conf.root_helper,
|
||||
root_helper=self.root_helper,
|
||||
namespace=self.ns_name(),
|
||||
binary_name=WRAP_NAME)
|
||||
self.metering_labels = {}
|
||||
|
@ -36,7 +36,7 @@ class IptablesDriverTestCase(base.BaseTestCase):
|
||||
self.addCleanup(self.utils_exec_p.stop)
|
||||
self.iptables_cls_p = mock.patch(
|
||||
'neutron.agent.linux.iptables_manager.IptablesManager')
|
||||
iptables_cls = self.iptables_cls_p.start()
|
||||
self.iptables_cls = self.iptables_cls_p.start()
|
||||
self.addCleanup(self.iptables_cls_p.stop)
|
||||
self.iptables_inst = mock.Mock()
|
||||
self.v4filter_inst = mock.Mock()
|
||||
@ -45,15 +45,31 @@ class IptablesDriverTestCase(base.BaseTestCase):
|
||||
self.v6filter_inst.chains = []
|
||||
self.iptables_inst.ipv4 = {'filter': self.v4filter_inst}
|
||||
self.iptables_inst.ipv6 = {'filter': self.v6filter_inst}
|
||||
iptables_cls.return_value = self.iptables_inst
|
||||
self.iptables_cls.return_value = self.iptables_inst
|
||||
cfg.CONF.set_override('interface_driver',
|
||||
'neutron.agent.linux.interface.NullDriver')
|
||||
self.router_info_inst = mock.Mock()
|
||||
self.router_info_inst.iptables_manager = self.iptables_inst
|
||||
|
||||
cfg.CONF.set_override('root_helper',
|
||||
'fake_sudo',
|
||||
'AGENT')
|
||||
self.metering = iptables_driver.IptablesMeteringDriver('metering',
|
||||
cfg.CONF)
|
||||
|
||||
def test_root_helper(self):
|
||||
routers = [{'_metering_labels': [
|
||||
{'id': 'c5df2fe5-c600-4a2a-b2f4-c0fb6df73c83',
|
||||
'rules': []}],
|
||||
'admin_state_up': True,
|
||||
'gw_port_id': '7d411f48-ecc7-45e0-9ece-3b5bdb54fcee',
|
||||
'id': '473ec392-1711-44e3-b008-3251ccfc5099',
|
||||
'name': 'router1',
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '6c5f5d2a1fa2441e88e35422926f48e8'}]
|
||||
self.metering.add_metering_label(None, routers)
|
||||
|
||||
self.iptables_cls.assert_called_with(root_helper='fake_sudo',
|
||||
namespace=mock.ANY,
|
||||
binary_name=mock.ANY)
|
||||
|
||||
def test_add_metering_label(self):
|
||||
routers = [{'_metering_labels': [
|
||||
{'id': 'c5df2fe5-c600-4a2a-b2f4-c0fb6df73c83',
|
||||
|
Loading…
Reference in New Issue
Block a user