from oslo_config import cfg
-from neutron.agent.common import config as agconfig
from neutron.common import utils
from neutron.extensions import portbindings
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)
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:])
from oslo_config import cfg
-from neutron.agent.common import config
-
cisco_opts = [
cfg.StrOpt('vlan_name_prefix', default='q-',
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
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.
: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
{'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!"),
'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}
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.")),
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)
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
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
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 = [
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")),
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)
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)
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
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)
from oslo_config import cfg
-from neutron.agent.common import config
-
NVSD_OPT = [
cfg.StrOpt('nvsd_ip',
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
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
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)
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)
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)
@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)
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,
"""
self.emb_switches_map = {}
self.pci_slot_map = {}
- self.root_helper = root_helper
self._discover_devices(device_mappings, exclude_devices)
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
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):
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}
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()
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)
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'}
"PciOsWrapper.is_assigned_vf",
return_value=True)):
- esm.ESwitchManager(device_mappings, None, None)
+ esm.ESwitchManager(device_mappings, None)
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."
"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(
'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:
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:
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: