From fb79d9bd77735001c3e1bc135454f1441d876de4 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Sat, 31 Jan 2015 00:50:52 -0600 Subject: [PATCH] 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 --- neutron/agent/common/config.py | 14 +------- neutron/agent/linux/interface.py | 6 ++-- neutron/tests/unit/test_agent_config.py | 6 ---- neutron/tests/unit/test_dhcp_agent.py | 46 +++++++++++++------------ neutron/tests/unit/test_l3_agent.py | 8 ++--- 5 files changed, 33 insertions(+), 47 deletions(-) diff --git a/neutron/agent/common/config.py b/neutron/agent/common/config.py index 9275f5850d8..d559612b5a4 100644 --- a/neutron/agent/common/config.py +++ b/neutron/agent/common/config.py @@ -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(): diff --git a/neutron/agent/linux/interface.py b/neutron/agent/linux/interface.py index f6dd43f7728..bd1714fcc89 100644 --- a/neutron/agent/linux/interface.py +++ b/neutron/agent/linux/interface.py @@ -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): diff --git a/neutron/tests/unit/test_agent_config.py b/neutron/tests/unit/test_agent_config.py index 5e1b7f49404..cf717f66da4 100644 --- a/neutron/tests/unit/test_agent_config.py +++ b/neutron/tests/unit/test_agent_config.py @@ -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) diff --git a/neutron/tests/unit/test_dhcp_agent.py b/neutron/tests/unit/test_dhcp_agent.py index 98ec92717b7..37c527aa37c 100644 --- a/neutron/tests/unit/test_dhcp_agent.py +++ b/neutron/tests/unit/test_dhcp_agent.py @@ -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 diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index f996951c82b..2d4daaa7c7e 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -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)]