Hi, I found lxc RA does not work with LXC-0.7.5 because the output of the command lxc-info used in RA has changed since LXC-0.7.5.
So I wrote two patches. One patch fixes the above problem. The other patch makes ocf_version_cmp in ocf-shellfuncs work for different version scheme, such as 0.7.4.2 and 0.7.5. Patch attached. Corresponding Github pull requests are #51 and #55. Regards, Kazuyoshi -- Kazuyoshi MII NTT Open Source Software Center NIPPON TELEGRAPH AND TELEPHONE CORPORATION
diff --git a/heartbeat/lxc b/heartbeat/lxc index f534757..43e505a 100755 --- a/heartbeat/lxc +++ b/heartbeat/lxc @@ -239,7 +239,10 @@ LXC_stop() { } LXC_status() { - S=`lxc-info -n ${OCF_RESKEY_container}` + # run lxc-info with -s option for LXC-0.7.5 or later + local lxc_info_opt="-s" + ocf_version_cmp "`lxc-version | cut -d' ' -f 3`" 0.7.5 && lxc_info_opt="" + S=`lxc-info $lxc_info_opt -n ${OCF_RESKEY_container}` ocf_log debug "State of ${OCF_RESKEY_container}: $S" if [[ "${S##* }" = "RUNNING" ]] ; then return $OCF_SUCCESS
diff --git a/heartbeat/ocf-shellfuncs.in b/heartbeat/ocf-shellfuncs.in index 811c536..e1cd33f 100644 --- a/heartbeat/ocf-shellfuncs.in +++ b/heartbeat/ocf-shellfuncs.in @@ -462,6 +462,19 @@ ocf_ver2num() { {for(i=1; i<=NF; i++) s=s*1000+$i; print s} ' } +ocf_ver_level(){ + echo $1 | awk -F'[.-]' '{print NF}' +} +ocf_ver_complete_level(){ + local ver="$1" + local level="$2" + local i=0 + while [ $i -lt $level ]; do + ver=${ver}.0 + i=`expr $i + 1` + done + echo $ver +} # usage: ocf_version_cmp VER1 VER2 # version strings can contain digits, dots, and dashes @@ -474,8 +487,20 @@ ocf_ver2num() { ocf_version_cmp() { ocf_is_ver "$1" || return 3 ocf_is_ver "$2" || return 3 - local v1=`ocf_ver2num $1` - local v2=`ocf_ver2num $2` + local v1=$1 + local v2=$2 + local v1_level=`ocf_ver_level $v1` + local v2_level=`ocf_ver_level $v2` + local level_diff + if [ $v1_level -lt $v2_level ]; then + level_diff=`expr $v2_level - $v1_level` + v1=`ocf_ver_complete_level $v1 $level_diff` + elif [ $v1_level -gt $v2_level ]; then + level_diff=`expr $v1_level - $v2_level` + v2=`ocf_ver_complete_level $v2 $level_diff` + fi + v1=`ocf_ver2num $v1` + v2=`ocf_ver2num $v2` if [ $v1 -eq $v2 ]; then return 1 elif [ $v1 -lt $v2 ]; then
_______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/