From b9e32cceb9d6b10dfbbc5d03c44a276ad79cc3ab Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 2 Feb 2011 16:27:22 -0800 Subject: [PATCH] script may return stdout from command, need to add another # to seperate it --- .../xen/resource/CitrixResourceBase.java | 5 ++--- .../xen/resource/XenServer56Resource.java | 4 ++-- .../xenserver/setup_heartbeat_file.sh | 16 +++++++-------- .../xenserver/setup_heartbeat_sr.sh | 20 +++++++++---------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index b69816cd0c1..3918e06511d 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3855,12 +3855,11 @@ public abstract class CitrixResourceBase implements ServerResource { boolean found = false; for (PBD pbd : pbds) { - if (host.equals(pbd.getHost(conn))) { - PBD.Record pbdr = pbd.getRecord(conn); + PBD.Record pbdr = pbd.getRecord(conn); + if (host.equals(pbdr.host)) { if (!pbdr.currentlyAttached) { pbdPlug(conn, pbd, pbdr.uuid); } - pbds.remove(pbd); found = true; break; } diff --git a/core/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java b/core/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java index 51b33b241b3..e6880e70970 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java +++ b/core/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java @@ -242,11 +242,11 @@ public class XenServer56Resource extends CitrixResourceBase { } String result = callHostPluginThroughMaster(conn, "vmopspremium", "setup_heartbeat_sr", "host", _host.uuid, "sr", srUuid); - if (result == null || !result.split("#")[0].equals("0")) { + if (result == null || !result.split("#")[1].equals("0")) { throw new CloudRuntimeException("Unable to setup heartbeat sr on SR " + srUuid + " due to " + result); } result = callHostPluginPremium(conn, "setup_heartbeat_file", "host", _host.uuid, "sr", srUuid); - if (result == null || !result.split("#")[0].equals("0")) { + if (result == null || !result.split("#")[1].equals("0")) { throw new CloudRuntimeException("Unable to setup heartbeat file entry on SR " + srUuid + " due to " + result); } diff --git a/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh b/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh index 42ff965e5be..535e5dfd280 100755 --- a/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh +++ b/scripts/vm/hypervisor/xenserver/setup_heartbeat_file.sh @@ -10,28 +10,28 @@ usage() { if [ -z $1 ]; then usage - echo "1# no uuid of host" + echo "#1# no uuid of host" exit 0 fi if [ -z $2 ]; then usage - echo "2# no uuid of sr" + echo "#2# no uuid of sr" exit 0 fi if [ `xe host-list | grep $1 | wc -l` -ne 1 ]; then - echo "3# Unable to find the host uuid: $1" + echo "#3# Unable to find the host uuid: $1" exit 0 fi if [ `xe sr-list uuid=$2 | wc -l` -eq 0 ]; then - echo "4# Unable to find SR with uuid: $2" + echo "#4# Unable to find SR with uuid: $2" exit 0 fi if [ `xe pbd-list sr-uuid=$2 | grep -B 1 $1 | wc -l` -eq 0 ]; then - echo "5# Unable to find a pbd for the SR: $2" + echo "#5# Unable to find a pbd for the SR: $2" exit 0 fi @@ -42,7 +42,7 @@ if [ "$srtype" = "nfs" ];then dir=/var/run/sr-mount/$2 filename=$dir/hb-$1 if [ ! -f "$filename" ]; then - echo "6# heartbeat file $filename doesn't exist" + echo "#6# heartbeat file $filename doesn't exist" exit 0 fi else @@ -50,7 +50,7 @@ else link=$dir/hb-$1 lvchange -ay $link if [ $? -ne 0 ]; then - echo "7# Unable to make the heartbeat $link active" + echo "#7# Unable to make the heartbeat $link active" exit 0 fi fi @@ -67,6 +67,6 @@ else echo $dir >> $hbfile fi -echo "0#DONE" +echo "#0#DONE" exit 0 diff --git a/scripts/vm/hypervisor/xenserver/setup_heartbeat_sr.sh b/scripts/vm/hypervisor/xenserver/setup_heartbeat_sr.sh index 0408c417e90..e0492b7208b 100755 --- a/scripts/vm/hypervisor/xenserver/setup_heartbeat_sr.sh +++ b/scripts/vm/hypervisor/xenserver/setup_heartbeat_sr.sh @@ -9,28 +9,28 @@ usage() { if [ -z $1 ]; then usage - echo "1#no host uuid" + echo "#1#no host uuid" exit 0 fi if [ -z $2 ]; then usage - echo "2#no sr uuid" + echo "#2#no sr uuid" exit 0 fi if [ `xe host-list | grep $1 | wc -l` -ne 1 ]; then - echo "3# Unable to find the host uuid: $1" + echo "#3# Unable to find the host uuid: $1" exit 0 fi if [ `xe sr-list uuid=$2 | wc -l` -eq 0 ]; then - echo "4# Unable to find SR with uuid: $2" + echo "#4# Unable to find SR with uuid: $2" exit 0 fi if [ `xe pbd-list sr-uuid=$2 | grep -B 1 $1 | wc -l` -eq 0 ]; then - echo "5# Unable to find a pbd for the SR: $2" + echo "#5# Unable to find a pbd for the SR: $2" exit 0 fi @@ -58,12 +58,12 @@ else fi lvcreate VG_XenStorage-$2 -n hb-$1 --size 4M if [ $? -ne 0 ]; then - echo "6# Unable to create heartbeat volume hb-$1" + echo "#6# Unable to create heartbeat volume hb-$1" exit 0 fi lv=`lvscan | grep $link` if [ -z "$lv" ]; then - echo "7# volume hb-$1 is not created" + echo "#7# volume hb-$1 is not created" exit 0 fi fi @@ -71,18 +71,18 @@ else if [ `echo $lv | awk '{print $1}'` == "inactive" ]; then lvchange -ay $link if [ $? -ne 0 ]; then - echo "8# Unable to make $link active" + echo "#8# Unable to make $link active" exit 0 fi fi if [ ! -L $link ]; then - echo "9# Unable to find the soft link $link" + echo "#9# Unable to find the soft link $link" exit 0 fi dd if=/dev/zero of=$link bs=1 count=100 fi -echo "0#DONE" +echo "#0#DONE" exit 0