Blame SOURCES/bz1497076-NovaEvacuate-Instance-HA-OSP12.patch

3052fb
diff -uNr a/heartbeat/NovaEvacuate b/heartbeat/NovaEvacuate
3052fb
--- a/heartbeat/NovaEvacuate	2017-09-27 11:59:28.430326918 +0200
3052fb
+++ b/heartbeat/NovaEvacuate	2017-09-27 12:04:21.599608299 +0200
3052fb
@@ -77,6 +77,24 @@
3052fb
 <content type="string" default="" />
3052fb
 </parameter>
3052fb
 
3052fb
+<parameter name="region_name" unique="0" required="0">
3052fb
+<longdesc lang="en">
3052fb
+Region name for connecting to nova.
3052fb
+</longdesc>
3052fb
+<shortdesc lang="en">Region name</shortdesc>
3052fb
+<content type="string" default="" />
3052fb
+</parameter>
3052fb
+
3052fb
+<parameter name="insecure" unique="0" required="0">
3052fb
+<longdesc lang="en">
3052fb
+Explicitly allow client to perform "insecure" TLS (https) requests.
3052fb
+The server's certificate will not be verified against any certificate authorities.
3052fb
+This option should be used with caution.
3052fb
+</longdesc>
3052fb
+<shortdesc lang="en">Allow insecure TLS requests</shortdesc>
3052fb
+<content type="boolean" default="0" />
3052fb
+</parameter>
3052fb
+
3052fb
 <parameter name="no_shared_storage" unique="0" required="0">
3052fb
 <longdesc lang="en">
3052fb
 Disable shared storage recovery for instances. Use at your own risk!
3052fb
@@ -85,6 +103,14 @@
3052fb
 <content type="boolean" default="0" />
3052fb
 </parameter>
3052fb
 
3052fb
+<parameter name="verbose" unique="0" required="0">
3052fb
+<longdesc lang="en">
3052fb
+Enable extra logging from the evacuation process
3052fb
+</longdesc>
3052fb
+<shortdesc lang="en">Enable debug logging</shortdesc>
3052fb
+<content type="boolean" default="0" />
3052fb
+</parameter>
3052fb
+
3052fb
 </parameters>
3052fb
 
3052fb
 <actions>
3052fb
@@ -143,16 +169,20 @@
3052fb
 	need_evacuate=0
3052fb
 
3052fb
 	case $state in
3052fb
-	    "") ;;
3052fb
-	    no)  ocf_log debug "$node is either fine or already handled";;
3052fb
-	    yes) need_evacuate=1;; 
3052fb
+	    "")
3052fb
+	        ;;
3052fb
+	    no)
3052fb
+		ocf_log debug "$node is either fine or already handled"
3052fb
+		;;
3052fb
+	    yes) need_evacuate=1
3052fb
+		;; 
3052fb
 	    *@*)
3052fb
 		where=$(echo $state | awk -F@ '{print $1}')
3052fb
 		when=$(echo $state | awk -F@ '{print $2}')
3052fb
 		now=$(date +%s)
3052fb
 
3052fb
 		if [ $(($now - $when)) -gt 60 ]; then
3052fb
-		    ocf_log info "Processing partial evacuation of $node by $where at $when"		
3052fb
+		    ocf_log info "Processing partial evacuation of $node by $where at $when"
3052fb
 		    need_evacuate=1
3052fb
 		else
3052fb
 		    # Give some time for any in-flight evacuations to either complete or fail
3052fb
@@ -163,9 +193,15 @@
3052fb
 	esac
3052fb
 
3052fb
 	if [ $need_evacuate = 1 ]; then
3052fb
-	    ocf_log notice "Initiating evacuation of $node"
3052fb
+	    fence_agent="fence_compute"
3052fb
+
3052fb
+	    if have_binary fence_evacuate
3052fb
+	    then
3052fb
+		fence_agent="fence_evacuate"
3052fb
+	    fi
3052fb
 
3052fb
-	    fence_compute ${fence_options} -o status -n ${node}
3052fb
+	    ocf_log notice "Initiating evacuation of $node with $fence_agent"
3052fb
+	    $fence_agent ${fence_options} -o status -n ${node}
3052fb
 	    if [ $? = 1 ]; then
3052fb
 		ocf_log info "Nova does not know about ${node}"
3052fb
 		# Dont mark as no because perhaps nova is unavailable right now
3052fb
@@ -177,7 +213,7 @@
3052fb
 		return $OCF_SUCCESS
3052fb
 	    fi
3052fb
 
3052fb
-	    fence_compute ${fence_options} -o off -n $node
3052fb
+	    $fence_agent ${fence_options} -o off -n $node
3052fb
 	    rc=$?
3052fb
 
3052fb
 	    if [ $rc = 0 ]; then
3052fb
@@ -211,7 +247,10 @@
3052fb
     rc=$OCF_SUCCESS
3052fb
     fence_options=""
3052fb
 
3052fb
-    check_binary fence_compute
3052fb
+    
3052fb
+    if ! have_binary fence_evacuate; then
3052fb
+       check_binary fence_compute
3052fb
+    fi
3052fb
 
3052fb
     # Is the state directory writable? 
3052fb
     state_dir=$(dirname $statefile)
3052fb
@@ -250,12 +289,29 @@
3052fb
 
3052fb
     fence_options="${fence_options} -t ${OCF_RESKEY_tenant_name}"
3052fb
 
3052fb
+    if [ -n "${OCF_RESKEY_region_name}" ]; then
3052fb
+        fence_options="${fence_options} \
3052fb
+            --region-name ${OCF_RESKEY_region_name}"
3052fb
+    fi
3052fb
+
3052fb
+    if [ -n "${OCF_RESKEY_insecure}" ]; then
3052fb
+        if ocf_is_true "${OCF_RESKEY_insecure}"; then
3052fb
+            fence_options="${fence_options} --insecure"
3052fb
+        fi
3052fb
+    fi
3052fb
+
3052fb
     if [ -n "${OCF_RESKEY_no_shared_storage}" ]; then
3052fb
 	if ocf_is_true "${OCF_RESKEY_no_shared_storage}"; then
3052fb
 	    fence_options="${fence_options} --no-shared-storage"
3052fb
 	fi
3052fb
     fi
3052fb
 
3052fb
+    if [ -n "${OCF_RESKEY_verbose}" ]; then
3052fb
+        if ocf_is_true "${OCF_RESKEY_verbose}"; then
3052fb
+            fence_options="${fence_options} --verbose"
3052fb
+        fi
3052fb
+    fi
3052fb
+
3052fb
     if [ -n "${OCF_RESKEY_endpoint_type}" ]; then
3052fb
 	case ${OCF_RESKEY_endpoint_type} in
3052fb
 	    adminURL|publicURL|internalURL) ;;
3052fb
@@ -276,19 +332,32 @@
3052fb
 statefile="${HA_RSCTMP}/${OCF_RESOURCE_INSTANCE}.active"
3052fb
 
3052fb
 case $__OCF_ACTION in
3052fb
-start)		evacuate_validate; evacuate_start;;
3052fb
-stop)		evacuate_stop;;
3052fb
-monitor)	evacuate_validate; evacuate_monitor;;
3052fb
-meta-data)	meta_data
3052fb
-		exit $OCF_SUCCESS
3052fb
-		;;
3052fb
-usage|help)	evacuate_usage
3052fb
-		exit $OCF_SUCCESS
3052fb
-		;;
3052fb
-validate-all)	exit $OCF_SUCCESS;;
3052fb
-*)		evacuate_usage
3052fb
-		exit $OCF_ERR_UNIMPLEMENTED
3052fb
-		;;
3052fb
+    start)
3052fb
+	evacuate_validate
3052fb
+	evacuate_start
3052fb
+	;;
3052fb
+    stop)
3052fb
+	evacuate_stop
3052fb
+	;;
3052fb
+    monitor)
3052fb
+	evacuate_validate
3052fb
+	evacuate_monitor
3052fb
+	;;
3052fb
+    meta-data)
3052fb
+	meta_data
3052fb
+	exit $OCF_SUCCESS
3052fb
+	;;
3052fb
+    usage|help)
3052fb
+	evacuate_usage
3052fb
+	exit $OCF_SUCCESS
3052fb
+	;;
3052fb
+    validate-all)
3052fb
+	exit $OCF_SUCCESS
3052fb
+	;;
3052fb
+    *)
3052fb
+	evacuate_usage
3052fb
+	exit $OCF_ERR_UNIMPLEMENTED
3052fb
+	;;
3052fb
 esac
3052fb
 rc=$?
3052fb
 ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"