Gitweb:
http://git.fedorahosted.org/git/resource-agents.git?p=resource-agents.git...
Commit: 655c17612390283deed576751f0dfea04603e4c1
Parent: becbaff82799a2327f696231f614ca1c4c6be1a0
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Fri Oct 30 17:23:03 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Nov 3 12:14:51 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 fd62747..4f2d0d8 100644
--- a/rgmanager/src/resources/vm.sh
+++ b/rgmanager/src/resources/vm.sh
@@ -565,7 +565,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.
@@ -600,22 +603,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
#