Skip to content

Commit

Permalink
Medium: VirtualDomain: Add start_scripts parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
berlevdv committed Nov 15, 2016
1 parent 3446b99 commit d058e8e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
30 changes: 30 additions & 0 deletions heartbeat/VirtualDomain
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,21 @@ Be sure to set the timeout of these operations to accommodate this delay.
<content type="string" default="" />
</parameter>
<parameter name="start_scripts" unique="0" required="0">
<longdesc lang="en">
To additionally start services within the virtual domain, add this
parameter with a list of scripts to start. Each executed script gets
one argument with Domain Name, specified in the libvirt configuration
file for this virtual domain.
Note: when start scripts are used, the start operation will complete
only when all start scripts have completed successfully.
Be sure to set the timeout of these operations to accommodate this delay.
</longdesc>
<shortdesc lang="en">space-separated list of start scripts</shortdesc>
<content type="string" default="" />
</parameter>
<parameter name="autoset_utilization_cpu" unique="0" required="0">
<longdesc lang="en">
If set true, the agent will detect the number of domainU's vCPUs from virsh, and put it
Expand Down Expand Up @@ -463,6 +478,21 @@ VirtualDomain_start() {
return $OCF_SUCCESS
fi

# If we have start scripts defined, run them one after another.
for script in ${OCF_RESKEY_start_scripts}; do
script_output="$($script $DOMAIN_NAME 2>&1)"
script_rc=$?
if [ ${script_rc} -ne ${OCF_SUCCESS} ]; then
# A start script returned a non-success exit
# code. Stop iterating over the list of scripts, log a
# warning message, and propagate $OCF_ERR_GENERIC.
ocf_exit_reason "Start command \"${script}\" for domain ${DOMAIN_NAME} returned ${script_rc} with output: ${script_output}"
return $OCF_ERR_GENERIC
else
ocf_log info "Start command \"${script}\" for domain ${DOMAIN_NAME} completed successfully with output: ${script_output}"
fi
done

snapshotimage="$OCF_RESKEY_snapshot/${DOMAIN_NAME}.state"
if [ -n "$OCF_RESKEY_snapshot" -a -f "$snapshotimage" ]; then
virsh restore $snapshotimage
Expand Down
6 changes: 4 additions & 2 deletions heartbeat/iscsi
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,16 @@ open_iscsi_add() {
}
open_iscsi_get_session_id() {
local target="$1"
local portal="$2"
$iscsiadm -m session 2>/dev/null |
grep -E "$target($|[[:space:]])" |
grep -E "] $portal" |
awk '{print $2}' | tr -d '[]'
}
open_iscsi_remove() {
local target="$1"
local session_id
session_id=`open_iscsi_get_session_id "$target"`
session_id=`open_iscsi_get_session_id "$target" "$OCF_RESKEY_portal"`
if [ "$session_id" ]; then
$iscsiadm -m session -r $session_id -u
else
Expand All @@ -296,7 +298,7 @@ open_iscsi_monitor() {
local recov

recov=${2:-$OCF_RESKEY_try_recovery}
session_id=`open_iscsi_get_session_id "$target"`
session_id=`open_iscsi_get_session_id "$target" "$OCF_RESKEY_portal"`
prev_state=""
if [ -z "$session_id" ]; then
if $iscsiadm -m node -p $OCF_RESKEY_portal -T $target >/dev/null 2>&1; then
Expand Down

0 comments on commit d058e8e

Please sign in to comment.