Remove root_helper arg from sanity checks
Change-Id: I0e0791b9a04750968675d21b93cee412c50fdd51 Partially-Implements: blueprint rootwrap-daemon-mode
This commit is contained in:
parent
c1e0f9d641
commit
8d5b57c20d
@ -51,13 +51,10 @@ class IpLinkSupport(object):
|
||||
SUB_CAPABILITY_REGEX = r"\[ %(cap)s (.*) \[ %(subcap)s (.*)"
|
||||
|
||||
@classmethod
|
||||
def get_vf_mgmt_section(cls, root_helper=None):
|
||||
"""Parses ip link help output, and gets vf block
|
||||
def get_vf_mgmt_section(cls):
|
||||
"""Parses ip link help output, and gets vf block"""
|
||||
|
||||
:param root_helper: root permission helper
|
||||
|
||||
"""
|
||||
output = cls._get_ip_link_output(root_helper)
|
||||
output = cls._get_ip_link_output()
|
||||
vf_block_pattern = re.search(cls.VF_BLOCK_REGEX,
|
||||
output,
|
||||
re.DOTALL | re.MULTILINE)
|
||||
@ -87,7 +84,7 @@ class IpLinkSupport(object):
|
||||
return pattern_match is not None
|
||||
|
||||
@classmethod
|
||||
def _get_ip_link_output(cls, root_helper):
|
||||
def _get_ip_link_output(cls):
|
||||
"""Gets the output of the ip link help command
|
||||
|
||||
Runs ip link help command and stores its output
|
||||
@ -99,7 +96,7 @@ class IpLinkSupport(object):
|
||||
try:
|
||||
ip_cmd = ['ip', 'link', 'help']
|
||||
_stdout, _stderr = utils.execute(
|
||||
ip_cmd, root_helper,
|
||||
ip_cmd,
|
||||
check_exit_code=False,
|
||||
return_stderr=True,
|
||||
log_fail_as_error=False)
|
||||
|
@ -34,22 +34,22 @@ LOG = logging.getLogger(__name__)
|
||||
MINIMUM_DNSMASQ_VERSION = 2.67
|
||||
|
||||
|
||||
def ovs_vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
|
||||
def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
|
||||
name = "vxlantest-" + utils.get_random_string(6)
|
||||
with ovs_lib.OVSBridge(name) as br:
|
||||
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
|
||||
return port != ovs_lib.INVALID_OFPORT
|
||||
|
||||
|
||||
def iproute2_vxlan_supported(root_helper):
|
||||
ip = ip_lib.IPWrapper(root_helper)
|
||||
def iproute2_vxlan_supported():
|
||||
ip = ip_lib.IPWrapper()
|
||||
name = "vxlantest-" + utils.get_random_string(4)
|
||||
port = ip.add_vxlan(name, 3000)
|
||||
ip.del_veth(name)
|
||||
return name == port.name
|
||||
|
||||
|
||||
def patch_supported(root_helper):
|
||||
def patch_supported():
|
||||
seed = utils.get_random_string(6)
|
||||
name = "patchtest-" + seed
|
||||
peer_name = "peertest0-" + seed
|
||||
@ -67,10 +67,9 @@ def nova_notify_supported():
|
||||
return False
|
||||
|
||||
|
||||
def ofctl_arg_supported(root_helper, cmd, **kwargs):
|
||||
def ofctl_arg_supported(cmd, **kwargs):
|
||||
"""Verify if ovs-ofctl binary supports cmd with **kwargs.
|
||||
|
||||
:param root_helper: utility to use when running shell commands.
|
||||
:param cmd: ovs-ofctl command to use for test.
|
||||
:param **kwargs: arguments to test with the command.
|
||||
:returns: a boolean if the supplied arguments are supported.
|
||||
@ -80,7 +79,7 @@ def ofctl_arg_supported(root_helper, cmd, **kwargs):
|
||||
full_args = ["ovs-ofctl", cmd, test_br.br_name,
|
||||
ovs_lib._build_flow_expr_str(kwargs, cmd.split('-')[0])]
|
||||
try:
|
||||
agent_utils.execute(full_args, root_helper=root_helper)
|
||||
agent_utils.execute(full_args, run_as_root=True)
|
||||
except RuntimeError as e:
|
||||
LOG.debug("Exception while checking supported feature via "
|
||||
"command %s. Exception: %s", full_args, e)
|
||||
@ -93,13 +92,12 @@ def ofctl_arg_supported(root_helper, cmd, **kwargs):
|
||||
return True
|
||||
|
||||
|
||||
def arp_responder_supported(root_helper):
|
||||
def arp_responder_supported():
|
||||
mac = netaddr.EUI('dead:1234:beef', dialect=netaddr.mac_unix)
|
||||
ip = netaddr.IPAddress('240.0.0.1')
|
||||
actions = ovs_const.ARP_RESPONDER_ACTIONS % {'mac': mac, 'ip': ip}
|
||||
|
||||
return ofctl_arg_supported(root_helper,
|
||||
cmd='add-flow',
|
||||
return ofctl_arg_supported(cmd='add-flow',
|
||||
table=21,
|
||||
priority=1,
|
||||
proto='arp',
|
||||
@ -108,10 +106,9 @@ def arp_responder_supported(root_helper):
|
||||
actions=actions)
|
||||
|
||||
|
||||
def vf_management_supported(root_helper):
|
||||
def vf_management_supported():
|
||||
try:
|
||||
vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section(
|
||||
root_helper)
|
||||
vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section()
|
||||
if not ip_link_support.IpLinkSupport.vf_mgmt_capability_supported(
|
||||
vf_section,
|
||||
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_STATE):
|
||||
@ -124,8 +121,8 @@ def vf_management_supported(root_helper):
|
||||
return True
|
||||
|
||||
|
||||
def netns_read_requires_helper(root_helper):
|
||||
ipw = ip_lib.IPWrapper(root_helper)
|
||||
def netns_read_requires_helper():
|
||||
ipw = ip_lib.IPWrapper()
|
||||
nsname = "netnsreadtest-" + uuidutils.generate_uuid()
|
||||
ipw.netns.add(nsname)
|
||||
try:
|
||||
|
@ -42,7 +42,7 @@ class BoolOptCallback(cfg.BoolOpt):
|
||||
|
||||
|
||||
def check_ovs_vxlan():
|
||||
result = checks.ovs_vxlan_supported(root_helper=cfg.CONF.AGENT.root_helper)
|
||||
result = checks.ovs_vxlan_supported()
|
||||
if not result:
|
||||
LOG.error(_LE('Check for Open vSwitch VXLAN support failed. '
|
||||
'Please ensure that the version of openvswitch '
|
||||
@ -51,8 +51,7 @@ def check_ovs_vxlan():
|
||||
|
||||
|
||||
def check_iproute2_vxlan():
|
||||
result = checks.iproute2_vxlan_supported(
|
||||
root_helper=cfg.CONF.AGENT.root_helper)
|
||||
result = checks.iproute2_vxlan_supported()
|
||||
if not result:
|
||||
LOG.error(_LE('Check for iproute2 VXLAN support failed. Please ensure '
|
||||
'that the iproute2 has VXLAN support.'))
|
||||
@ -60,7 +59,7 @@ def check_iproute2_vxlan():
|
||||
|
||||
|
||||
def check_ovs_patch():
|
||||
result = checks.patch_supported(root_helper=cfg.CONF.AGENT.root_helper)
|
||||
result = checks.patch_supported()
|
||||
if not result:
|
||||
LOG.error(_LE('Check for Open vSwitch patch port support failed. '
|
||||
'Please ensure that the version of openvswitch '
|
||||
@ -70,8 +69,7 @@ def check_ovs_patch():
|
||||
|
||||
|
||||
def check_read_netns():
|
||||
required = checks.netns_read_requires_helper(
|
||||
root_helper=cfg.CONF.AGENT.root_helper)
|
||||
required = checks.netns_read_requires_helper()
|
||||
if not required and cfg.CONF.AGENT.use_helper_for_ns_read:
|
||||
LOG.warning(_LW("The user that is executing neutron can read the "
|
||||
"namespaces without using the root_helper. Disable "
|
||||
@ -113,8 +111,7 @@ def check_nova_notify():
|
||||
|
||||
|
||||
def check_arp_responder():
|
||||
result = checks.arp_responder_supported(
|
||||
root_helper=cfg.CONF.AGENT.root_helper)
|
||||
result = checks.arp_responder_supported()
|
||||
if not result:
|
||||
LOG.error(_LE('Check for Open vSwitch ARP responder support failed. '
|
||||
'Please ensure that the version of openvswitch '
|
||||
@ -123,8 +120,7 @@ def check_arp_responder():
|
||||
|
||||
|
||||
def check_vf_management():
|
||||
result = checks.vf_management_supported(
|
||||
root_helper=cfg.CONF.AGENT.root_helper)
|
||||
result = checks.vf_management_supported()
|
||||
if not result:
|
||||
LOG.error(_LE('Check for VF management support failed. '
|
||||
'Please ensure that the version of ip link '
|
||||
|
@ -48,19 +48,19 @@ class SanityTestCaseRoot(functional_base.BaseSudoTestCase):
|
||||
self.check_sudo_enabled()
|
||||
|
||||
def test_ovs_vxlan_support_runs(self):
|
||||
checks.ovs_vxlan_supported(self.root_helper)
|
||||
checks.ovs_vxlan_supported()
|
||||
|
||||
def test_iproute2_vxlan_support_runs(self):
|
||||
checks.iproute2_vxlan_supported(self.root_helper)
|
||||
checks.iproute2_vxlan_supported()
|
||||
|
||||
def test_ovs_patch_support_runs(self):
|
||||
checks.patch_supported(self.root_helper)
|
||||
checks.patch_supported()
|
||||
|
||||
def test_arp_responder_runs(self):
|
||||
checks.arp_responder_supported(self.root_helper)
|
||||
checks.arp_responder_supported()
|
||||
|
||||
def test_vf_management_runs(self):
|
||||
checks.vf_management_supported(self.root_helper)
|
||||
checks.vf_management_supported()
|
||||
|
||||
def test_namespace_root_read_detection_runs(self):
|
||||
checks.netns_read_requires_helper(self.root_helper)
|
||||
checks.netns_read_requires_helper()
|
||||
|
@ -114,7 +114,6 @@ TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can }
|
||||
vf_section, capability, subcapability)
|
||||
self.assertEqual(expected, capable)
|
||||
mock_exec.assert_called_once_with(['ip', 'link', 'help'],
|
||||
None,
|
||||
check_exit_code=False,
|
||||
return_stderr=True,
|
||||
log_fail_as_error=False)
|
||||
|
Loading…
Reference in New Issue
Block a user