Blame SOURCES/bz1282723-novacompute-novaevacuate-fix-evacute-typo.patch

4efcdb
diff -uNr a/doc/man/Makefile.am b/doc/man/Makefile.am
937446
--- a/doc/man/Makefile.am	2016-02-02 14:49:34.546698286 +0100
937446
+++ b/doc/man/Makefile.am	2016-02-02 14:50:29.893979453 +0100
4efcdb
@@ -73,7 +73,7 @@
4efcdb
                           ocf_heartbeat_MailTo.7 \
4efcdb
                           ocf_heartbeat_ManageRAID.7 \
4efcdb
                           ocf_heartbeat_ManageVE.7 \
4efcdb
-                          ocf_heartbeat_NovaCompute.7 \
4efcdb
+                          ocf_heartbeat_nova-compute-wait.7 \
4efcdb
                           ocf_heartbeat_NovaEvacuate.7 \
4efcdb
                           ocf_heartbeat_Pure-FTPd.7 \
4efcdb
                           ocf_heartbeat_Raid1.7 \
4efcdb
diff -uNr a/heartbeat/Makefile.am b/heartbeat/Makefile.am
937446
--- a/heartbeat/Makefile.am	2016-02-02 14:49:34.546698286 +0100
937446
+++ b/heartbeat/Makefile.am	2016-02-02 14:50:29.894979440 +0100
4efcdb
@@ -52,7 +52,7 @@
4efcdb
 IPv6addr_LDADD          = -lplumb $(LIBNETLIBS)
4efcdb
 send_ua_LDADD           = $(LIBNETLIBS)
4efcdb
 
4efcdb
-osp_SCRIPTS	     =  NovaCompute		\
4efcdb
+osp_SCRIPTS	     =  nova-compute-wait	\
4efcdb
 			NovaEvacuate
4efcdb
 
4efcdb
 ocf_SCRIPTS	     =  ClusterMon		\
4efcdb
diff -uNr a/heartbeat/NovaCompute b/heartbeat/NovaCompute
937446
--- a/heartbeat/NovaCompute	2016-02-02 14:49:34.541698351 +0100
4efcdb
+++ b/heartbeat/NovaCompute	1970-01-01 01:00:00.000000000 +0100
4efcdb
@@ -1,366 +0,0 @@
4efcdb
-#!/bin/sh
4efcdb
-#
4efcdb
-#
4efcdb
-# NovaCompute agent manages compute daemons.
4efcdb
-#
4efcdb
-# Copyright (c) 2015
4efcdb
-#
4efcdb
-# This program is free software; you can redistribute it and/or modify
4efcdb
-# it under the terms of version 2 of the GNU General Public License as
4efcdb
-# published by the Free Software Foundation.
4efcdb
-#
4efcdb
-# This program is distributed in the hope that it would be useful, but
4efcdb
-# WITHOUT ANY WARRANTY; without even the implied warranty of
4efcdb
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4efcdb
-#
4efcdb
-# Further, this software is distributed without any warranty that it is
4efcdb
-# free of the rightful claim of any third person regarding infringement
4efcdb
-# or the like.  Any license provided herein, whether implied or
4efcdb
-# otherwise, applies only to this software file.  Patent licenses, if
4efcdb
-# any, provided herein do not apply to combinations of this program with
4efcdb
-# other software, or any other product whatsoever.
4efcdb
-#
4efcdb
-# You should have received a copy of the GNU General Public License
4efcdb
-# along with this program; if not, write the Free Software Foundation,
4efcdb
-# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
4efcdb
-#
4efcdb
-
4efcdb
-#######################################################################
4efcdb
-# Initialization:
4efcdb
-
4efcdb
-###
4efcdb
-: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
4efcdb
-. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
4efcdb
-###
4efcdb
-
4efcdb
-: ${__OCF_ACTION=$1}
4efcdb
-
4efcdb
-#######################################################################
4efcdb
-
4efcdb
-meta_data() {
4efcdb
-	cat <
4efcdb
-
4efcdb
-
4efcdb
-<resource-agent name="NovaCompute" version="1.0">
4efcdb
-<version>1.0</version>
4efcdb
-
4efcdb
-<longdesc lang="en">
4efcdb
-OpenStack Nova Compute Server.
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">OpenStack Nova Compute Server</shortdesc>
4efcdb
-
4efcdb
-<parameters>
4efcdb
-
4efcdb
-<parameter name="auth_url" unique="0" required="1">
4efcdb
-<longdesc lang="en">
4efcdb
-Authorization URL for connecting to keystone in admin context
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Authorization URL</shortdesc>
4efcdb
-<content type="string" default="" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="username" unique="0" required="1">
4efcdb
-<longdesc lang="en">
4efcdb
-Username for connecting to keystone in admin context
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Username</shortdesc>
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="password" unique="0" required="1">
4efcdb
-<longdesc lang="en">
4efcdb
-Password for connecting to keystone in admin context
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Password</shortdesc>
4efcdb
-<content type="string" default="" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="tenant_name" unique="0" required="1">
4efcdb
-<longdesc lang="en">
4efcdb
-Tenant name for connecting to keystone in admin context.
4efcdb
-Note that with Keystone V3 tenant names are only unique within a domain.
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Tenant name</shortdesc>
4efcdb
-<content type="string" default="" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="domain" unique="0" required="0">
4efcdb
-<longdesc lang="en">
4efcdb
-DNS domain in which hosts live, useful when the cluster uses short names and nova uses FQDN
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">DNS domain</shortdesc>
4efcdb
-<content type="string" default="" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="endpoint_type" unique="0" required="0">
4efcdb
-<longdesc lang="en">
4efcdb
-Nova API location (internal, public or admin URL)
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Nova API location (internal, public or admin URL)</shortdesc>
4efcdb
-<content type="string" default="" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="no_shared_storage" unique="0" required="0">
4efcdb
-<longdesc lang="en">
4efcdb
-Disable shared storage recovery for instances. Use at your own risk!
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Disable shared storage recovery for instances</shortdesc>
4efcdb
-<content type="boolean" default="0" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-<parameter name="evacuation_delay" unique="0" required="0">
4efcdb
-<longdesc lang="en">
4efcdb
-How long to wait for nova to finish evacuating instances elsewhere
4efcdb
-before starting nova-compute.  Only used when the agent detects
4efcdb
-evacuations might be in progress.
4efcdb
-
4efcdb
-You may need to increase the start timeout when increasing this value.
4efcdb
-</longdesc>
4efcdb
-<shortdesc lang="en">Delay to allow evacuations time to complete</shortdesc>
4efcdb
-<content type="integer" default="120" />
4efcdb
-</parameter>
4efcdb
-
4efcdb
-</parameters>
4efcdb
-
4efcdb
-<actions>
4efcdb
-<action name="start"        timeout="600" />
4efcdb
-<action name="stop"         timeout="300" />
4efcdb
-<action name="monitor"      timeout="20" interval="10" depth="0"/>
4efcdb
-<action name="validate-all" timeout="20" />
4efcdb
-<action name="meta-data"    timeout="5" />
4efcdb
-</actions>
4efcdb
-</resource-agent>
4efcdb
-END
4efcdb
-}
4efcdb
-
4efcdb
-#######################################################################
4efcdb
-
4efcdb
-# don't exit on TERM, to test that lrmd makes sure that we do exit
4efcdb
-trap sigterm_handler TERM
4efcdb
-sigterm_handler() {
4efcdb
-	ocf_log info "They use TERM to bring us down. No such luck."
4efcdb
-	return
4efcdb
-}
4efcdb
-
4efcdb
-nova_usage() {
4efcdb
-	cat <
4efcdb
-usage: $0 {start|stop|monitor|validate-all|meta-data}
4efcdb
-
4efcdb
-Expects to have a fully populated OCF RA-compliant environment set.
4efcdb
-END
4efcdb
-}
4efcdb
-
4efcdb
-nova_pid() {
4efcdb
-    ps axf | grep python.*nova-compute | grep -v grep | awk '{print $1}'
4efcdb
-}
4efcdb
-
4efcdb
-nova_start() {
4efcdb
-    nova_monitor
4efcdb
-    if [ $? = $OCF_SUCCESS ]; then
4efcdb
-	return $OCF_SUCCESS
4efcdb
-    fi
4efcdb
-
937446
-    state=$(attrd_updater -p -n evacute -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
4efcdb
-    if [ "x$state" = x ]; then
4efcdb
-	: never been fenced
4efcdb
-
4efcdb
-    elif [ "x$state" = xno ]; then
4efcdb
-	: has been evacuated, however it could have been 1s ago
4efcdb
-	ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
4efcdb
-	sleep ${OCF_RESKEY_evacuation_delay}
4efcdb
-
4efcdb
-    else
4efcdb
-	ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
4efcdb
-	while [ "x$state" != "xno" ]; do
937446
-	    state=$(attrd_updater -p -n evacute -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
4efcdb
-	    sleep 5
4efcdb
-	done
4efcdb
-
4efcdb
-	ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
4efcdb
-	sleep ${OCF_RESKEY_evacuation_delay}
4efcdb
-    fi
4efcdb
-
4efcdb
-    export LIBGUESTFS_ATTACH_METHOD=appliance
4efcdb
-    su nova -s /bin/sh -c /usr/bin/nova-compute &
4efcdb
-
4efcdb
-    rc=$OCF_NOT_RUNNING
4efcdb
-    ocf_log info "Waiting for nova to start"
4efcdb
-    while [ $rc != $OCF_SUCCESS ]; do
4efcdb
-	nova_monitor
4efcdb
-	rc=$?
4efcdb
-    done
4efcdb
-
4efcdb
-##   TEMPORARY disable call to "service enable" that seems to create
4efcdb
-##   issues and it is unnecessary since fence_compute doesn't disable
4efcdb
-##   the service
4efcdb
-
4efcdb
-#    if [ "x${OCF_RESKEY_domain}" != x ]; then
4efcdb
-#	export service_host="${NOVA_HOST}.${OCF_RESKEY_domain}"
4efcdb
-#    else
4efcdb
-#	export service_host="${NOVA_HOST}"
4efcdb
-#    fi
4efcdb
-
4efcdb
-#    python -c "import os; from novaclient import client as nova_client; nova = nova_client.Client('2', os.environ.get('OCF_RESKEY_username'), os.environ.get('OCF_RESKEY_password'), os.environ.get('OCF_RESKEY_tenant_name'), os.environ.get('OCF_RESKEY_auth_url')); nova.services.enable(os.environ.get('service_host'), 'nova-compute');"
4efcdb
-
4efcdb
-#    rc=$?
4efcdb
-#    if [ $rc != 0 ]; then
4efcdb
-#	ocf_exit_reason "nova.services.enable failed $rc"
4efcdb
-#	exit $OCF_NOT_RUNNING
4efcdb
-#    fi
4efcdb
-
4efcdb
-    return $OCF_SUCCESS
4efcdb
-}
4efcdb
-
4efcdb
-nova_stop() {
4efcdb
-    pid=$(nova_pid)
4efcdb
-    if [ "x$pid" != x ]; then
4efcdb
-	su nova -c "kill -TERM $pid" -s /bin/bash	
4efcdb
-    fi
4efcdb
-
4efcdb
-    while [ "x$pid" != x ]; do
4efcdb
-	sleep 1
4efcdb
-	pid=$(nova_pid)
4efcdb
-    done
4efcdb
-    
4efcdb
-    return $OCF_SUCCESS
4efcdb
-}
4efcdb
-
4efcdb
-nova_monitor() {
4efcdb
-    pid=$(nova_pid)
4efcdb
-    if [ "x$pid" != x ]; then
4efcdb
-	## TEMPORARY disable call to fence_compute to avoid noise on first
4efcdb
-	## first startup due to nova-compute not being fast enough to populate
4efcdb
-	## the db and fence_compute checking if node exists and it's enabled
4efcdb
-	#state=$(fence_compute ${fence_options} -o status -n $NOVA_HOST | grep Status)
4efcdb
-	#if [ "x$state" = "xStatus: ON" ]; then
4efcdb
-	    return $OCF_SUCCESS
4efcdb
-	#else
4efcdb
-	#    ocf_exit_reason "Nova status: $state"
4efcdb
-	#    return $OCF_ERR_GENERIC
4efcdb
-	#fi
4efcdb
-    fi
4efcdb
-
4efcdb
-    return $OCF_NOT_RUNNING
4efcdb
-}
4efcdb
-
4efcdb
-nova_notify() {
4efcdb
-    return $OCF_SUCCESS
4efcdb
-}
4efcdb
-
4efcdb
-nova_validate() {
4efcdb
-    rc=$OCF_SUCCESS
4efcdb
-    fence_options=""
4efcdb
-
4efcdb
-    check_binary openstack-config
4efcdb
-    check_binary nova-compute
4efcdb
-
4efcdb
-    if [ ! -f /etc/nova/nova.conf ]; then
4efcdb
-	   ocf_exit_reason "/etc/nova/nova.conf not found"
4efcdb
-	   exit $OCF_ERR_CONFIGURED
4efcdb
-    fi
4efcdb
-
4efcdb
-    if [ -z "${OCF_RESKEY_auth_url}" ]; then
4efcdb
-	   ocf_exit_reason "auth_url not configured"
4efcdb
-	   exit $OCF_ERR_CONFIGURED
4efcdb
-    fi
4efcdb
-
4efcdb
-    fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
4efcdb
-
4efcdb
-    if [ -z "${OCF_RESKEY_username}" ]; then
4efcdb
-	   ocf_exit_reason "username not configured"
4efcdb
-	   exit $OCF_ERR_CONFIGURED
4efcdb
-    fi
4efcdb
-
4efcdb
-    fence_options="${fence_options} -l ${OCF_RESKEY_username}"
4efcdb
-
4efcdb
-    if [ -z "${OCF_RESKEY_password}" ]; then
4efcdb
-	   ocf_exit_reason "password not configured"
4efcdb
-	   exit $OCF_ERR_CONFIGURED
4efcdb
-    fi
4efcdb
-
4efcdb
-    fence_options="${fence_options} -p ${OCF_RESKEY_password}"
4efcdb
-
4efcdb
-    if [ -z "${OCF_RESKEY_tenant_name}" ]; then
4efcdb
-	   ocf_exit_reason "tenant_name not configured"
4efcdb
-	   exit $OCF_ERR_CONFIGURED
4efcdb
-    fi
4efcdb
-
4efcdb
-    fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
4efcdb
-
4efcdb
-    if [ -n "${OCF_RESKEY_domain}" ]; then
4efcdb
-	fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
4efcdb
-    fi
4efcdb
-
4efcdb
-    if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
4efcdb
-	if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
4efcdb
-	    fence_options="${fence_options} --no-shared-storage"
4efcdb
-	fi
4efcdb
-    fi
4efcdb
-
4efcdb
-    if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
4efcdb
-	case ${OCF_RESKEY_endpoint_type} in
4efcdb
-	    adminURL|publicURL|internalURL) ;;
4efcdb
-	    *)
4efcdb
-		ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
4efcdb
-		exit $OCF_ERR_CONFIGURED
4efcdb
-	    ;;
4efcdb
-	esac
4efcdb
-	fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
4efcdb
-    fi
4efcdb
-
4efcdb
-    # we take a chance here and hope that host is either not configured
4efcdb
-    # or configured in nova.conf
4efcdb
-
4efcdb
-    NOVA_HOST=$(openstack-config --get /etc/nova/nova.conf DEFAULT host 2>/dev/null)
4efcdb
-    if [ $? = 1 ]; then
4efcdb
-	if [ "x${OCF_RESKEY_domain}" != x ]; then
4efcdb
-	    NOVA_HOST=$(uname -n | awk -F. '{print $1}')
4efcdb
-	else
4efcdb
-	    NOVA_HOST=$(uname -n)
4efcdb
-	fi
4efcdb
-    fi
4efcdb
-
4efcdb
-    # We only need to check a configured value, calculated ones are fine
4efcdb
-    openstack-config --get /etc/nova/nova.conf DEFAULT host 2>/dev/null
4efcdb
-    if [ $? = 0 ]; then
4efcdb
-	if [ "x${OCF_RESKEY_domain}" != x ]; then
4efcdb
-	    short_host=$(uname -n | awk -F. '{print $1}')
4efcdb
-	    if [ "x$NOVA_HOST" != "x${short_host}" ]; then
4efcdb
-		ocf_exit_reason "Invalid Nova host name, must be ${short_host} in order for instance recovery to function"
4efcdb
-		rc=$OCF_ERR_CONFIGURED
4efcdb
-	    fi
4efcdb
-
4efcdb
-	elif [ "x$NOVA_HOST" != "x$(uname -n)" ]; then
4efcdb
-            ocf_exit_reason "Invalid Nova host name, must be $(uname -n) in order for instance recovery to function"
4efcdb
-	    rc=$OCF_ERR_CONFIGURED
4efcdb
-	fi
4efcdb
-    fi
4efcdb
-
4efcdb
-    if [ $rc != $OCF_SUCCESS ]; then
4efcdb
-	exit $rc
4efcdb
-    fi
4efcdb
-    return $rc
4efcdb
-}
4efcdb
-
4efcdb
-: ${OCF_RESKEY_evacuation_delay=120}
4efcdb
-case $__OCF_ACTION in
4efcdb
-meta-data)	meta_data
4efcdb
-		exit $OCF_SUCCESS
4efcdb
-		;;
4efcdb
-usage|help)	nova_usage
4efcdb
-		exit $OCF_SUCCESS
4efcdb
-		;;
4efcdb
-esac
4efcdb
-
4efcdb
-case $__OCF_ACTION in
4efcdb
-start)		nova_validate; nova_start;;
4efcdb
-stop)		nova_stop;;
4efcdb
-monitor)	nova_validate; nova_monitor;;
4efcdb
-notify)		nova_notify;;
4efcdb
-validate-all)	exit $OCF_SUCCESS;;
4efcdb
-*)		nova_usage
4efcdb
-		exit $OCF_ERR_UNIMPLEMENTED
4efcdb
-		;;
4efcdb
-esac
4efcdb
-rc=$?
4efcdb
-ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
4efcdb
-exit $rc
4efcdb
diff -uNr a/heartbeat/nova-compute-wait b/heartbeat/nova-compute-wait
4efcdb
--- a/heartbeat/nova-compute-wait	1970-01-01 01:00:00.000000000 +0100
937446
+++ b/heartbeat/nova-compute-wait	2016-02-02 14:50:29.894979440 +0100
4efcdb
@@ -0,0 +1,304 @@
4efcdb
+#!/bin/sh
4efcdb
+#
4efcdb
+#
4efcdb
+# nova-compute-wait agent manages compute daemons.
4efcdb
+#
4efcdb
+# Copyright (c) 2015
4efcdb
+#
4efcdb
+# This program is free software; you can redistribute it and/or modify
4efcdb
+# it under the terms of version 2 of the GNU General Public License as
4efcdb
+# published by the Free Software Foundation.
4efcdb
+#
4efcdb
+# This program is distributed in the hope that it would be useful, but
4efcdb
+# WITHOUT ANY WARRANTY; without even the implied warranty of
4efcdb
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
4efcdb
+#
4efcdb
+# Further, this software is distributed without any warranty that it is
4efcdb
+# free of the rightful claim of any third person regarding infringement
4efcdb
+# or the like.  Any license provided herein, whether implied or
4efcdb
+# otherwise, applies only to this software file.  Patent licenses, if
4efcdb
+# any, provided herein do not apply to combinations of this program with
4efcdb
+# other software, or any other product whatsoever.
4efcdb
+#
4efcdb
+# You should have received a copy of the GNU General Public License
4efcdb
+# along with this program; if not, write the Free Software Foundation,
4efcdb
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
4efcdb
+#
4efcdb
+
4efcdb
+#######################################################################
4efcdb
+# Initialization:
4efcdb
+
4efcdb
+###
4efcdb
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
4efcdb
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
4efcdb
+###
4efcdb
+
4efcdb
+: ${__OCF_ACTION=$1}
4efcdb
+
4efcdb
+#######################################################################
4efcdb
+
4efcdb
+meta_data() {
4efcdb
+	cat <
4efcdb
+
4efcdb
+
4efcdb
+<resource-agent name="nova-compute-wait" version="1.0">
4efcdb
+<version>1.0</version>
4efcdb
+
4efcdb
+<longdesc lang="en">
4efcdb
+OpenStack Nova Compute Server.
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">OpenStack Nova Compute Server</shortdesc>
4efcdb
+
4efcdb
+<parameters>
4efcdb
+
4efcdb
+<parameter name="auth_url" unique="0" required="1">
4efcdb
+<longdesc lang="en">
4efcdb
+Authorization URL for connecting to keystone in admin context
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Authorization URL</shortdesc>
4efcdb
+<content type="string" default="" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="username" unique="0" required="1">
4efcdb
+<longdesc lang="en">
4efcdb
+Username for connecting to keystone in admin context
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Username</shortdesc>
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="password" unique="0" required="1">
4efcdb
+<longdesc lang="en">
4efcdb
+Password for connecting to keystone in admin context
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Password</shortdesc>
4efcdb
+<content type="string" default="" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="tenant_name" unique="0" required="1">
4efcdb
+<longdesc lang="en">
4efcdb
+Tenant name for connecting to keystone in admin context.
4efcdb
+Note that with Keystone V3 tenant names are only unique within a domain.
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Tenant name</shortdesc>
4efcdb
+<content type="string" default="" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="domain" unique="0" required="0">
4efcdb
+<longdesc lang="en">
4efcdb
+DNS domain in which hosts live, useful when the cluster uses short names and nova uses FQDN
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">DNS domain</shortdesc>
4efcdb
+<content type="string" default="" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="endpoint_type" unique="0" required="0">
4efcdb
+<longdesc lang="en">
4efcdb
+Nova API location (internal, public or admin URL)
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Nova API location (internal, public or admin URL)</shortdesc>
4efcdb
+<content type="string" default="" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="no_shared_storage" unique="0" required="0">
4efcdb
+<longdesc lang="en">
4efcdb
+Disable shared storage recovery for instances. Use at your own risk!
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Disable shared storage recovery for instances</shortdesc>
4efcdb
+<content type="boolean" default="0" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+<parameter name="evacuation_delay" unique="0" required="0">
4efcdb
+<longdesc lang="en">
4efcdb
+How long to wait for nova to finish evacuating instances elsewhere
4efcdb
+before starting nova-compute.  Only used when the agent detects
4efcdb
+evacuations might be in progress.
4efcdb
+
4efcdb
+You may need to increase the start timeout when increasing this value.
4efcdb
+</longdesc>
4efcdb
+<shortdesc lang="en">Delay to allow evacuations time to complete</shortdesc>
4efcdb
+<content type="integer" default="120" />
4efcdb
+</parameter>
4efcdb
+
4efcdb
+</parameters>
4efcdb
+
4efcdb
+<actions>
4efcdb
+<action name="start"        timeout="600" />
4efcdb
+<action name="stop"         timeout="300" />
4efcdb
+<action name="monitor"      timeout="20" interval="10" depth="0"/>
4efcdb
+<action name="validate-all" timeout="20" />
4efcdb
+<action name="meta-data"    timeout="5" />
4efcdb
+</actions>
4efcdb
+</resource-agent>
4efcdb
+END
4efcdb
+}
4efcdb
+
4efcdb
+#######################################################################
4efcdb
+
4efcdb
+# don't exit on TERM, to test that lrmd makes sure that we do exit
4efcdb
+trap sigterm_handler TERM
4efcdb
+sigterm_handler() {
4efcdb
+	ocf_log info "They use TERM to bring us down. No such luck."
4efcdb
+	return
4efcdb
+}
4efcdb
+
4efcdb
+nova_usage() {
4efcdb
+	cat <
4efcdb
+usage: $0 {start|stop|monitor|validate-all|meta-data}
4efcdb
+
4efcdb
+Expects to have a fully populated OCF RA-compliant environment set.
4efcdb
+END
4efcdb
+}
4efcdb
+
4efcdb
+nova_start() {
4efcdb
+    state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
4efcdb
+    if [ "x$state" = x ]; then
4efcdb
+	: never been fenced
4efcdb
+
4efcdb
+    elif [ "x$state" = xno ]; then
4efcdb
+	: has been evacuated, however it could have been 1s ago
4efcdb
+	ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
4efcdb
+	sleep ${OCF_RESKEY_evacuation_delay}
4efcdb
+
4efcdb
+    else
4efcdb
+	ocf_log info "Waiting for pending evacuations from ${NOVA_HOST}"
4efcdb
+	while [ "x$state" != "xno" ]; do
4efcdb
+	    state=$(attrd_updater -p -n evacuate -N ${NOVA_HOST} | sed -e 's/.*value=//' | tr -d '"' )
4efcdb
+	    sleep 5
4efcdb
+	done
4efcdb
+
4efcdb
+	ocf_log info "Pausing to give evacuations from ${NOVA_HOST} time to complete"
4efcdb
+	sleep ${OCF_RESKEY_evacuation_delay}
4efcdb
+    fi
4efcdb
+    return $OCF_SUCCESS
4efcdb
+}
4efcdb
+
4efcdb
+nova_stop() {
4efcdb
+    return $OCF_SUCCESS
4efcdb
+}
4efcdb
+
4efcdb
+nova_monitor() {
4efcdb
+    return $OCF_SUCCESS
4efcdb
+}
4efcdb
+
4efcdb
+nova_notify() {
4efcdb
+    return $OCF_SUCCESS
4efcdb
+}
4efcdb
+
4efcdb
+nova_validate() {
4efcdb
+    rc=$OCF_SUCCESS
4efcdb
+    fence_options=""
4efcdb
+
4efcdb
+    check_binary openstack-config
4efcdb
+    check_binary nova-compute
4efcdb
+
4efcdb
+    if [ ! -f /etc/nova/nova.conf ]; then
4efcdb
+	   ocf_exit_reason "/etc/nova/nova.conf not found"
4efcdb
+	   exit $OCF_ERR_CONFIGURED
4efcdb
+    fi
4efcdb
+
4efcdb
+    if [ -z "${OCF_RESKEY_auth_url}" ]; then
4efcdb
+	   ocf_exit_reason "auth_url not configured"
4efcdb
+	   exit $OCF_ERR_CONFIGURED
4efcdb
+    fi
4efcdb
+
4efcdb
+    fence_options="${fence_options} -k ${OCF_RESKEY_auth_url}"
4efcdb
+
4efcdb
+    if [ -z "${OCF_RESKEY_username}" ]; then
4efcdb
+	   ocf_exit_reason "username not configured"
4efcdb
+	   exit $OCF_ERR_CONFIGURED
4efcdb
+    fi
4efcdb
+
4efcdb
+    fence_options="${fence_options} -l ${OCF_RESKEY_username}"
4efcdb
+
4efcdb
+    if [ -z "${OCF_RESKEY_password}" ]; then
4efcdb
+	   ocf_exit_reason "password not configured"
4efcdb
+	   exit $OCF_ERR_CONFIGURED
4efcdb
+    fi
4efcdb
+
4efcdb
+    fence_options="${fence_options} -p ${OCF_RESKEY_password}"
4efcdb
+
4efcdb
+    if [ -z "${OCF_RESKEY_tenant_name}" ]; then
4efcdb
+	   ocf_exit_reason "tenant_name not configured"
4efcdb
+	   exit $OCF_ERR_CONFIGURED
4efcdb
+    fi
4efcdb
+
4efcdb
+    fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
4efcdb
+
4efcdb
+    if [ -n "${OCF_RESKEY_domain}" ]; then
4efcdb
+	fence_options="${fence_options} -d ${OCF_RESKEY_domain}"
4efcdb
+    fi
4efcdb
+
4efcdb
+    if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
4efcdb
+	if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
4efcdb
+	    fence_options="${fence_options} --no-shared-storage"
4efcdb
+	fi
4efcdb
+    fi
4efcdb
+
4efcdb
+    if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
4efcdb
+	case ${OCF_RESKEY_endpoint_type} in
4efcdb
+	    adminURL|publicURL|internalURL) ;;
4efcdb
+	    *)
4efcdb
+		ocf_exit_reason "endpoint_type ${OCF_RESKEY_endpoint_type} not valid. Use adminURL or publicURL or internalURL"
4efcdb
+		exit $OCF_ERR_CONFIGURED
4efcdb
+	    ;;
4efcdb
+	esac
4efcdb
+	fence_options="${fence_options} -e ${OCF_RESKEY_endpoint_type}"
4efcdb
+    fi
4efcdb
+
4efcdb
+    # we take a chance here and hope that host is either not configured
4efcdb
+    # or configured in nova.conf
4efcdb
+
4efcdb
+    NOVA_HOST=$(openstack-config --get /etc/nova/nova.conf DEFAULT host 2>/dev/null)
4efcdb
+    if [ $? = 1 ]; then
4efcdb
+	if [ "x${OCF_RESKEY_domain}" != x ]; then
4efcdb
+	    NOVA_HOST=$(uname -n | awk -F. '{print $1}')
4efcdb
+	else
4efcdb
+	    NOVA_HOST=$(uname -n)
4efcdb
+	fi
4efcdb
+    fi
4efcdb
+
4efcdb
+    # We only need to check a configured value, calculated ones are fine
4efcdb
+    openstack-config --get /etc/nova/nova.conf DEFAULT host 2>/dev/null
4efcdb
+    if [ $? = 0 ]; then
4efcdb
+	if [ "x${OCF_RESKEY_domain}" != x ]; then
4efcdb
+	    short_host=$(uname -n | awk -F. '{print $1}')
4efcdb
+	    if [ "x$NOVA_HOST" != "x${short_host}" ]; then
4efcdb
+		ocf_exit_reason "Invalid Nova host name, must be ${short_host} in order for instance recovery to function"
4efcdb
+		rc=$OCF_ERR_CONFIGURED
4efcdb
+	    fi
4efcdb
+
4efcdb
+	elif [ "x$NOVA_HOST" != "x$(uname -n)" ]; then
4efcdb
+            ocf_exit_reason "Invalid Nova host name, must be $(uname -n) in order for instance recovery to function"
4efcdb
+	    rc=$OCF_ERR_CONFIGURED
4efcdb
+	fi
4efcdb
+    fi
4efcdb
+
4efcdb
+    if [ $rc != $OCF_SUCCESS ]; then
4efcdb
+	exit $rc
4efcdb
+    fi
4efcdb
+    return $rc
4efcdb
+}
4efcdb
+
4efcdb
+: ${OCF_RESKEY_evacuation_delay=120}
4efcdb
+case $__OCF_ACTION in
4efcdb
+meta-data)	meta_data
4efcdb
+		exit $OCF_SUCCESS
4efcdb
+		;;
4efcdb
+usage|help)	nova_usage
4efcdb
+		exit $OCF_SUCCESS
4efcdb
+		;;
4efcdb
+esac
4efcdb
+
4efcdb
+case $__OCF_ACTION in
4efcdb
+start)		nova_validate; nova_start;;
4efcdb
+stop)		nova_stop;;
4efcdb
+monitor)	nova_validate; nova_monitor;;
4efcdb
+notify)		nova_notify;;
4efcdb
+validate-all)	exit $OCF_SUCCESS;;
4efcdb
+*)		nova_usage
4efcdb
+		exit $OCF_ERR_UNIMPLEMENTED
4efcdb
+		;;
4efcdb
+esac
4efcdb
+rc=$?
4efcdb
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
4efcdb
+exit $rc
937446
diff -uNr a/heartbeat/NovaEvacuate b/heartbeat/NovaEvacuate
937446
--- a/heartbeat/NovaEvacuate	2016-02-02 14:49:34.541698351 +0100
937446
+++ b/heartbeat/NovaEvacuate	2016-02-02 14:50:22.768072003 +0100
937446
@@ -141,7 +141,7 @@
937446
 }
937446
 
937446
 update_evacuation() {
937446
-    attrd_updater -p -n evacute -Q -N ${1} -v ${2}
937446
+    attrd_updater -p -n evacuate -Q -N ${1} -v ${2}
937446
     arc=$?
937446
     if [ ${arc} != 0 ]; then
937446
 	ocf_log warn "Can not set evacuation state of ${1} to ${2}: ${arc}"
937446
@@ -219,7 +219,12 @@
937446
 	return $OCF_NOT_RUNNING
937446
     fi
937446
 
937446
-    handle_evacuations $(attrd_updater -n evacute -A | tr '="' '  ' | awk '{print $4" "$6}')
937446
+    handle_evacuations $(
937446
+        attrd_updater -n evacuate -A |
937446
+            sed 's/ value=""/ value="no"/' |
937446
+            tr '="' '  ' |
937446
+            awk '{print $4" "$6}'
937446
+    )
937446
     return $OCF_SUCCESS
937446
 }
937446