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
(cherry picked from commit 46827e0de9
)
This commit is contained in:
parent
eb23414b71
commit
7b8583482b
@ -1135,7 +1135,7 @@ def add_namespace_to_cmd(cmd, namespace=None):
|
||||
|
||||
|
||||
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):
|
||||
|
@ -18,7 +18,6 @@ from neutron_lib import constants as n_consts
|
||||
from oslo_log import log as logging
|
||||
|
||||
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.common import utils
|
||||
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 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
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
flows = create_protocol_flows(direction, flow_template, port, rule)
|
||||
|
@ -335,6 +335,10 @@ def is_cidr_host(cidr):
|
||||
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):
|
||||
if ip_version_int == 4:
|
||||
return n_const.IPv4
|
||||
|
Loading…
Reference in New Issue
Block a user