Browse code

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

Brian Haley authored on 2016/06/02 23:29:43
Showing 2 changed files
... ...
@@ -511,61 +511,6 @@ function check_path_perm_sanity {
511 511
 }
512 512
 
513 513
 
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
-
569 514
 # vercmp ver1 op ver2
570 515
 #  Compare VER1 to VER2
571 516
 #   - op is one of < <= == >= >
... ...
@@ -54,7 +54,7 @@ function _neutron_ovs_base_install_ubuntu_dkms {
54 54
     local kernel_major_minor
55 55
     kernel_major_minor=`echo $kernel_version | cut -d. -f1-2`
56 56
     # 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
58 58
         install_package "dkms openvswitch-datapath-dkms linux-headers-$kernel_version"
59 59
     fi
60 60
 }