Remove remaining root_helper args from plugins

Change-Id: If5ba0a6fd63640f97f7eccca839dbbbf26bf3f89
Partially-Implements: blueprint rootwrap-daemon-mode
This commit is contained in:
Terry Wilson 2015-02-10 23:04:34 -06:00
parent a796f95eb8
commit b2f996346f
21 changed files with 23 additions and 60 deletions

View 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)

View 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:])

View 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

View 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}

View 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.")),

View 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)

View 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

View File

@ -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")),

View 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)

View 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)

View 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

View 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)

View 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

View 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)

View 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)

View 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)

View 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

View 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):

View 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)

View 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(

View 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: