|
|
cf07b3 |
From f00dcaf19467e3d96d9790d386b860b53ca381f9 Mon Sep 17 00:00:00 2001
|
|
|
cf07b3 |
From: David Vossel <dvossel@redhat.com>
|
|
|
cf07b3 |
Date: Mon, 7 Oct 2013 19:37:43 -0500
|
|
|
cf07b3 |
Subject: [PATCH] High: VirtualDomain: Ensure it is possible to manage a libvirt domain defined outside of VirtualDomain
|
|
|
cf07b3 |
|
|
|
cf07b3 |
---
|
|
|
cf07b3 |
heartbeat/VirtualDomain | 17 +++++++++++++++++
|
|
|
cf07b3 |
1 files changed, 17 insertions(+), 0 deletions(-)
|
|
|
cf07b3 |
|
|
|
cf07b3 |
diff --git a/heartbeat/VirtualDomain b/heartbeat/VirtualDomain
|
|
|
cf07b3 |
index f7ed100..8d5e181 100755
|
|
|
cf07b3 |
--- a/heartbeat/VirtualDomain
|
|
|
cf07b3 |
+++ b/heartbeat/VirtualDomain
|
|
|
cf07b3 |
@@ -257,6 +257,15 @@ VirtualDomain_Status() {
|
|
|
cf07b3 |
return $rc
|
|
|
cf07b3 |
}
|
|
|
cf07b3 |
|
|
|
cf07b3 |
+verify_undefined() {
|
|
|
cf07b3 |
+ for dom in `virsh --connect=${OCF_RESKEY_hypervisor} list --all --name`; do
|
|
|
cf07b3 |
+ if [ "$dom" = "$DOMAIN_NAME" ]; then
|
|
|
cf07b3 |
+ virsh $VIRSH_OPTIONS undefine $DOMAIN_NAME > /dev/null 2>&1
|
|
|
cf07b3 |
+ return
|
|
|
cf07b3 |
+ fi
|
|
|
cf07b3 |
+ done
|
|
|
cf07b3 |
+}
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
VirtualDomain_Start() {
|
|
|
cf07b3 |
local snapshotimage
|
|
|
cf07b3 |
|
|
|
cf07b3 |
@@ -276,6 +285,14 @@ VirtualDomain_Start() {
|
|
|
cf07b3 |
return $OCF_ERR_GENERIC
|
|
|
cf07b3 |
fi
|
|
|
cf07b3 |
|
|
|
cf07b3 |
+ # Make sure domain is undefined before creating.
|
|
|
cf07b3 |
+ # The 'create' command guarantees that the domain will be
|
|
|
cf07b3 |
+ # undefined on shutdown, but requires the domain to be undefined.
|
|
|
cf07b3 |
+ # if a user defines the domain
|
|
|
cf07b3 |
+ # outside of this agent, we have to ensure that the domain
|
|
|
cf07b3 |
+ # is restored to an 'undefined' state before creating.
|
|
|
cf07b3 |
+ verify_undefined
|
|
|
cf07b3 |
+
|
|
|
cf07b3 |
virsh $VIRSH_OPTIONS create ${OCF_RESKEY_config}
|
|
|
cf07b3 |
rc=$?
|
|
|
cf07b3 |
if [ $rc -ne 0 ]; then
|
|
|
cf07b3 |
--
|
|
|
cf07b3 |
1.7.1
|
|
|
cf07b3 |
|