Skip to content

Commit 0960434

Browse files
author
Brian Haley
committed
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
1 parent feb828b commit 0960434

File tree

2 files changed

+1
-56
lines changed

2 files changed

+1
-56
lines changed

functions

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -511,61 +511,6 @@ function check_path_perm_sanity {
511511
}
512512

513513

514-
# This function recursively compares versions, and is not meant to be
515-
# called by anything other than vercmp_numbers below. This function does
516-
# not work with alphabetic versions.
517-
#
518-
# _vercmp_r sep ver1 ver2
519-
function _vercmp_r {
520-
typeset sep
521-
typeset -a ver1=() ver2=()
522-
sep=$1; shift
523-
ver1=("${@:1:sep}")
524-
ver2=("${@:sep+1}")
525-
526-
if ((ver1 > ver2)); then
527-
echo 1; return 0
528-
elif ((ver2 > ver1)); then
529-
echo -1; return 0
530-
fi
531-
532-
if ((sep <= 1)); then
533-
echo 0; return 0
534-
fi
535-
536-
_vercmp_r $((sep-1)) "${ver1[@]:1}" "${ver2[@]:1}"
537-
}
538-
539-
540-
# This function compares two versions and is meant to be called by
541-
# external callers. Please note the function assumes non-alphabetic
542-
# versions. For example, this will work:
543-
#
544-
# vercmp_numbers 1.10 1.4
545-
#
546-
# The above will return "1", as 1.10 is greater than 1.4.
547-
#
548-
# vercmp_numbers 5.2 6.4
549-
#
550-
# The above will return "-1", as 5.2 is less than 6.4.
551-
#
552-
# vercmp_numbers 4.0 4.0
553-
#
554-
# The above will return "0", as the versions are equal.
555-
#
556-
# vercmp_numbers ver1 ver2
557-
function vercmp_numbers {
558-
typeset v1=$1 v2=$2 sep
559-
typeset -a ver1 ver2
560-
561-
deprecated "vercmp_numbers is deprecated for more generic vercmp"
562-
563-
IFS=. read -ra ver1 <<< "$v1"
564-
IFS=. read -ra ver2 <<< "$v2"
565-
566-
_vercmp_r "${#ver1[@]}" "${ver1[@]}" "${ver2[@]}"
567-
}
568-
569514
# vercmp ver1 op ver2
570515
# Compare VER1 to VER2
571516
# - op is one of < <= == >= >

lib/neutron_plugins/ovs_base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function _neutron_ovs_base_install_ubuntu_dkms {
5454
local kernel_major_minor
5555
kernel_major_minor=`echo $kernel_version | cut -d. -f1-2`
5656
# From kernel 3.13 on, openvswitch-datapath-dkms is not needed
57-
if [ `vercmp_numbers "$kernel_major_minor" "3.13"` -lt "0" ]; then
57+
if vercmp '$kernel_major_minor' '<' '3.13'; then
5858
install_package "dkms openvswitch-datapath-dkms linux-headers-$kernel_version"
5959
fi
6060
}

0 commit comments

Comments
 (0)