]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove remaining root_helper args from plugins
authorTerry Wilson <twilson@redhat.com>
Wed, 11 Feb 2015 05:04:34 +0000 (23:04 -0600)
committerTerry Wilson <twilson@redhat.com>
Fri, 13 Feb 2015 15:01:59 +0000 (09:01 -0600)
Change-Id: If5ba0a6fd63640f97f7eccca839dbbbf26bf3f89
Partially-Implements: blueprint rootwrap-daemon-mode

21 files changed:
neutron/plugins/bigswitch/config.py
neutron/plugins/cisco/cfg_agent/cfg_agent.py
neutron/plugins/cisco/common/config.py
neutron/plugins/ibm/agent/sdnve_neutron_agent.py
neutron/plugins/ibm/common/config.py
neutron/plugins/linuxbridge/common/config.py
neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py
neutron/plugins/ml2/drivers/cisco/apic/config.py
neutron/plugins/mlnx/agent/config.py
neutron/plugins/mlnx/agent/eswitch_neutron_agent.py
neutron/plugins/nec/common/config.py
neutron/plugins/ofagent/common/config.py
neutron/plugins/oneconvergence/lib/config.py
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/plugins/openvswitch/common/config.py
neutron/plugins/sriovnicagent/common/config.py
neutron/plugins/sriovnicagent/eswitch_manager.py
neutron/plugins/sriovnicagent/pci_lib.py
neutron/plugins/sriovnicagent/sriov_nic_agent.py
neutron/tests/unit/sriovnicagent/test_eswitch_manager.py
neutron/tests/unit/sriovnicagent/test_sriov_neutron_agent.py

index 422488d60e1101660c4e650b61d12e9c7781a8f7..1c74fd871c3d463d25a51c0f3577cf0365214dd5 100644 (file)
@@ -19,7 +19,6 @@ This module manages configuration options
 
 from oslo_config import cfg
 
-from neutron.agent.common import config as agconfig
 from neutron.common import utils
 from neutron.extensions import portbindings
 
@@ -115,4 +114,3 @@ def register_config():
     cfg.CONF.register_opts(router_opts, "ROUTER")
     cfg.CONF.register_opts(nova_opts, "NOVA")
     cfg.CONF.register_opts(agent_opts, "RESTPROXYAGENT")
-    agconfig.register_root_helper(cfg.CONF)
index 5953e9383dcaa2285b016d93993798c22b6bf0c0..4e108d58b5bb56a20cb1f212debb6859e6d38843 100644 (file)
@@ -331,7 +331,6 @@ def main(manager='neutron.plugins.cisco.cfg_agent.'
     conf = cfg.CONF
     conf.register_opts(CiscoCfgAgent.OPTS, "cfg_agent")
     config.register_agent_state_opts_helper(conf)
-    config.register_root_helper(conf)
     conf.register_opts(interface.OPTS)
     conf.register_opts(external_process.OPTS)
     common_config.init(sys.argv[1:])
index b2364a50be2c53701f45af44a65794196e47b71f..99676b63140890e6c10f3d5982f912b0e5366174 100644 (file)
@@ -14,8 +14,6 @@
 
 from oslo_config import cfg
 
-from neutron.agent.common import config
-
 
 cisco_opts = [
     cfg.StrOpt('vlan_name_prefix', default='q-',
@@ -78,7 +76,6 @@ cisco_n1k_opts = [
 
 cfg.CONF.register_opts(cisco_opts, "CISCO")
 cfg.CONF.register_opts(cisco_n1k_opts, "CISCO_N1K")
-config.register_root_helper(cfg.CONF)
 
 # shortcuts
 CONF = cfg.CONF
index 72d39ad11245c5e6e9e0222e8c6318eec182d018..00e7adc83b4f4e786cd3b194eb1ba290313b585e 100644 (file)
@@ -56,7 +56,7 @@ class SdnveNeutronAgent(object):
     target = oslo_messaging.Target(version='1.1')
 
     def __init__(self, integ_br, interface_mappings,
-                 info, root_helper, polling_interval,
+                 info, polling_interval,
                  controller_ip, reset_br, out_of_band):
         '''The agent initialization.
 
@@ -65,13 +65,11 @@ class SdnveNeutronAgent(object):
         :param integ_br: name of the integration bridge.
         :param interface_mappings: interfaces to physical networks.
         :param info: local IP address of this hypervisor.
-        :param root_helper: utility to use when running shell cmds.
         :param polling_interval: interval (secs) to poll DB.
         :param controller_ip: Ip address of SDN-VE controller.
         '''
 
         super(SdnveNeutronAgent, self).__init__()
-        self.root_helper = root_helper
         self.int_bridge_name = integ_br
         self.controller_ip = controller_ip
         self.interface_mappings = interface_mappings
@@ -193,7 +191,7 @@ class SdnveNeutronAgent(object):
                      {'physical_network': physical_network,
                       'interface': interface})
             # Connect the physical interface to the bridge
-            if not ip_lib.device_exists(interface, self.root_helper):
+            if not ip_lib.device_exists(interface):
                 LOG.error(_LE("Interface %(interface)s for physical network "
                               "%(physical_network)s does not exist. Agent "
                               "terminated!"),
@@ -241,7 +239,6 @@ def create_agent_config_map(config):
         'interface_mappings': interface_mappings,
         'controller_ip': controller_ip,
         'info': config.SDNVE.info,
-        'root_helper': config.SDNVE_AGENT.root_helper,
         'polling_interval': config.SDNVE_AGENT.polling_interval,
         'reset_br': config.SDNVE.reset_bridge,
         'out_of_band': config.SDNVE.out_of_band}
index 45b27f89b99438bca4e002a8ae1b7ff55e2d5b60..73580bca7631d4e07f9777d4d8dbab2c361ae4cd 100644 (file)
@@ -61,8 +61,6 @@ sdnve_opts = [
 sdnve_agent_opts = [
     cfg.IntOpt('polling_interval', default=2,
                help=_("Agent polling interval if necessary.")),
-    cfg.StrOpt('root_helper', default='sudo',
-               help=_("Using root helper.")),
     cfg.BoolOpt('rpc', default=True,
                 help=_("Whether to use rpc.")),
 
index db5b605e297acd2f87c4774112ca26978e06c9c5..7184e7af8224111967d9689c509c8a35c7a00f82 100644 (file)
@@ -70,4 +70,3 @@ cfg.CONF.register_opts(vxlan_opts, "VXLAN")
 cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE")
 cfg.CONF.register_opts(agent_opts, "AGENT")
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
index 3487d5e070c9352383f29592bdcc14003f7747e5..10fbc377da12bbc763708f766ad374e90d29ee3a 100644 (file)
@@ -169,7 +169,6 @@ class ApicTopologyAgent(manager.Manager):
         self.lldpcmd = None
         self.peers = {}
         self.port_desc_re = map(re.compile, ACI_PORT_DESCR_FORMATS)
-        self.root_helper = self.conf.root_helper
         self.service_agent = ApicTopologyServiceNotifierApi()
         self.state = None
         self.state_agent = None
@@ -248,7 +247,7 @@ class ApicTopologyAgent(manager.Manager):
 
     def _get_peers(self):
         peers = {}
-        lldpkeys = utils.execute(self.lldpcmd, self.root_helper)
+        lldpkeys = utils.execute(self.lldpcmd, run_as_root=True)
         for line in lldpkeys.splitlines():
             if '=' not in line:
                 continue
index 0c55625eeaab321424728374679076f6970b8964..c5edc0b8309c2955a516cd30f919b1fe0cc25d9d 100644 (file)
 from oslo_config import cfg
 
 
-DEFAULT_ROOT_HELPER = ('sudo /usr/local/bin/neutron-rootwrap '
-                       '/etc/neutron/rootwrap.conf')
-
-
 # oslo_config limits ${var} expansion to global variables
 # That is why apic_system_id as a global variable
 global_opts = [
@@ -76,9 +72,6 @@ apic_opts = [
     cfg.StrOpt('apic_vlan_range',
                default='2:4093',
                help=_("Range of VLAN's to be used for Openstack")),
-    cfg.StrOpt('root_helper',
-               default=DEFAULT_ROOT_HELPER,
-               help=_("Setup root helper as rootwrap or sudo")),
     cfg.IntOpt('apic_sync_interval',
                default=0,
                help=_("Synchronization interval in seconds")),
index dbbba93b64fd9bd3e3cbe301ed146223f2f2bdeb..39c618ca6397195d05dd1d0b308ab4d0dd208699 100644 (file)
@@ -53,4 +53,3 @@ agent_opts = [
 cfg.CONF.register_opts(eswitch_opts, "ESWITCH")
 cfg.CONF.register_opts(agent_opts, "AGENT")
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
index 36e3226d72b99a1efff09b819389cb1ca60803d5..19c610640fe6d604c096d7be2928cefeecc6d769 100644 (file)
@@ -41,10 +41,9 @@ def main():
         sys.exit(1)
     LOG.info(_LI("Interface mappings: %s"), interface_mappings)
 
-    root_helper = cfg.CONF.AGENT.root_helper
     try:
         agent = mlnx_eswitch_neutron_agent.MlnxEswitchNeutronAgent(
-            interface_mappings, root_helper)
+            interface_mappings)
     except Exception as e:
         LOG.error(_LE("Failed on Agent initialisation : %s. "
                       "Agent terminated!"), e)
index 55f093ebddc4827c708eca50337a9e05e2c74c8a..429dc3783c8b46a88cb5170544fe8914f94b2364 100644 (file)
@@ -73,7 +73,6 @@ cfg.CONF.register_opts(agent_opts, "AGENT")
 cfg.CONF.register_opts(ofc_opts, "OFC")
 cfg.CONF.register_opts(provider_opts, "PROVIDER")
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
 
 # shortcuts
 CONF = cfg.CONF
index 149ffb834263e999b2d28b303f8faed204fc8c9d..2d6d495457661a5a83218f0c484a6f9694099417 100644 (file)
@@ -34,4 +34,3 @@ cfg.CONF.register_opts(ovs_config.ovs_opts, 'OVS')
 cfg.CONF.register_opts(ovs_config.agent_opts, 'AGENT')
 cfg.CONF.register_opts(agent_opts, 'AGENT')
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
index 1baf8d307fbffd0a9c9e084d525f24dd6240070d..78bb41adb363df4c480a7d070633ab922461cfc2 100644 (file)
@@ -17,8 +17,6 @@
 
 from oslo_config import cfg
 
-from neutron.agent.common import config
-
 
 NVSD_OPT = [
     cfg.StrOpt('nvsd_ip',
@@ -51,7 +49,5 @@ agent_opts = [
 cfg.CONF.register_opts(NVSD_OPT, "nvsd")
 cfg.CONF.register_opts(agent_opts, "AGENT")
 
-config.register_root_helper(cfg.CONF)
-
 CONF = cfg.CONF
 AGENT = cfg.CONF.AGENT
index 89955c8b990c712b464bad4324c6e8321416d9a7..79b6659d9be54c1198f2fdaa49f45e16549f5a02 100644 (file)
@@ -28,6 +28,7 @@ from oslo_config import cfg
 import oslo_messaging
 from six import moves
 
+from neutron.agent.common import config
 from neutron.agent import l2population_rpc
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import ovs_lib
@@ -1570,6 +1571,7 @@ def create_agent_config_map(config):
 
 def main():
     cfg.CONF.register_opts(ip_lib.OPTS)
+    config.register_root_helper(cfg.CONF)
     common_config.init(sys.argv[1:])
     common_config.setup_logging()
     q_utils.log_opt_values(LOG)
index 5266b3c3dc8169df68829b3fe286e1c54e7f88f7..5923291763ed13acdd5f37bf78445c08f7c181a2 100644 (file)
@@ -89,4 +89,3 @@ agent_opts = [
 cfg.CONF.register_opts(ovs_opts, "OVS")
 cfg.CONF.register_opts(agent_opts, "AGENT")
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
index ff18d4d1ba30b0d575369c2c36e1da20e38ad418..07e42462f4bc09f83314acb421b01346e2e15489 100644 (file)
@@ -85,4 +85,3 @@ sriov_nic_opts = [
 cfg.CONF.register_opts(agent_opts, 'AGENT')
 cfg.CONF.register_opts(sriov_nic_opts, 'SRIOV_NIC')
 config.register_agent_state_opts_helper(cfg.CONF)
-config.register_root_helper(cfg.CONF)
index 0f8e1080846a7a70b6bb5b0da7b2526aebe83735..0397ffb005817a350d5dd77dfe9da4d55e61ee20 100644 (file)
@@ -93,19 +93,17 @@ class EmbSwitch(object):
     @ivar pci_dev_wrapper: pci device wrapper
     """
 
-    def __init__(self, phys_net, dev_name, exclude_devices, root_helper):
+    def __init__(self, phys_net, dev_name, exclude_devices):
         """Constructor
 
         @param phys_net: physical network
         @param dev_name: network device name
         @param exclude_devices: list of pci slots to exclude
-        @param root_helper: root permissions helper
         """
         self.phys_net = phys_net
         self.dev_name = dev_name
         self.pci_slot_map = {}
-        self.pci_dev_wrapper = pci_lib.PciDeviceIPWrapper(dev_name,
-                                                          root_helper)
+        self.pci_dev_wrapper = pci_lib.PciDeviceIPWrapper(dev_name)
 
         self._load_devices(exclude_devices)
 
@@ -182,7 +180,7 @@ class EmbSwitch(object):
 class ESwitchManager(object):
     """Manages logical Embedded Switch entities for physical network."""
 
-    def __init__(self, device_mappings, exclude_devices, root_helper):
+    def __init__(self, device_mappings, exclude_devices):
         """Constructor.
 
         Create Embedded Switch logical entities for all given device mappings,
@@ -190,7 +188,6 @@ class ESwitchManager(object):
         """
         self.emb_switches_map = {}
         self.pci_slot_map = {}
-        self.root_helper = root_helper
 
         self._discover_devices(device_mappings, exclude_devices)
 
@@ -266,8 +263,7 @@ class ESwitchManager(object):
                                     exclude_devices.get(dev_name, set()))
 
     def _create_emb_switch(self, phys_net, dev_name, exclude_devices):
-        embedded_switch = EmbSwitch(phys_net, dev_name, exclude_devices,
-                                    self.root_helper)
+        embedded_switch = EmbSwitch(phys_net, dev_name, exclude_devices)
         self.emb_switches_map[phys_net] = embedded_switch
         for pci_slot in embedded_switch.get_pci_slot_list():
             self.pci_slot_map[pci_slot] = embedded_switch
index 0a818d924986a8ae6d0f78752e916b3bb8cc49e9..917ac3eb12e4cefa00f163f7d6563d0e79fa5edd 100644 (file)
@@ -40,8 +40,8 @@ class PciDeviceIPWrapper(ip_lib.IPWrapper):
         ENABLE = "enable"
         DISABLE = "disable"
 
-    def __init__(self, dev_name, root_helper=None):
-        super(ip_lib.IPWrapper, self).__init__(root_helper=root_helper)
+    def __init__(self, dev_name):
+        super(ip_lib.IPWrapper, self).__init__()
         self.dev_name = dev_name
 
     def get_assigned_macs(self, vf_list):
index 53cce664f4c9cacfb0280ce4d7edb7e06047c845..7928417bb24e0475ff6ea74408ac921f8c33f566 100644 (file)
@@ -68,10 +68,9 @@ class SriovNicSwitchRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
 
 class SriovNicSwitchAgent(object):
     def __init__(self, physical_devices_mappings, exclude_devices,
-                 polling_interval, root_helper):
+                 polling_interval):
 
         self.polling_interval = polling_interval
-        self.root_helper = root_helper
         self.setup_eswitch_mgr(physical_devices_mappings,
                                exclude_devices)
         configurations = {'device_mappings': physical_devices_mappings}
@@ -130,9 +129,7 @@ class SriovNicSwitchAgent(object):
             LOG.exception(_LE("Failed reporting state!"))
 
     def setup_eswitch_mgr(self, device_mappings, exclude_devices={}):
-        self.eswitch_mgr = esm.ESwitchManager(device_mappings,
-                                              exclude_devices,
-                                              self.root_helper)
+        self.eswitch_mgr = esm.ESwitchManager(device_mappings, exclude_devices)
 
     def scan_devices(self, registered_devices, updated_devices):
         curr_devices = self.eswitch_mgr.get_assigned_devices()
@@ -337,12 +334,10 @@ def main():
     LOG.info(_LI("Exclude Devices: %s"), exclude_devices)
 
     polling_interval = cfg.CONF.AGENT.polling_interval
-    root_helper = cfg.CONF.AGENT.root_helper
     try:
         agent = SriovNicSwitchAgent(device_mappings,
                                     exclude_devices,
-                                    polling_interval,
-                                    root_helper)
+                                    polling_interval)
     except exc.SriovNicError:
         LOG.exception(_LE("Agent Initialization Failed"))
         raise SystemExit(1)
index f0c19adc0cc174f3c9b767f645fc16dd180aa9cd..3aacb722c75c3c5e638869ad3a2b374cf9c42ef1 100644 (file)
@@ -44,7 +44,7 @@ class TestCreateESwitchManager(base.BaseTestCase):
                        return_value=True)):
 
             with testtools.ExpectedException(exc.InvalidDeviceError):
-                esm.ESwitchManager(device_mappings, None, None)
+                esm.ESwitchManager(device_mappings, None)
 
     def test_create_eswitch_mgr_ok(self):
         device_mappings = {'physnet1': 'p6p1'}
@@ -56,7 +56,7 @@ class TestCreateESwitchManager(base.BaseTestCase):
                        "PciOsWrapper.is_assigned_vf",
                        return_value=True)):
 
-            esm.ESwitchManager(device_mappings, None, None)
+            esm.ESwitchManager(device_mappings, None)
 
 
 class TestESwitchManagerApi(base.BaseTestCase):
@@ -79,7 +79,7 @@ class TestESwitchManagerApi(base.BaseTestCase):
             mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
                        "PciOsWrapper.is_assigned_vf",
                        return_value=True)):
-            self.eswitch_mgr = esm.ESwitchManager(device_mappings, None, None)
+            self.eswitch_mgr = esm.ESwitchManager(device_mappings, None)
 
     def test_get_assigned_devices(self):
         with mock.patch("neutron.plugins.sriovnicagent.eswitch_manager."
@@ -206,7 +206,7 @@ class TestEmbSwitch(base.BaseTestCase):
                         "PciOsWrapper.scan_vf_devices",
                         return_value=self.SCANNED_DEVICES):
             self.emb_switch = esm.EmbSwitch(self.PHYS_NET, self.DEV_NAME,
-                                            exclude_devices, None)
+                                            exclude_devices)
 
     def test_get_assigned_devices(self):
         with contextlib.nested(
index fa96dda542960d752f1505ff2a74dde2eef3c06c..2fc6ad09edbab3c75d264851771c1c448a0ac944 100644 (file)
@@ -47,10 +47,10 @@ class TestSriovAgent(base.BaseTestCase):
                    'FixedIntervalLoopingCall',
                    new=MockFixedIntervalLoopingCall)
 
-        self.agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0, None)
+        self.agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0)
 
     def test_treat_devices_removed_with_existed_device(self):
-        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0, None)
+        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0)
         devices = [DEVICE_MAC]
         with mock.patch.object(agent.plugin_rpc,
                                "update_device_down") as fn_udd:
@@ -64,7 +64,7 @@ class TestSriovAgent(base.BaseTestCase):
                 self.assertTrue(fn_udd.called)
 
     def test_treat_devices_removed_with_not_existed_device(self):
-        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0, None)
+        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0)
         devices = [DEVICE_MAC]
         with mock.patch.object(agent.plugin_rpc,
                                "update_device_down") as fn_udd:
@@ -78,7 +78,7 @@ class TestSriovAgent(base.BaseTestCase):
                 self.assertTrue(fn_udd.called)
 
     def test_treat_devices_removed_failed(self):
-        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0, None)
+        agent = sriov_nic_agent.SriovNicSwitchAgent({}, {}, 0)
         devices = [DEVICE_MAC]
         with mock.patch.object(agent.plugin_rpc,
                                "update_device_down") as fn_udd: