]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove root_helper arg from SecurityGroupAgentRpc
authorTerry Wilson <twilson@redhat.com>
Tue, 10 Feb 2015 04:50:09 +0000 (22:50 -0600)
committerHenry Gessau <gessau@cisco.com>
Wed, 18 Feb 2015 13:24:51 +0000 (13:24 +0000)
Removes the root_helper argument from SecurityGroupAgentRpc and
removes usages of root_helper that were solely required for it.

Change-Id: If166fda9fac7718ae7bbc86756884ddea8dd70d5
Partially-Implements: blueprint rootwrap-daemon-mode

13 files changed:
neutron/agent/securitygroups_rpc.py
neutron/plugins/bigswitch/agent/restproxy_agent.py
neutron/plugins/hyperv/agent/hyperv_neutron_agent.py
neutron/plugins/nec/agent/nec_neutron_agent.py
neutron/plugins/ofagent/agent/ofa_neutron_agent.py
neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/plugins/sriovnicagent/sriov_nic_agent.py
neutron/tests/unit/bigswitch/test_restproxy_agent.py
neutron/tests/unit/nec/test_nec_agent.py
neutron/tests/unit/oneconvergence/test_nvsd_agent.py
neutron/tests/unit/openvswitch/test_ovs_tunnel.py
neutron/tests/unit/test_security_groups_rpc.py

index 0b1c549754492149b00f345bdd7774585d653f14..5fe11a236ccf1e88a750c4deb90f4f8ac1fe41d9 100644 (file)
@@ -163,11 +163,9 @@ class SecurityGroupAgentRpcCallbackMixin(object):
 class SecurityGroupAgentRpc(object):
     """Enables SecurityGroup agent support in agent implementations."""
 
-    def __init__(self, context, plugin_rpc, root_helper,
-                 defer_refresh_firewall=False):
+    def __init__(self, context, plugin_rpc, defer_refresh_firewall=False):
         self.context = context
         self.plugin_rpc = plugin_rpc
-        self.root_helper = root_helper
         self.init_firewall(defer_refresh_firewall)
 
     def init_firewall(self, defer_refresh_firewall=False):
index 85689469c61857969473d1b48ab4dcf8cfe0e115..54f5d34bf4fbe179d0c203b653678fda4aee7a2f 100644 (file)
@@ -75,13 +75,12 @@ class RestProxyAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
 
     target = oslo_messaging.Target(version='1.1')
 
-    def __init__(self, integ_br, polling_interval, root_helper, vs='ovs'):
+    def __init__(self, integ_br, polling_interval, vs='ovs'):
         super(RestProxyAgent, self).__init__()
         self.polling_interval = polling_interval
         self._setup_rpc()
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                                                     self.sg_plugin_rpc,
-                                                     root_helper)
+                                                     self.sg_plugin_rpc)
         if vs == 'ivs':
             self.int_br = IVSBridge(integ_br)
         else:
@@ -158,8 +157,7 @@ def main():
 
     integ_br = cfg.CONF.RESTPROXYAGENT.integration_bridge
     polling_interval = cfg.CONF.RESTPROXYAGENT.polling_interval
-    root_helper = cfg.CONF.AGENT.root_helper
-    bsnagent = RestProxyAgent(integ_br, polling_interval, root_helper,
+    bsnagent = RestProxyAgent(integ_br, polling_interval,
                               cfg.CONF.RESTPROXYAGENT.virtual_switch_type)
     bsnagent.daemon_loop()
     sys.exit(0)
index 3752956290e2e0689d3d51738c3ec122352eb30c..58580f5bd43ee5978189c2804d5004a8accf30a6 100644 (file)
@@ -81,10 +81,7 @@ config.register_agent_state_opts_helper(cfg.CONF)
 class HyperVSecurityAgent(sg_rpc.SecurityGroupAgentRpc):
 
     def __init__(self, context, plugin_rpc):
-        # Note: as rootwrap is not supported on HyperV, root_helper is
-        # passed in as None.
-        super(HyperVSecurityAgent, self).__init__(context, plugin_rpc,
-                                                  root_helper=None)
+        super(HyperVSecurityAgent, self).__init__(context, plugin_rpc)
         if sg_rpc.is_firewall_enabled():
             self._setup_rpc()
 
index f50887ff4e672806a7efa813a743e49e66d076f2..23b7d543fb4e14a0df44c5e46305f80dfcf77ce6 100755 (executable)
@@ -94,11 +94,10 @@ class SecurityGroupAgentRpcCallback(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
 
 class NECNeutronAgent(object):
 
-    def __init__(self, integ_br, root_helper, polling_interval):
+    def __init__(self, integ_br, polling_interval):
         '''Constructor.
 
         :param integ_br: name of the integration bridge.
-        :param root_helper: utility to use when running shell cmds.
         :param polling_interval: interval (secs) to check the bridge.
         '''
         self.int_br = ovs_lib.OVSBridge(integ_br)
@@ -116,9 +115,9 @@ class NECNeutronAgent(object):
             'agent_type': q_const.AGENT_TYPE_NEC,
             'start_flag': True}
 
-        self.setup_rpc(root_helper)
+        self.setup_rpc()
 
-    def setup_rpc(self, root_helper):
+    def setup_rpc(self):
         self.host = socket.gethostname()
         self.agent_id = 'nec-q-agent.%s' % self.host
         LOG.info(_LI("RPC agent_id: %s"), self.agent_id)
@@ -130,7 +129,7 @@ class NECNeutronAgent(object):
         self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
         self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                self.sg_plugin_rpc, root_helper)
+                self.sg_plugin_rpc)
 
         # RPC network init
         # Handle updates from service
@@ -221,10 +220,9 @@ def main():
 
     # Determine which agent type to use.
     integ_br = config.OVS.integration_bridge
-    root_helper = config.AGENT.root_helper
     polling_interval = config.AGENT.polling_interval
 
-    agent = NECNeutronAgent(integ_br, root_helper, polling_interval)
+    agent = NECNeutronAgent(integ_br, polling_interval)
 
     # Start everything.
     agent.daemon_loop()
index f4877a50758473a2b1d740e2fcc75cdc0e2ea468..fc0706413dca0e647e54b932f7570c655d4d5887 100644 (file)
@@ -180,7 +180,7 @@ class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
     target = oslo_messaging.Target(version='1.1')
 
     def __init__(self, ryuapp, integ_br, local_ip,
-                 bridge_mappings, interface_mappings, root_helper,
+                 bridge_mappings, interface_mappings,
                  polling_interval, tunnel_types=None):
         """Constructor.
 
@@ -191,7 +191,6 @@ class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                (deprecated)
         :param interface_mappings: mappings from physical network name to
                interface.
-        :param root_helper: utility to use when running shell cmds.
         :param polling_interval: interval (secs) to poll DB.
         :param tunnel_types: A list of tunnel types to enable support for in
                the agent. If set, will automatically set enable_tunneling to
@@ -199,7 +198,6 @@ class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         """
         super(OFANeutronAgent, self).__init__()
         self.ryuapp = ryuapp
-        self.root_helper = root_helper
         # TODO(yamamoto): Remove this VLAN leftover
         self.available_local_vlans = set(xrange(ofa_const.LOCAL_VLAN_MIN,
                                                 ofa_const.LOCAL_VLAN_MAX))
@@ -246,8 +244,7 @@ class OFANeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
 
         # Security group agent support
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                self.sg_plugin_rpc, self.root_helper,
-                defer_refresh_firewall=True)
+                self.sg_plugin_rpc, defer_refresh_firewall=True)
         # Initialize iteration counter
         self.iter_num = 0
 
@@ -906,7 +903,6 @@ def create_agent_config_map(config):
         local_ip=config.OVS.local_ip,
         interface_mappings=interface_mappings,
         bridge_mappings=bridge_mappings,
-        root_helper=config.AGENT.root_helper,
         polling_interval=config.AGENT.polling_interval,
         tunnel_types=config.AGENT.tunnel_types,
     )
index d0e0764ba2d865f7cb32df520c4a3b23458b2e5d..26c0685e867083324d79bb3c5a2af5c5bb1a8ad5 100644 (file)
@@ -75,11 +75,10 @@ class NVSDNeutronAgent(object):
     #   1.1 Support Security Group RPC
     target = oslo_messaging.Target(version='1.1')
 
-    def __init__(self, integ_br, root_helper, polling_interval):
+    def __init__(self, integ_br, polling_interval):
         super(NVSDNeutronAgent, self).__init__()
         self.int_br = ovs_lib.OVSBridge(integ_br)
         self.polling_interval = polling_interval
-        self.root_helper = root_helper
         self.setup_rpc()
         self.ports = set()
 
@@ -93,8 +92,7 @@ class NVSDNeutronAgent(object):
         self.context = n_context.get_admin_context_without_session()
         self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                                                     self.sg_plugin_rpc,
-                                                     self.root_helper)
+                                                     self.sg_plugin_rpc)
 
         # RPC network init
         # Handle updates from service
@@ -150,9 +148,8 @@ def main():
     common_config.setup_logging()
 
     integ_br = config.AGENT.integration_bridge
-    root_helper = config.AGENT.root_helper
     polling_interval = config.AGENT.polling_interval
-    agent = NVSDNeutronAgent(integ_br, root_helper, polling_interval)
+    agent = NVSDNeutronAgent(integ_br, polling_interval)
     LOG.info(_LI("NVSD Agent initialized successfully, now running... "))
 
     # Start everything.
index d94c1dc0ed978ec84a1681c214ae6b4c1b06d724..307c770f18cd32abdad8e8c46d06b4f433b75af3 100644 (file)
@@ -253,7 +253,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
 
         # Security group agent support
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                self.sg_plugin_rpc, root_helper, defer_refresh_firewall=True)
+                self.sg_plugin_rpc, defer_refresh_firewall=True)
 
         # Initialize iteration counter
         self.iter_num = 0
@@ -894,7 +894,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         self.phys_brs = {}
         self.int_ofports = {}
         self.phys_ofports = {}
-        ip_wrapper = ip_lib.IPWrapper(self.root_helper)
+        ip_wrapper = ip_lib.IPWrapper()
         ovs = ovs_lib.BaseOVS()
         ovs_bridges = ovs.get_bridges()
         for physical_network, bridge in bridge_mappings.iteritems():
@@ -923,9 +923,8 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
             self.int_br.delete_port(int_if_name)
             br.delete_port(phys_if_name)
             if self.use_veth_interconnection:
-                if ip_lib.device_exists(int_if_name, self.root_helper):
-                    ip_lib.IPDevice(int_if_name,
-                                    self.root_helper).link.delete()
+                if ip_lib.device_exists(int_if_name):
+                    ip_lib.IPDevice(int_if_name).link.delete()
                     # Give udev a chance to process its rules here, to avoid
                     # race conditions between commands launched by udev rules
                     # and the subsequent call to ip_wrapper.add_veth
index ad4bfb7c33c2c9d768c490c36d47e97c93b68ddc..53cce664f4c9cacfb0280ce4d7edb7e06047c845 100644 (file)
@@ -90,7 +90,7 @@ class SriovNicSwitchAgent(object):
         self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
         self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
         self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
-                self.sg_plugin_rpc, self.root_helper)
+                self.sg_plugin_rpc)
         self._setup_rpc()
         # Initialize iteration counter
         self.iter_num = 0
index e9e8f77eec7dff35bf13a5fd5b2f36b3380319fa..665d0f089cb933b4dd0cebca4892fa52c734515b 100644 (file)
@@ -51,7 +51,7 @@ class TestRestProxyAgentOVS(BaseAgentTestCase):
     def mock_agent(self):
         mock_context = mock.Mock(return_value='abc')
         self.context.get_admin_context_without_session = mock_context
-        return self.mod_agent.RestProxyAgent('int-br', 2, 'helper')
+        return self.mod_agent.RestProxyAgent('int-br', 2)
 
     def mock_port_update(self, **kwargs):
         agent = self.mock_agent()
@@ -160,8 +160,7 @@ class TestRestProxyAgent(BaseAgentTestCase):
     def mock_main(self):
         cfg_attrs = {'CONF.RESTPROXYAGENT.integration_bridge': 'integ_br',
                      'CONF.RESTPROXYAGENT.polling_interval': 5,
-                     'CONF.RESTPROXYAGENT.virtual_switch_type': 'ovs',
-                     'CONF.AGENT.root_helper': 'helper'}
+                     'CONF.RESTPROXYAGENT.virtual_switch_type': 'ovs'}
         with contextlib.nested(
             mock.patch(AGENTMOD + '.cfg', **cfg_attrs),
             mock.patch(AGENTMOD + '.config.init'),
@@ -181,6 +180,6 @@ class TestRestProxyAgent(BaseAgentTestCase):
             self.assertRaises(SystemExit, self.mock_main)
 
         mock_agent.assert_has_calls([
-            mock.call('integ_br', 5, 'helper', 'ovs'),
+            mock.call('integ_br', 5, 'ovs'),
             mock.call().daemon_loop()
         ])
index bf8d0173ba44f8733b9c98aa0fe97b347db72a56..2b7559cfa74f726d1cf77e5c69b5447ddc787fda 100644 (file)
@@ -49,9 +49,7 @@ class TestNecAgentBase(base.BaseTestCase):
             mock.patch('neutron.agent.rpc.PluginReportStateAPI')
         ) as (get_datapath_id, gethostname,
               loopingcall, state_rpc_api):
-            kwargs = {'integ_br': 'integ_br',
-                      'root_helper': 'dummy_wrapper',
-                      'polling_interval': 1}
+            kwargs = {'integ_br': 'integ_br', 'polling_interval': 1}
             self.agent = nec_neutron_agent.NECNeutronAgent(**kwargs)
             self.loopingcall = loopingcall
             self.state_rpc_api = state_rpc_api
@@ -336,13 +334,12 @@ class TestNecAgentMain(base.BaseTestCase):
             mock.patch.object(nec_neutron_agent, 'config')
         ) as (agent, common_config, cfg):
             cfg.OVS.integration_bridge = 'br-int-x'
-            cfg.AGENT.root_helper = 'dummy-helper'
             cfg.AGENT.polling_interval = 10
 
             nec_neutron_agent.main()
 
             self.assertTrue(common_config.setup_logging.called)
             agent.assert_has_calls([
-                mock.call('br-int-x', 'dummy-helper', 10),
+                mock.call('br-int-x', 10),
                 mock.call().daemon_loop()
             ])
index cb49f98654c997c1b7c6400938090bf61b06c79f..309ba24149aac7d2da6e39084deea052ef92a54b 100644 (file)
@@ -41,13 +41,12 @@ class TestOneConvergenceAgentBase(base.BaseTestCase):
                        'FixedIntervalLoopingCall'),
         ) as (loopingcall):
             kwargs = {'integ_br': 'integration_bridge',
-                      'root_helper': 'dummy_wrapper',
                       'polling_interval': 5}
             context = mock.Mock()
             self.agent = nvsd_neutron_agent.NVSDNeutronAgent(**kwargs)
             sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
             self.sg_agent = sg_rpc.SecurityGroupAgentRpc(context,
-                    sg_plugin_rpc, 'dummy_wrapper')
+                    sg_plugin_rpc)
             self.callback_nvsd = nvsd_neutron_agent.NVSDAgentRpcCallback(
                 context, self.agent, self.sg_agent)
             self.loopingcall = loopingcall
@@ -164,13 +163,12 @@ class TestOneConvergenceAgentMain(base.BaseTestCase):
             mock.patch.object(nvsd_neutron_agent, 'config')
         ) as (agent, common_config, config):
             config.AGENT.integration_bridge = 'br-int-dummy'
-            config.AGENT.root_helper = 'root-helper'
             config.AGENT.polling_interval = 5
 
             nvsd_neutron_agent.main()
 
             self.assertTrue(common_config.setup_logging.called)
             agent.assert_has_calls([
-                mock.call('br-int-dummy', 'root-helper', 5),
+                mock.call('br-int-dummy', 5),
                 mock.call().daemon_loop()
             ])
index d2ffc4ed89d7779f4aff7429069403e54b7ea08b..42071ebd71d22b9ba627d7afb468a5bda80797c6 100644 (file)
@@ -241,7 +241,7 @@ class TunnelTest(base.BaseTestCase):
         self.device_exists_expected = []
 
         self.ipdevice_expected = []
-        self.ipwrapper_expected = [mock.call('sudo')]
+        self.ipwrapper_expected = [mock.call()]
 
         self.get_bridges_expected = [mock.call(), mock.call()]
 
@@ -657,15 +657,15 @@ class TunnelTestUseVethInterco(TunnelTest):
         ]
 
         self.device_exists_expected = [
-            mock.call('int-%s' % self.MAP_TUN_BRIDGE, 'sudo'),
+            mock.call('int-%s' % self.MAP_TUN_BRIDGE),
         ]
 
         self.ipdevice_expected = [
-            mock.call('int-%s' % self.MAP_TUN_BRIDGE, 'sudo'),
+            mock.call('int-%s' % self.MAP_TUN_BRIDGE),
             mock.call().link.delete()
         ]
         self.ipwrapper_expected = [
-            mock.call('sudo'),
+            mock.call(),
             mock.call().add_veth('int-%s' % self.MAP_TUN_BRIDGE,
                                  'phy-%s' % self.MAP_TUN_BRIDGE)
         ]
index a647e221c4876c76de3d4c4eabf5a12faf32adfa..9f87287ad3e1ee28637971dfbc985f1b8d001ac3 100644 (file)
@@ -1113,7 +1113,7 @@ class SecurityGroupAgentRpcTestCaseForNoneDriver(base.BaseTestCase):
     def test_init_firewall_with_none_driver(self):
         set_enable_security_groups(False)
         agent = sg_rpc.SecurityGroupAgentRpc(
-                context=None, plugin_rpc=mock.Mock(), root_helper=None)
+                context=None, plugin_rpc=mock.Mock())
         self.assertEqual(agent.firewall.__class__.__name__,
                          'NoopFirewallDriver')
 
@@ -1123,7 +1123,7 @@ class BaseSecurityGroupAgentRpcTestCase(base.BaseTestCase):
         super(BaseSecurityGroupAgentRpcTestCase, self).setUp()
         set_firewall_driver(FIREWALL_NOOP_DRIVER)
         self.agent = sg_rpc.SecurityGroupAgentRpc(
-                context=None, plugin_rpc=mock.Mock(), root_helper='sudo',
+                context=None, plugin_rpc=mock.Mock(),
                 defer_refresh_firewall=defer_refresh_firewall)
         mock.patch('neutron.agent.linux.iptables_manager').start()
         self.default_firewall = self.agent.firewall
@@ -2503,7 +2503,6 @@ class TestSecurityGroupAgentWithIptables(base.BaseTestCase):
 
     def setUp(self, defer_refresh_firewall=False, test_rpc_v1_1=True):
         super(TestSecurityGroupAgentWithIptables, self).setUp()
-        config.register_root_helper(cfg.CONF)
         config.register_iptables_opts(cfg.CONF)
         set_firewall_driver(self.FIREWALL_DRIVER)
         cfg.CONF.set_override('enable_ipset', False, group='SECURITYGROUP')
@@ -2511,9 +2510,8 @@ class TestSecurityGroupAgentWithIptables(base.BaseTestCase):
 
         self.rpc = mock.Mock()
         self.agent = sg_rpc.SecurityGroupAgentRpc(
-                context=None, plugin_rpc=self.rpc, root_helper='sudo',
+                context=None, plugin_rpc=self.rpc,
                 defer_refresh_firewall=defer_refresh_firewall)
-        self.root_helper = 'sudo'
 
         if test_rpc_v1_1:
             self.rpc.security_group_info_for_devices.side_effect = (