Fixes crash when starting Neutron OVS Agent on Windows
The neutron OVS Agent does not start on Windows because of Linux specific import. The fix consists in moving the method get_ip_version in the common module of ip_lib being the only one used from the module. We will import the common module agent/common/ip_lib after that. Change-Id: I95e9a6fa99e0992499f46a4f0debccd47b8a936c Closes-Bug: #1670402
This commit is contained in:
parent
97db8aab07
commit
46827e0de9
@ -1138,8 +1138,12 @@ def add_namespace_to_cmd(cmd, namespace=None):
|
|||||||
return ['ip', 'netns', 'exec', namespace] + cmd if namespace else cmd
|
return ['ip', 'netns', 'exec', namespace] + cmd if namespace else cmd
|
||||||
|
|
||||||
|
|
||||||
|
@removals.remove(
|
||||||
|
message="This will be removed in the future. "
|
||||||
|
"Please use 'neutron.common.utils.get_ip_version' instead.",
|
||||||
|
version='Pike', removal_version='Queens')
|
||||||
def get_ip_version(ip_or_cidr):
|
def get_ip_version(ip_or_cidr):
|
||||||
return netaddr.IPNetwork(ip_or_cidr).version
|
return common_utils.get_ip_version(ip_or_cidr)
|
||||||
|
|
||||||
|
|
||||||
def get_ipv6_lladdr(mac_addr):
|
def get_ipv6_lladdr(mac_addr):
|
||||||
|
@ -18,7 +18,6 @@ from neutron_lib import constants as n_consts
|
|||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from neutron.agent import firewall
|
from neutron.agent import firewall
|
||||||
from neutron.agent.linux import ip_lib
|
|
||||||
from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts
|
from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts
|
||||||
from neutron.common import utils
|
from neutron.common import utils
|
||||||
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \
|
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \
|
||||||
@ -49,15 +48,15 @@ def create_flows_from_rule_and_port(rule, port):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if is_valid_prefix(dst_ip_prefix):
|
if is_valid_prefix(dst_ip_prefix):
|
||||||
if ip_lib.get_ip_version(dst_ip_prefix) == n_consts.IP_VERSION_4:
|
if utils.get_ip_version(dst_ip_prefix) == n_consts.IP_VERSION_4:
|
||||||
flow_template["nw_dst"] = dst_ip_prefix
|
flow_template["nw_dst"] = dst_ip_prefix
|
||||||
elif ip_lib.get_ip_version(dst_ip_prefix) == n_consts.IP_VERSION_6:
|
elif utils.get_ip_version(dst_ip_prefix) == n_consts.IP_VERSION_6:
|
||||||
flow_template["ipv6_dst"] = dst_ip_prefix
|
flow_template["ipv6_dst"] = dst_ip_prefix
|
||||||
|
|
||||||
if is_valid_prefix(src_ip_prefix):
|
if is_valid_prefix(src_ip_prefix):
|
||||||
if ip_lib.get_ip_version(src_ip_prefix) == n_consts.IP_VERSION_4:
|
if utils.get_ip_version(src_ip_prefix) == n_consts.IP_VERSION_4:
|
||||||
flow_template["nw_src"] = src_ip_prefix
|
flow_template["nw_src"] = src_ip_prefix
|
||||||
elif ip_lib.get_ip_version(src_ip_prefix) == n_consts.IP_VERSION_6:
|
elif utils.get_ip_version(src_ip_prefix) == n_consts.IP_VERSION_6:
|
||||||
flow_template["ipv6_src"] = src_ip_prefix
|
flow_template["ipv6_src"] = src_ip_prefix
|
||||||
|
|
||||||
flows = create_protocol_flows(direction, flow_template, port, rule)
|
flows = create_protocol_flows(direction, flow_template, port, rule)
|
||||||
|
@ -229,6 +229,10 @@ def is_cidr_host(cidr):
|
|||||||
return net.prefixlen == n_const.IPv6_BITS
|
return net.prefixlen == n_const.IPv6_BITS
|
||||||
|
|
||||||
|
|
||||||
|
def get_ip_version(ip_or_cidr):
|
||||||
|
return netaddr.IPNetwork(ip_or_cidr).version
|
||||||
|
|
||||||
|
|
||||||
def ip_version_from_int(ip_version_int):
|
def ip_version_from_int(ip_version_int):
|
||||||
if ip_version_int == 4:
|
if ip_version_int == 4:
|
||||||
return n_const.IPv4
|
return n_const.IPv4
|
||||||
|
Loading…
Reference in New Issue
Block a user