Change ovs_base neutron plugin to use vercmp

This plugin was using a deprecated function, vercmp_numbers(),
that wasn't actually working properly because the call to
'deprecated' at the beginning was causing garbage to be
returned to the caller.  For example, this was always in
stack.sh.log when using OVS:

.../lib/neutron_plugins/ovs_base: line 57: [: too many arguments

Update to use vercmp() like all other users in devstack, and
remove all the old code.

Change-Id: I352362cf59e492fa9f7725190f0243f2436ac347
This commit is contained in:
Brian Haley 2016-06-02 10:29:43 -04:00
parent feb828b7aa
commit 09604349f8
2 changed files with 1 additions and 56 deletions

View File

@ -511,61 +511,6 @@ function check_path_perm_sanity {
} }
# This function recursively compares versions, and is not meant to be
# called by anything other than vercmp_numbers below. This function does
# not work with alphabetic versions.
#
# _vercmp_r sep ver1 ver2
function _vercmp_r {
typeset sep
typeset -a ver1=() ver2=()
sep=$1; shift
ver1=("${@:1:sep}")
ver2=("${@:sep+1}")
if ((ver1 > ver2)); then
echo 1; return 0
elif ((ver2 > ver1)); then
echo -1; return 0
fi
if ((sep <= 1)); then
echo 0; return 0
fi
_vercmp_r $((sep-1)) "${ver1[@]:1}" "${ver2[@]:1}"
}
# This function compares two versions and is meant to be called by
# external callers. Please note the function assumes non-alphabetic
# versions. For example, this will work:
#
# vercmp_numbers 1.10 1.4
#
# The above will return "1", as 1.10 is greater than 1.4.
#
# vercmp_numbers 5.2 6.4
#
# The above will return "-1", as 5.2 is less than 6.4.
#
# vercmp_numbers 4.0 4.0
#
# The above will return "0", as the versions are equal.
#
# vercmp_numbers ver1 ver2
function vercmp_numbers {
typeset v1=$1 v2=$2 sep
typeset -a ver1 ver2
deprecated "vercmp_numbers is deprecated for more generic vercmp"
IFS=. read -ra ver1 <<< "$v1"
IFS=. read -ra ver2 <<< "$v2"
_vercmp_r "${#ver1[@]}" "${ver1[@]}" "${ver2[@]}"
}
# vercmp ver1 op ver2 # vercmp ver1 op ver2
# Compare VER1 to VER2 # Compare VER1 to VER2
# - op is one of < <= == >= > # - op is one of < <= == >= >

View File

@ -54,7 +54,7 @@ function _neutron_ovs_base_install_ubuntu_dkms {
local kernel_major_minor local kernel_major_minor
kernel_major_minor=`echo $kernel_version | cut -d. -f1-2` kernel_major_minor=`echo $kernel_version | cut -d. -f1-2`
# From kernel 3.13 on, openvswitch-datapath-dkms is not needed # From kernel 3.13 on, openvswitch-datapath-dkms is not needed
if [ `vercmp_numbers "$kernel_major_minor" "3.13"` -lt "0" ]; then if vercmp '$kernel_major_minor' '<' '3.13'; then
install_package "dkms openvswitch-datapath-dkms linux-headers-$kernel_version" install_package "dkms openvswitch-datapath-dkms linux-headers-$kernel_version"
fi fi
} }