Skip to content

Commit

Permalink
High: VirtualDomain: Ensure it is possible to manage a libvirt domain…
Browse files Browse the repository at this point in the history
… defined outside of VirtualDomain
  • Loading branch information
davidvossel committed Oct 8, 2013
1 parent 34994ed commit f00dcaf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions heartbeat/VirtualDomain
Expand Up @@ -257,6 +257,15 @@ VirtualDomain_Status() {
return $rc
}

verify_undefined() {
for dom in `virsh --connect=${OCF_RESKEY_hypervisor} list --all --name`; do
if [ "$dom" = "$DOMAIN_NAME" ]; then
virsh $VIRSH_OPTIONS undefine $DOMAIN_NAME > /dev/null 2>&1
return
fi
done
}

VirtualDomain_Start() {
local snapshotimage

Expand All @@ -276,6 +285,14 @@ VirtualDomain_Start() {
return $OCF_ERR_GENERIC
fi

# Make sure domain is undefined before creating.
# The 'create' command guarantees that the domain will be
# undefined on shutdown, but requires the domain to be undefined.
# if a user defines the domain
# outside of this agent, we have to ensure that the domain
# is restored to an 'undefined' state before creating.
verify_undefined

virsh $VIRSH_OPTIONS create ${OCF_RESKEY_config}
rc=$?
if [ $rc -ne 0 ]; then
Expand Down

0 comments on commit f00dcaf

Please sign in to comment.