From: Terry Wilson Date: Wed, 11 Feb 2015 05:04:34 +0000 (-0600) Subject: Remove remaining root_helper args from plugins X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b2f996346f738e5843a1206d331d866c3d2d22c2;p=openstack-build%2Fneutron-build.git Remove remaining root_helper args from plugins Change-Id: If5ba0a6fd63640f97f7eccca839dbbbf26bf3f89 Partially-Implements: blueprint rootwrap-daemon-mode --- diff --git a/neutron/plugins/bigswitch/config.py b/neutron/plugins/bigswitch/config.py index 422488d60..1c74fd871 100644 --- a/neutron/plugins/bigswitch/config.py +++ b/neutron/plugins/bigswitch/config.py @@ -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) diff --git a/neutron/plugins/cisco/cfg_agent/cfg_agent.py b/neutron/plugins/cisco/cfg_agent/cfg_agent.py index 5953e9383..4e108d58b 100644 --- a/neutron/plugins/cisco/cfg_agent/cfg_agent.py +++ b/neutron/plugins/cisco/cfg_agent/cfg_agent.py @@ -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:]) diff --git a/neutron/plugins/cisco/common/config.py b/neutron/plugins/cisco/common/config.py index b2364a50b..99676b631 100644 --- a/neutron/plugins/cisco/common/config.py +++ b/neutron/plugins/cisco/common/config.py @@ -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 diff --git a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py index 72d39ad11..00e7adc83 100644 --- a/neutron/plugins/ibm/agent/sdnve_neutron_agent.py +++ b/neutron/plugins/ibm/agent/sdnve_neutron_agent.py @@ -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} diff --git a/neutron/plugins/ibm/common/config.py b/neutron/plugins/ibm/common/config.py index 45b27f89b..73580bca7 100644 --- a/neutron/plugins/ibm/common/config.py +++ b/neutron/plugins/ibm/common/config.py @@ -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.")), diff --git a/neutron/plugins/linuxbridge/common/config.py b/neutron/plugins/linuxbridge/common/config.py index db5b605e2..7184e7af8 100644 --- a/neutron/plugins/linuxbridge/common/config.py +++ b/neutron/plugins/linuxbridge/common/config.py @@ -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) diff --git a/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py b/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py index 3487d5e07..10fbc377d 100644 --- a/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py +++ b/neutron/plugins/ml2/drivers/cisco/apic/apic_topology.py @@ -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 diff --git a/neutron/plugins/ml2/drivers/cisco/apic/config.py b/neutron/plugins/ml2/drivers/cisco/apic/config.py index 0c55625ee..c5edc0b83 100644 --- a/neutron/plugins/ml2/drivers/cisco/apic/config.py +++ b/neutron/plugins/ml2/drivers/cisco/apic/config.py @@ -16,10 +16,6 @@ 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")), diff --git a/neutron/plugins/mlnx/agent/config.py b/neutron/plugins/mlnx/agent/config.py index dbbba93b6..39c618ca6 100644 --- a/neutron/plugins/mlnx/agent/config.py +++ b/neutron/plugins/mlnx/agent/config.py @@ -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) diff --git a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py index 36e3226d7..19c610640 100644 --- a/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py +++ b/neutron/plugins/mlnx/agent/eswitch_neutron_agent.py @@ -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) diff --git a/neutron/plugins/nec/common/config.py b/neutron/plugins/nec/common/config.py index 55f093ebd..429dc3783 100644 --- a/neutron/plugins/nec/common/config.py +++ b/neutron/plugins/nec/common/config.py @@ -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 diff --git a/neutron/plugins/ofagent/common/config.py b/neutron/plugins/ofagent/common/config.py index 149ffb834..2d6d49545 100644 --- a/neutron/plugins/ofagent/common/config.py +++ b/neutron/plugins/ofagent/common/config.py @@ -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) diff --git a/neutron/plugins/oneconvergence/lib/config.py b/neutron/plugins/oneconvergence/lib/config.py index 1baf8d307..78bb41adb 100644 --- a/neutron/plugins/oneconvergence/lib/config.py +++ b/neutron/plugins/oneconvergence/lib/config.py @@ -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 diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index 89955c8b9..79b6659d9 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -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) diff --git a/neutron/plugins/openvswitch/common/config.py b/neutron/plugins/openvswitch/common/config.py index 5266b3c3d..592329176 100644 --- a/neutron/plugins/openvswitch/common/config.py +++ b/neutron/plugins/openvswitch/common/config.py @@ -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) diff --git a/neutron/plugins/sriovnicagent/common/config.py b/neutron/plugins/sriovnicagent/common/config.py index ff18d4d1b..07e42462f 100644 --- a/neutron/plugins/sriovnicagent/common/config.py +++ b/neutron/plugins/sriovnicagent/common/config.py @@ -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) diff --git a/neutron/plugins/sriovnicagent/eswitch_manager.py b/neutron/plugins/sriovnicagent/eswitch_manager.py index 0f8e10808..0397ffb00 100644 --- a/neutron/plugins/sriovnicagent/eswitch_manager.py +++ b/neutron/plugins/sriovnicagent/eswitch_manager.py @@ -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 diff --git a/neutron/plugins/sriovnicagent/pci_lib.py b/neutron/plugins/sriovnicagent/pci_lib.py index 0a818d924..917ac3eb1 100644 --- a/neutron/plugins/sriovnicagent/pci_lib.py +++ b/neutron/plugins/sriovnicagent/pci_lib.py @@ -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): diff --git a/neutron/plugins/sriovnicagent/sriov_nic_agent.py b/neutron/plugins/sriovnicagent/sriov_nic_agent.py index 53cce664f..7928417bb 100644 --- a/neutron/plugins/sriovnicagent/sriov_nic_agent.py +++ b/neutron/plugins/sriovnicagent/sriov_nic_agent.py @@ -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) diff --git a/neutron/tests/unit/sriovnicagent/test_eswitch_manager.py b/neutron/tests/unit/sriovnicagent/test_eswitch_manager.py index f0c19adc0..3aacb722c 100644 --- a/neutron/tests/unit/sriovnicagent/test_eswitch_manager.py +++ b/neutron/tests/unit/sriovnicagent/test_eswitch_manager.py @@ -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( diff --git a/neutron/tests/unit/sriovnicagent/test_sriov_neutron_agent.py b/neutron/tests/unit/sriovnicagent/test_sriov_neutron_agent.py index fa96dda54..2fc6ad09e 100644 --- a/neutron/tests/unit/sriovnicagent/test_sriov_neutron_agent.py +++ b/neutron/tests/unit/sriovnicagent/test_sriov_neutron_agent.py @@ -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: