23
24
from neutron.agent.linux import utils as agent_utils
24
25
from neutron.common import utils
25
26
from neutron.i18n import _LE
26
from neutron.openstack.common import log as logging
27
27
from neutron.openstack.common import uuidutils
28
28
from neutron.plugins.common import constants as const
29
29
from neutron.plugins.openvswitch.common import constants as ovs_const
34
34
MINIMUM_DNSMASQ_VERSION = 2.67
37
def ovs_vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
37
def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
38
38
name = "vxlantest-" + utils.get_random_string(6)
39
with ovs_lib.OVSBridge(name, root_helper) as br:
39
with ovs_lib.OVSBridge(name) as br:
40
40
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
41
41
return port != ovs_lib.INVALID_OFPORT
44
def iproute2_vxlan_supported(root_helper):
45
ip = ip_lib.IPWrapper(root_helper)
44
def iproute2_vxlan_supported():
45
ip = ip_lib.IPWrapper()
46
46
name = "vxlantest-" + utils.get_random_string(4)
47
47
port = ip.add_vxlan(name, 3000)
49
49
return name == port.name
52
def patch_supported(root_helper):
52
def patch_supported():
53
53
seed = utils.get_random_string(6)
54
54
name = "patchtest-" + seed
55
55
peer_name = "peertest0-" + seed
56
56
patch_name = "peertest1-" + seed
57
with ovs_lib.OVSBridge(name, root_helper) as br:
57
with ovs_lib.OVSBridge(name) as br:
58
58
port = br.add_patch_port(patch_name, peer_name)
59
59
return port != ovs_lib.INVALID_OFPORT
70
def ofctl_arg_supported(root_helper, cmd, **kwargs):
70
def ofctl_arg_supported(cmd, **kwargs):
71
71
"""Verify if ovs-ofctl binary supports cmd with **kwargs.
73
:param root_helper: utility to use when running shell commands.
74
73
:param cmd: ovs-ofctl command to use for test.
75
74
:param **kwargs: arguments to test with the command.
76
75
:returns: a boolean if the supplied arguments are supported.
78
77
br_name = 'br-test-%s' % utils.get_random_string(6)
79
with ovs_lib.OVSBridge(br_name, root_helper) as test_br:
78
with ovs_lib.OVSBridge(br_name) as test_br:
80
79
full_args = ["ovs-ofctl", cmd, test_br.br_name,
81
80
ovs_lib._build_flow_expr_str(kwargs, cmd.split('-')[0])]
83
agent_utils.execute(full_args, root_helper=root_helper)
82
agent_utils.execute(full_args, run_as_root=True)
84
83
except RuntimeError as e:
85
84
LOG.debug("Exception while checking supported feature via "
86
85
"command %s. Exception: %s", full_args, e)
96
def arp_responder_supported(root_helper):
95
def arp_responder_supported():
97
96
mac = netaddr.EUI('dead:1234:beef', dialect=netaddr.mac_unix)
98
97
ip = netaddr.IPAddress('240.0.0.1')
99
98
actions = ovs_const.ARP_RESPONDER_ACTIONS % {'mac': mac, 'ip': ip}
101
return ofctl_arg_supported(root_helper,
100
return ofctl_arg_supported(cmd='add-flow',
111
def vf_management_supported(root_helper):
109
def vf_management_supported():
113
vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section(
111
vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section()
115
112
if not ip_link_support.IpLinkSupport.vf_mgmt_capability_supported(
117
114
ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_STATE):