Remove deprecated DEFAULT.root_helper
root_helper has been deprecated under [DEFAULT] since the quantum to neutron rename. It's time to finally remove handling it. DocImpact UpgradeImpact Partially-Implements: blueprint rootwrap-daemon-mode Change-Id: I17cd62c8763430bf3a4b67ab5e9cf5b736065133
This commit is contained in:
parent
86dbb886be
commit
fb79d9bd77
|
@ -93,8 +93,6 @@ def get_log_args(conf, log_file_name):
|
|||
|
||||
|
||||
def register_root_helper(conf):
|
||||
# The first call is to ensure backward compatibility
|
||||
conf.register_opts(ROOT_HELPER_OPTS)
|
||||
conf.register_opts(ROOT_HELPER_OPTS, 'AGENT')
|
||||
|
||||
|
||||
|
@ -119,17 +117,7 @@ def register_process_monitor_opts(conf):
|
|||
|
||||
|
||||
def get_root_helper(conf):
|
||||
root_helper = conf.AGENT.root_helper
|
||||
if root_helper != 'sudo':
|
||||
return root_helper
|
||||
|
||||
root_helper = conf.root_helper
|
||||
if root_helper != 'sudo':
|
||||
LOG.deprecated(_('DEFAULT.root_helper is deprecated! Please move '
|
||||
'root_helper configuration to [AGENT] section.'))
|
||||
return root_helper
|
||||
|
||||
return 'sudo'
|
||||
return conf.AGENT.root_helper
|
||||
|
||||
|
||||
def setup_conf():
|
||||
|
|
|
@ -473,11 +473,13 @@ class MetaInterfaceDriver(LinuxInterfaceDriver):
|
|||
|
||||
def _set_device_plugin_tag(self, network_id, device_name, namespace=None):
|
||||
plugin_tag = self._get_flavor_by_network_id(network_id)
|
||||
device = ip_lib.IPDevice(device_name, self.conf.root_helper, namespace)
|
||||
device = ip_lib.IPDevice(device_name, self.conf.AGENT.root_helper,
|
||||
namespace)
|
||||
device.link.set_alias(plugin_tag)
|
||||
|
||||
def _get_device_plugin_tag(self, device_name, namespace=None):
|
||||
device = ip_lib.IPDevice(device_name, self.conf.root_helper, namespace)
|
||||
device = ip_lib.IPDevice(device_name, self.conf.AGENT.root_helper,
|
||||
namespace)
|
||||
return device.link.alias
|
||||
|
||||
def get_device_name(self, port):
|
||||
|
|
|
@ -30,12 +30,6 @@ class TestRootHelper(base.BaseTestCase):
|
|||
conf.set_override('root_helper', 'my_root_helper', 'AGENT')
|
||||
self.assertEqual(config.get_root_helper(conf), 'my_root_helper')
|
||||
|
||||
def test_root_helper(self):
|
||||
conf = config.setup_conf()
|
||||
config.register_root_helper(conf)
|
||||
conf.set_override('root_helper', 'my_root_helper')
|
||||
self.assertEqual(config.get_root_helper(conf), 'my_root_helper')
|
||||
|
||||
def test_root_default(self):
|
||||
conf = config.setup_conf()
|
||||
config.register_root_helper(conf)
|
||||
|
|
|
@ -413,7 +413,7 @@ class TestDhcpAgent(base.BaseTestCase):
|
|||
|
||||
self.driver.existing_dhcp_networks.assert_called_once_with(
|
||||
dhcp.conf,
|
||||
cfg.CONF.root_helper
|
||||
cfg.CONF.AGENT.root_helper
|
||||
)
|
||||
|
||||
self.assertFalse(dhcp.cache.get_network_ids())
|
||||
|
@ -427,7 +427,7 @@ class TestDhcpAgent(base.BaseTestCase):
|
|||
|
||||
self.driver.existing_dhcp_networks.assert_called_once_with(
|
||||
dhcp.conf,
|
||||
cfg.CONF.root_helper
|
||||
cfg.CONF.AGENT.root_helper
|
||||
)
|
||||
|
||||
self.assertEqual(set(networks), set(dhcp.cache.get_network_ids()))
|
||||
|
@ -1190,7 +1190,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.ensure_device_is_ready.return_value = device_is_ready
|
||||
self.mock_driver.get_device_name.return_value = 'tap12345678-12'
|
||||
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
dh._set_default_route = mock.Mock()
|
||||
interface_name = dh.setup(net)
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_create_dhcp_port_raise_conflict(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
plugin.create_dhcp_port.return_value = None
|
||||
self.assertRaises(exceptions.Conflict,
|
||||
dh.setup_dhcp_port,
|
||||
|
@ -1249,7 +1249,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_create_dhcp_port_create_new(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
plugin.create_dhcp_port.return_value = fake_network.ports[0]
|
||||
dh.setup_dhcp_port(fake_network)
|
||||
plugin.assert_has_calls([
|
||||
|
@ -1263,7 +1263,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_create_dhcp_port_update_add_subnet(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
fake_network_copy = copy.deepcopy(fake_network)
|
||||
fake_network_copy.ports[0].device_id = dh.get_device_id(fake_network)
|
||||
fake_network_copy.subnets[1].enable_dhcp = True
|
||||
|
@ -1281,7 +1281,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_update_dhcp_port_raises_conflict(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
fake_network_copy = copy.deepcopy(fake_network)
|
||||
fake_network_copy.ports[0].device_id = dh.get_device_id(fake_network)
|
||||
fake_network_copy.subnets[1].enable_dhcp = True
|
||||
|
@ -1292,7 +1292,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_create_dhcp_port_no_update_or_create(self):
|
||||
plugin = mock.Mock()
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, plugin)
|
||||
fake_network_copy = copy.deepcopy(fake_network)
|
||||
fake_network_copy.ports[0].device_id = dh.get_device_id(fake_network)
|
||||
dh.setup_dhcp_port(fake_network_copy)
|
||||
|
@ -1316,7 +1316,8 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
plugin = mock.Mock()
|
||||
plugin.get_dhcp_port.return_value = fake_port
|
||||
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper,
|
||||
plugin)
|
||||
dh.destroy(fake_net, 'tap12345678-12')
|
||||
|
||||
dvr_cls.assert_called_once_with(cfg.CONF)
|
||||
|
@ -1343,7 +1344,8 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
plugin = mock.Mock()
|
||||
plugin.get_dhcp_port.return_value = fake_port
|
||||
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, plugin)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper,
|
||||
plugin)
|
||||
dh.get_interface_name(fake_net, fake_port)
|
||||
|
||||
dvr_cls.assert_called_once_with(cfg.CONF)
|
||||
|
@ -1362,7 +1364,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
with mock.patch('uuid.uuid5') as uuid5:
|
||||
uuid5.return_value = '1ae5f96c-c527-5079-82ea-371a01645457'
|
||||
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
uuid5.called_once_with(uuid.NAMESPACE_DNS, cfg.CONF.host)
|
||||
self.assertEqual(dh.get_device_id(fake_net), expected)
|
||||
|
||||
|
@ -1370,7 +1372,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
# Try with namespaces and no metadata network
|
||||
cfg.CONF.set_override('use_namespaces', True)
|
||||
cfg.CONF.set_override('enable_metadata_network', False)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
dh._set_default_route = mock.Mock()
|
||||
network = mock.Mock()
|
||||
|
||||
|
@ -1382,7 +1384,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
# No namespaces, shouldn't set default route.
|
||||
cfg.CONF.set_override('use_namespaces', False)
|
||||
cfg.CONF.set_override('enable_metadata_network', False)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
dh._set_default_route = mock.Mock()
|
||||
|
||||
dh.update(FakeV4Network(), 'tap12345678-12')
|
||||
|
@ -1392,7 +1394,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
# Meta data network enabled, don't interfere with its gateway.
|
||||
cfg.CONF.set_override('use_namespaces', True)
|
||||
cfg.CONF.set_override('enable_metadata_network', True)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
dh._set_default_route = mock.Mock()
|
||||
|
||||
dh.update(FakeV4Network(), 'ns-12345678-12')
|
||||
|
@ -1402,7 +1404,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
# For completeness
|
||||
cfg.CONF.set_override('use_namespaces', False)
|
||||
cfg.CONF.set_override('enable_metadata_network', True)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
dh._set_default_route = mock.Mock()
|
||||
|
||||
dh.update(FakeV4Network(), 'ns-12345678-12')
|
||||
|
@ -1410,7 +1412,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.assertFalse(dh._set_default_route.called)
|
||||
|
||||
def test_set_default_route(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1424,7 +1426,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
device.route.add_gateway.assert_called_once_with('192.168.0.1')
|
||||
|
||||
def test_set_default_route_no_subnet(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1438,7 +1440,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
def test_set_default_route_no_subnet_delete_gateway(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1452,7 +1454,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
def test_set_default_route_no_gateway(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1466,7 +1468,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
def test_set_default_route_do_nothing(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1479,7 +1481,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
self.assertFalse(device.route.add_gateway.called)
|
||||
|
||||
def test_set_default_route_change_gateway(self):
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
@ -1493,7 +1495,7 @@ class TestDeviceManager(base.BaseTestCase):
|
|||
|
||||
def test_set_default_route_two_subnets(self):
|
||||
# Try two subnets. Should set gateway from the first.
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.root_helper, None)
|
||||
dh = dhcp.DeviceManager(cfg.CONF, cfg.CONF.AGENT.root_helper, None)
|
||||
with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
|
||||
device = mock.Mock()
|
||||
mock_IPDevice.return_value = device
|
||||
|
|
|
@ -193,7 +193,7 @@ class BasicRouterOperationsFramework(base.BaseTestCase):
|
|||
'neutron.agent.linux.interface.NullDriver')
|
||||
self.conf.set_override('send_arp_for_ha', 1)
|
||||
self.conf.set_override('state_path', '')
|
||||
self.conf.root_helper = 'sudo'
|
||||
self.conf.AGENT.root_helper = 'sudo'
|
||||
|
||||
self.device_exists_p = mock.patch(
|
||||
'neutron.agent.linux.ip_lib.device_exists')
|
||||
|
@ -275,7 +275,7 @@ class BasicRouterOperationsFramework(base.BaseTestCase):
|
|||
'ip_address': '152.10.0.13'}],
|
||||
'id': _uuid(), 'device_id': _uuid()}]
|
||||
|
||||
self.ri_kwargs = {'root_helper': self.conf.root_helper,
|
||||
self.ri_kwargs = {'root_helper': self.conf.AGENT.root_helper,
|
||||
'agent_conf': self.conf,
|
||||
'interface_driver': mock.sentinel.interface_driver}
|
||||
|
||||
|
@ -969,7 +969,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
self.assertEqual({}, fip_statuses)
|
||||
device.addr.delete.assert_called_once_with(4, '15.1.2.3/32')
|
||||
self.mock_driver.delete_conntrack_state.assert_called_once_with(
|
||||
root_helper=self.conf.root_helper,
|
||||
root_helper=self.conf.AGENT.root_helper,
|
||||
namespace=ri.ns_name,
|
||||
ip='15.1.2.3/32')
|
||||
|
||||
|
@ -1161,7 +1161,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
service=process,
|
||||
default_cmd_callback=mock.ANY,
|
||||
namespace=ri.ns_name,
|
||||
root_helper=self.conf.root_helper,
|
||||
root_helper=self.conf.AGENT.root_helper,
|
||||
conf=self.conf,
|
||||
pid_file=None,
|
||||
cmd_addl_env=None)]
|
||||
|
|
Loading…
Reference in New Issue