Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: a52ad31c2140655e327c27caa0fef8d23adb3bef
Parent: da220abc1de33c59cef58f23433d434ceab3638f
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Fri Oct 30 17:23:03 2009 -0400
Committer: root <root(a)localhost.localdomain>
CommitterDate: Tue Nov 3 09:53:38 2009 -0500
resource-agents: More misc. vm.sh warnings
This adds:
- warnings if use_virsh="1" is set while path is also set
- warnings if you are not root
- checks for xm and virsh binaries in $PATH
Resolves: rhbz#529926
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/vm.sh | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/rgmanager/src/resources/vm.sh b/rgmanager/src/resources/vm.sh
index 02bb5ff..8169ae4 100755
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -550,7 +550,10 @@ do_status()
validate_all()
{
- [ "$(id -u)" = "0" ] || return 1
+ if [ "$(id -u)" != "0" ]; then
+ ocf_log err "Cannot control VMs. as non-root user."
+ return 1
+ fi
#
# If someone selects a hypervisor, honor it.
@@ -585,22 +588,40 @@ validate_all()
echo "Management tool: virsh"
export OCF_RESKEY_use_virsh=1
else
+ if [ -n "$OCF_RESKEY_use_virsh" ]; then
+ ocf_log warning "Cannot use virsh with 'path' attribute set"
+ ocf_log warning "Setting use_virsh to 0."
+ fi
+
if [ "$OCF_RESKEY_hypervisor" != "xen" ]; then
ocf_log err "Cannot use $OCF_RESKEY_hypervisor hypervisor with 'path'
attribute"
return $OCF_ERR_ARGS
fi
-
+
echo "Management tool: xm"
export OCF_RESKEY_use_virsh=0
fi
fi
if [ "$OCF_RESKEY_use_virsh" = "0" ]; then
+
+ which xm &> /dev/null
+ if [ $? -ne 0 ]; then
+ ocf_log err "Cannot find 'xm'; is it installed?"
+ return $OCF_ERR_INSTALLED
+ fi
+
if [ "$OCF_RESKEY_hypervisor" = "qemu" ] ||
[ "$OCF_RESKEY_hypervisor" = "kvm" ]; then
ocf_log err "Cannot use $OCF_RESKEY_hypervisor hypervisor without using
virsh"
return $OCF_ERR_ARGS
fi
+ else
+ which virsh &> /dev/null
+ if [ $? -ne 0 ]; then
+ ocf_log err "Cannot find 'virsh'; is it installed?"
+ return $OCF_ERR_INSTALLED
+ fi
fi
#