|
|
8d4b3d |
From 8c92227bce9cc4fe177eea5b2f7c9016e96434f9 Mon Sep 17 00:00:00 2001
|
|
|
8d4b3d |
From: David Vossel <dvossel@redhat.com>
|
|
|
8d4b3d |
Date: Mon, 29 Jun 2015 13:03:17 -0500
|
|
|
8d4b3d |
Subject: [PATCH 1/3] bz1214360-NovaCompute-update1.patch
|
|
|
8d4b3d |
|
|
|
8d4b3d |
---
|
|
|
8d4b3d |
doc/man/Makefile.am | 1 +
|
|
|
8d4b3d |
heartbeat/Makefile.am | 3 +-
|
|
|
8d4b3d |
heartbeat/NovaCompute | 73 ++++++------
|
|
|
8d4b3d |
heartbeat/NovaEvacuate | 311 +++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
8d4b3d |
4 files changed, 352 insertions(+), 36 deletions(-)
|
|
|
8d4b3d |
create mode 100755 heartbeat/NovaEvacuate
|
|
|
8d4b3d |
|
|
|
8d4b3d |
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
|
|
|
8d4b3d |
index 42a57fe..d32426b 100644
|
|
|
8d4b3d |
--- a/doc/man/Makefile.am
|
|
|
8d4b3d |
+++ b/doc/man/Makefile.am
|
|
|
8d4b3d |
@@ -74,6 +74,7 @@ man_MANS = ocf_heartbeat_AoEtarget.7 \
|
|
|
8d4b3d |
ocf_heartbeat_ManageRAID.7 \
|
|
|
8d4b3d |
ocf_heartbeat_ManageVE.7 \
|
|
|
8d4b3d |
ocf_heartbeat_NovaCompute.7 \
|
|
|
8d4b3d |
+ ocf_heartbeat_NovaEvacuate.7 \
|
|
|
8d4b3d |
ocf_heartbeat_Pure-FTPd.7 \
|
|
|
8d4b3d |
ocf_heartbeat_Raid1.7 \
|
|
|
8d4b3d |
ocf_heartbeat_Route.7 \
|
|
|
8d4b3d |
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
|
|
|
8d4b3d |
index 0bebf97..1034632 100644
|
|
|
8d4b3d |
--- a/heartbeat/Makefile.am
|
|
|
8d4b3d |
+++ b/heartbeat/Makefile.am
|
|
|
8d4b3d |
@@ -52,7 +52,8 @@ send_ua_SOURCES = send_ua.c IPv6addr_utils.c
|
|
|
8d4b3d |
IPv6addr_LDADD = -lplumb $(LIBNETLIBS)
|
|
|
8d4b3d |
send_ua_LDADD = $(LIBNETLIBS)
|
|
|
8d4b3d |
|
|
|
8d4b3d |
-osp_SCRIPTS = NovaCompute
|
|
|
8d4b3d |
+osp_SCRIPTS = NovaCompute \
|
|
|
8d4b3d |
+ NovaEvacuate
|
|
|
8d4b3d |
|
|
|
8d4b3d |
ocf_SCRIPTS = ClusterMon \
|
|
|
8d4b3d |
CTDB \
|
|
|
8d4b3d |
diff --git a/heartbeat/NovaCompute b/heartbeat/NovaCompute
|
|
|
8d4b3d |
index f71abeb..09eee38 100644
|
|
|
8d4b3d |
--- a/heartbeat/NovaCompute
|
|
|
8d4b3d |
+++ b/heartbeat/NovaCompute
|
|
|
8d4b3d |
@@ -107,15 +107,26 @@ Disable shared storage recovery for instances. Use at your own risk!
|
|
|
8d4b3d |
<content type="boolean" default="0" />
|
|
|
8d4b3d |
</parameter>
|
|
|
8d4b3d |
|
|
|
8d4b3d |
+<parameter name="evacuation_delay" unique="0" required="0">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+How long to wait for nova to finish evacuating instances elsewhere
|
|
|
8d4b3d |
+before starting nova-compute. Only used when the agent detects
|
|
|
8d4b3d |
+evacuations might be in progress.
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+You may need to increase the start timeout when increasing this value.
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Delay to allow evacuations time to complete</shortdesc>
|
|
|
8d4b3d |
+<content type="integer" default="120" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
</parameters>
|
|
|
8d4b3d |
|
|
|
8d4b3d |
<actions>
|
|
|
8d4b3d |
-<action name="start" timeout="120" />
|
|
|
8d4b3d |
+<action name="start" timeout="600" />
|
|
|
8d4b3d |
<action name="stop" timeout="300" />
|
|
|
8d4b3d |
<action name="monitor" timeout="20" interval="10" depth="0"/>
|
|
|
8d4b3d |
<action name="validate-all" timeout="20" />
|
|
|
8d4b3d |
<action name="meta-data" timeout="5" />
|
|
|
8d4b3d |
-<action name="notify" timeout="600" />
|
|
|
8d4b3d |
</actions>
|
|
|
8d4b3d |
</resource-agent>
|
|
|
8d4b3d |
END
|
|
|
8d4b3d |
@@ -132,7 +143,7 @@ sigterm_handler() {
|
|
|
8d4b3d |
|
|
|
8d4b3d |
nova_usage() {
|
|
|
8d4b3d |
cat <
|
|
|
8d4b3d |
-usage: $0 {start|stop|monitor|notify|validate-all|meta-data}
|
|
|
8d4b3d |
+usage: $0 {start|stop|monitor|validate-all|meta-data}
|
|
|
8d4b3d |
|
|
|
8d4b3d |
Expects to have a fully populated OCF RA-compliant environment set.
|
|
|
8d4b3d |
END
|
|
|
8d4b3d |
@@ -148,6 +159,26 @@ nova_start() {
|
|
|
8d4b3d |
return $OCF_SUCCESS
|
|
|
8d4b3d |
fi
|
|
|
8d4b3d |
|
|
|
8d4b3d |
+ state=$(attrd_updater -p -n evacute -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
|
|
|
8d4b3d |
+ if [ "x$state" = x ]; then
|
|
|
8d4b3d |
+ : never been fenced
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ elif [ "x$state" = xno ]; then
|
|
|
8d4b3d |
+ : has been evacuated, however it could have been 1s ago
|
|
|
8d4b3d |
+ ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
|
|
|
8d4b3d |
+ sleep ${OCF_RESKEY_evacuation_delay}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ else
|
|
|
8d4b3d |
+ ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
|
|
|
8d4b3d |
+ while [ "x$state" != "xno" ]; do
|
|
|
8d4b3d |
+ state=$(attrd_updater -p -n evacute -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
|
|
|
8d4b3d |
+ sleep 5
|
|
|
8d4b3d |
+ done
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
|
|
|
8d4b3d |
+ sleep ${OCF_RESKEY_evacuation_delay}
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
export LIBGUESTFS_ATTACH_METHOD=appliance
|
|
|
8d4b3d |
su nova -s /bin/sh -c /usr/bin/nova-compute &
|
|
|
8d4b3d |
|
|
|
8d4b3d |
@@ -212,33 +243,7 @@ nova_monitor() {
|
|
|
8d4b3d |
}
|
|
|
8d4b3d |
|
|
|
8d4b3d |
nova_notify() {
|
|
|
8d4b3d |
- if [ "x${OCF_RESKEY_CRM_meta_notify_operation}" != "xstop" ]; then
|
|
|
8d4b3d |
- return $OCF_SUCCESS
|
|
|
8d4b3d |
- elif [ "x${OCF_RESKEY_CRM_meta_notify_type}" != "xpost" ]; then
|
|
|
8d4b3d |
- return $OCF_SUCCESS
|
|
|
8d4b3d |
- fi
|
|
|
8d4b3d |
-
|
|
|
8d4b3d |
- # Only the first node not stopping performs evacuates for now
|
|
|
8d4b3d |
- # Can we allow all of them to do it? It would make this block much simpler.
|
|
|
8d4b3d |
- for host in ${OCF_RESKEY_CRM_meta_notify_active_uname}; do
|
|
|
8d4b3d |
- for stop in ${OCF_RESKEY_CRM_meta_notify_stop_uname}; do
|
|
|
8d4b3d |
- if [ "$stop" = "$host" ]; then
|
|
|
8d4b3d |
- : $host is one of the nodes that is stopping
|
|
|
8d4b3d |
-
|
|
|
8d4b3d |
- elif [ "x$(echo ${host} | awk -F. '{print $1}')" != "x$(uname -n | awk -F. '{print $1}')" ]; then
|
|
|
8d4b3d |
- : We are not the first non-stopping node
|
|
|
8d4b3d |
- return $OCF_SUCCESS
|
|
|
8d4b3d |
-
|
|
|
8d4b3d |
- else
|
|
|
8d4b3d |
- # Also repeat for any peer NOT in active_uname somehow?
|
|
|
8d4b3d |
- for node in $OCF_RESKEY_CRM_meta_notify_stop_uname; do
|
|
|
8d4b3d |
- ocf_log info "Performing evacuations for $node"
|
|
|
8d4b3d |
- fence_compute ${fence_options} -o reboot -n $node
|
|
|
8d4b3d |
- done
|
|
|
8d4b3d |
- return $OCF_SUCCESS
|
|
|
8d4b3d |
- fi
|
|
|
8d4b3d |
- done
|
|
|
8d4b3d |
- done
|
|
|
8d4b3d |
+ return $OCF_SUCCESS
|
|
|
8d4b3d |
}
|
|
|
8d4b3d |
|
|
|
8d4b3d |
nova_validate() {
|
|
|
8d4b3d |
@@ -246,7 +251,6 @@ nova_validate() {
|
|
|
8d4b3d |
fence_options=""
|
|
|
8d4b3d |
|
|
|
8d4b3d |
check_binary openstack-config
|
|
|
8d4b3d |
- check_binary fence_compute
|
|
|
8d4b3d |
check_binary nova-compute
|
|
|
8d4b3d |
|
|
|
8d4b3d |
if [ ! -f /etc/nova/nova.conf ]; then
|
|
|
8d4b3d |
@@ -337,6 +341,7 @@ nova_validate() {
|
|
|
8d4b3d |
return $rc
|
|
|
8d4b3d |
}
|
|
|
8d4b3d |
|
|
|
8d4b3d |
+: ${OCF_RESKEY_evacuation_delay=120}
|
|
|
8d4b3d |
case $__OCF_ACTION in
|
|
|
8d4b3d |
meta-data) meta_data
|
|
|
8d4b3d |
exit $OCF_SUCCESS
|
|
|
8d4b3d |
@@ -346,12 +351,10 @@ usage|help) nova_usage
|
|
|
8d4b3d |
;;
|
|
|
8d4b3d |
esac
|
|
|
8d4b3d |
|
|
|
8d4b3d |
-nova_validate
|
|
|
8d4b3d |
-
|
|
|
8d4b3d |
case $__OCF_ACTION in
|
|
|
8d4b3d |
-start) nova_start;;
|
|
|
8d4b3d |
+start) nova_validate; nova_start;;
|
|
|
8d4b3d |
stop) nova_stop;;
|
|
|
8d4b3d |
-monitor) nova_monitor;;
|
|
|
8d4b3d |
+monitor) nova_validate; nova_monitor;;
|
|
|
8d4b3d |
notify) nova_notify;;
|
|
|
8d4b3d |
validate-all) exit $OCF_SUCCESS;;
|
|
|
8d4b3d |
*) nova_usage
|
|
|
8d4b3d |
diff --git a/heartbeat/NovaEvacuate b/heartbeat/NovaEvacuate
|
|
|
8d4b3d |
new file mode 100755
|
|
|
8d4b3d |
index 0000000..f9a24f1
|
|
|
8d4b3d |
--- /dev/null
|
|
|
8d4b3d |
+++ b/heartbeat/NovaEvacuate
|
|
|
8d4b3d |
@@ -0,0 +1,311 @@
|
|
|
8d4b3d |
+#!/bin/sh
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# NovaCompute agent manages compute daemons.
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# Copyright (c) 2015
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# This program is free software; you can redistribute it and/or modify
|
|
|
8d4b3d |
+# it under the terms of version 2 of the GNU General Public License as
|
|
|
8d4b3d |
+# published by the Free Software Foundation.
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# This program is distributed in the hope that it would be useful, but
|
|
|
8d4b3d |
+# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8d4b3d |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# Further, this software is distributed without any warranty that it is
|
|
|
8d4b3d |
+# free of the rightful claim of any third person regarding infringement
|
|
|
8d4b3d |
+# or the like. Any license provided herein, whether implied or
|
|
|
8d4b3d |
+# otherwise, applies only to this software file. Patent licenses, if
|
|
|
8d4b3d |
+# any, provided herein do not apply to combinations of this program with
|
|
|
8d4b3d |
+# other software, or any other product whatsoever.
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+# You should have received a copy of the GNU General Public License
|
|
|
8d4b3d |
+# along with this program; if not, write the Free Software Foundation,
|
|
|
8d4b3d |
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
8d4b3d |
+#
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+#######################################################################
|
|
|
8d4b3d |
+# Initialization:
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+###
|
|
|
8d4b3d |
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
|
|
|
8d4b3d |
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
|
|
|
8d4b3d |
+###
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+: ${__OCF_ACTION=$1}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+#######################################################################
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+meta_data() {
|
|
|
8d4b3d |
+ cat <
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<resource-agent name="NovaEvacuate" version="1.0">
|
|
|
8d4b3d |
+<version>1.0</version>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Facility for tacking a list of compute nodes and reliably evacuating the ones that fence_evacuate has flagged.
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Evacuator for OpenStack Nova Compute Server</shortdesc>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameters>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="auth_url" unique="0" required="1">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Authorization URL for connecting to keystone in admin context
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Authorization URL</shortdesc>
|
|
|
8d4b3d |
+<content type="string" default="" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="username" unique="0" required="1">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Username for connecting to keystone in admin context
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Username</shortdesc>
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="password" unique="0" required="1">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Password for connecting to keystone in admin context
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Password</shortdesc>
|
|
|
8d4b3d |
+<content type="string" default="" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="tenant_name" unique="0" required="1">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Tenant name for connecting to keystone in admin context.
|
|
|
8d4b3d |
+Note that with Keystone V3 tenant names are only unique within a domain.
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Tenant name</shortdesc>
|
|
|
8d4b3d |
+<content type="string" default="" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="endpoint_type" unique="0" required="0">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Nova API location (internal, public or admin URL)
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Nova API location (internal, public or admin URL)</shortdesc>
|
|
|
8d4b3d |
+<content type="string" default="" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<parameter name="no_shared_storage" unique="0" required="0">
|
|
|
8d4b3d |
+<longdesc lang="en">
|
|
|
8d4b3d |
+Disable shared storage recovery for instances. Use at your own risk!
|
|
|
8d4b3d |
+</longdesc>
|
|
|
8d4b3d |
+<shortdesc lang="en">Disable shared storage recovery for instances</shortdesc>
|
|
|
8d4b3d |
+<content type="boolean" default="0" />
|
|
|
8d4b3d |
+</parameter>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+</parameters>
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+<actions>
|
|
|
8d4b3d |
+<action name="start" timeout="20" />
|
|
|
8d4b3d |
+<action name="stop" timeout="20" />
|
|
|
8d4b3d |
+<action name="monitor" timeout="600" interval="10" depth="0"/>
|
|
|
8d4b3d |
+<action name="validate-all" timeout="20" />
|
|
|
8d4b3d |
+<action name="meta-data" timeout="5" />
|
|
|
8d4b3d |
+</actions>
|
|
|
8d4b3d |
+</resource-agent>
|
|
|
8d4b3d |
+END
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+#######################################################################
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+# don't exit on TERM, to test that lrmd makes sure that we do exit
|
|
|
8d4b3d |
+trap sigterm_handler TERM
|
|
|
8d4b3d |
+sigterm_handler() {
|
|
|
8d4b3d |
+ ocf_log info "They use TERM to bring us down. No such luck."
|
|
|
8d4b3d |
+ return
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+evacuate_usage() {
|
|
|
8d4b3d |
+ cat <
|
|
|
8d4b3d |
+usage: $0 {start|stop|monitor|validate-all|meta-data}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+Expects to have a fully populated OCF RA-compliant environment set.
|
|
|
8d4b3d |
+END
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+evacuate_stop() {
|
|
|
8d4b3d |
+ rm -f "$statefile"
|
|
|
8d4b3d |
+ return $OCF_SUCCESS
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+evacuate_start() {
|
|
|
8d4b3d |
+ touch "$statefile"
|
|
|
8d4b3d |
+ # Do not invole monitor here so that the start timeout can be low
|
|
|
8d4b3d |
+ return $?
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+update_evacuation() {
|
|
|
8d4b3d |
+ attrd_updater -p -n evacute -Q -N ${1} -v ${2}
|
|
|
8d4b3d |
+ arc=$?
|
|
|
8d4b3d |
+ if [ ${arc} != 0 ]; then
|
|
|
8d4b3d |
+ ocf_log warn "Can not set evacuation state of ${1} to ${2}: ${arc}"
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ return ${arc}
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+handle_evacuations() {
|
|
|
8d4b3d |
+ while [ $# -gt 0 ]; do
|
|
|
8d4b3d |
+ node=$1
|
|
|
8d4b3d |
+ state=$2
|
|
|
8d4b3d |
+ shift; shift;
|
|
|
8d4b3d |
+ need_evacuate=0
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ case $state in
|
|
|
8d4b3d |
+ "") ;;
|
|
|
8d4b3d |
+ no) ocf_log debug "$node is either fine or already handled";;
|
|
|
8d4b3d |
+ yes) need_evacuate=1;;
|
|
|
8d4b3d |
+ *@*)
|
|
|
8d4b3d |
+ where=$(echo $state | awk -F@ '{print $1}')
|
|
|
8d4b3d |
+ when=$(echo $state | awk -F@ '{print $2}')
|
|
|
8d4b3d |
+ now=$(date +%s)
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ $(($now - $when)) -gt 60 ]; then
|
|
|
8d4b3d |
+ ocf_log info "Processing partial evacuation of $node by $where at $when"
|
|
|
8d4b3d |
+ need_evacuate=1
|
|
|
8d4b3d |
+ else
|
|
|
8d4b3d |
+ # Give some time for any in-flight evacuations to either complete or fail
|
|
|
8d4b3d |
+ # Nova won't react well if there are two overlapping requests
|
|
|
8d4b3d |
+ ocf_log info "Deferring processing partial evacuation of $node by $where at $when"
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ ;;
|
|
|
8d4b3d |
+ esac
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ $need_evacuate = 1 ]; then
|
|
|
8d4b3d |
+ found=0
|
|
|
8d4b3d |
+ ocf_log notice "Initiating evacuation of $node"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ for known in $(fence_compute ${fence_options} -o list | tr -d ','); do
|
|
|
8d4b3d |
+ if [ ${known} = ${node} ]; then
|
|
|
8d4b3d |
+ found=1
|
|
|
8d4b3d |
+ break
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ done
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ $found = 0 ]; then
|
|
|
8d4b3d |
+ ocf_log info "Nova does not know about ${node}"
|
|
|
8d4b3d |
+ # Dont mark as no because perhaps nova is unavailable right now
|
|
|
8d4b3d |
+ continue
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ update_evacuation ${node} "$(uname -n)@$(date +%s)"
|
|
|
8d4b3d |
+ if [ $? != 0 ]; then
|
|
|
8d4b3d |
+ return $OCF_SUCCESS
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ fence_compute ${fence_options} -o reboot -n $node
|
|
|
8d4b3d |
+ rc=$?
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ $rc = 0 ]; then
|
|
|
8d4b3d |
+ update_evacuation ${node} no
|
|
|
8d4b3d |
+ ocf_log notice "Completed evacuation of $node"
|
|
|
8d4b3d |
+ else
|
|
|
8d4b3d |
+ ocf_log warn "Evacuation of $node failed: $rc"
|
|
|
8d4b3d |
+ update_evacuation ${node} yes
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ done
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ return $OCF_SUCCESS
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+evacuate_monitor() {
|
|
|
8d4b3d |
+ if [ ! -f "$statefile" ]; then
|
|
|
8d4b3d |
+ return $OCF_NOT_RUNNING
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ handle_evacuations $(attrd_updater -n evacute -A | tr '="' ' ' | awk '{print $4" "$6}')
|
|
|
8d4b3d |
+ return $OCF_SUCCESS
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+evacuate_validate() {
|
|
|
8d4b3d |
+ rc=$OCF_SUCCESS
|
|
|
8d4b3d |
+ fence_options=""
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ check_binary fence_compute
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ # Is the state directory writable?
|
|
|
8d4b3d |
+ state_dir=$(dirname $statefile)
|
|
|
8d4b3d |
+ touch "$state_dir/$$"
|
|
|
8d4b3d |
+ if [ $? != 0 ]; then
|
|
|
8d4b3d |
+ ocf_exit_reason "Invalid state directory: $state_dir"
|
|
|
8d4b3d |
+ return $OCF_ERR_ARGS
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ rm -f "$state_dir/$$"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -z "${OCF_RESKEY_auth_url}" ]; then
|
|
|
8d4b3d |
+ ocf_exit_reason "auth_url not configured"
|
|
|
8d4b3d |
+ exit $OCF_ERR_CONFIGURED
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -z "${OCF_RESKEY_username}" ]; then
|
|
|
8d4b3d |
+ ocf_exit_reason "username not configured"
|
|
|
8d4b3d |
+ exit $OCF_ERR_CONFIGURED
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ fence_options="${fence_options} -l ${OCF_RESKEY_username}"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -z "${OCF_RESKEY_password}" ]; then
|
|
|
8d4b3d |
+ ocf_exit_reason "password not configured"
|
|
|
8d4b3d |
+ exit $OCF_ERR_CONFIGURED
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ fence_options="${fence_options} -p ${OCF_RESKEY_password}"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -z "${OCF_RESKEY_tenant_name}" ]; then
|
|
|
8d4b3d |
+ ocf_exit_reason "tenant_name not configured"
|
|
|
8d4b3d |
+ exit $OCF_ERR_CONFIGURED
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
|
|
|
8d4b3d |
+ if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
|
|
|
8d4b3d |
+ fence_options="${fence_options} --no-shared-storage"
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
|
|
|
8d4b3d |
+ case ${OCF_RESKEY_endpoint_type} in
|
|
|
8d4b3d |
+ adminURL|publicURL|internalURL) ;;
|
|
|
8d4b3d |
+ *)
|
|
|
8d4b3d |
+ ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
|
|
|
8d4b3d |
+ exit $OCF_ERR_CONFIGURED
|
|
|
8d4b3d |
+ ;;
|
|
|
8d4b3d |
+ esac
|
|
|
8d4b3d |
+ fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+ if [ $rc != $OCF_SUCCESS ]; then
|
|
|
8d4b3d |
+ exit $rc
|
|
|
8d4b3d |
+ fi
|
|
|
8d4b3d |
+ return $rc
|
|
|
8d4b3d |
+}
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
|
|
|
8d4b3d |
+
|
|
|
8d4b3d |
+case $__OCF_ACTION in
|
|
|
8d4b3d |
+start) evacuate_validate; evacuate_start;;
|
|
|
8d4b3d |
+stop) evacuate_stop;;
|
|
|
8d4b3d |
+monitor) evacuate_validate; evacuate_monitor;;
|
|
|
8d4b3d |
+meta-data) meta_data
|
|
|
8d4b3d |
+ exit $OCF_SUCCESS
|
|
|
8d4b3d |
+ ;;
|
|
|
8d4b3d |
+usage|help) evacuate_usage
|
|
|
8d4b3d |
+ exit $OCF_SUCCESS
|
|
|
8d4b3d |
+ ;;
|
|
|
8d4b3d |
+validate-all) exit $OCF_SUCCESS;;
|
|
|
8d4b3d |
+*) evacuate_usage
|
|
|
8d4b3d |
+ exit $OCF_ERR_UNIMPLEMENTED
|
|
|
8d4b3d |
+ ;;
|
|
|
8d4b3d |
+esac
|
|
|
8d4b3d |
+rc=$?
|
|
|
8d4b3d |
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
|
|
|
8d4b3d |
+exit $rc
|
|
|
8d4b3d |
--
|
|
|
8d4b3d |
1.8.4.2
|
|
|
8d4b3d |
|