File 0006-ec2-instance-tag-bsc-947026.patch of Package cluster-glue

# HG changeset patch
# User Kazuhiko Higashi <kazuh@goo.jp>
# Date 1443417289 -32400
# Node ID 70c1608dd39535465b9f04147081436bcc59f611
# Parent  9da0680bc9c0b99eba65b40aac9282a8dd28889a
Dev: stonith: external/ec2: Be able to omit the "port" option.

It changed the following points.

 - the "tag" and the "port" options will be "not" required.

 - if the "port" option is not set, the 2nd argument of ec2 will use as the "port".
   - the 2nd argument of ec2 is "node to fence".

 - the "stat" and "status" action will be same the "monitor" action.
   (for do not use the "port" parameter in "stat" action.)

By this modifications, If it is described uname in the Name tag,
the setting of the "tag" and "port" parameters are no longer necessary.

diff -r 9da0680bc9c0 -r 70c1608dd395 lib/plugins/stonith/external/ec2
--- a/lib/plugins/stonith/external/ec2	Wed Mar 11 13:24:25 2015 +0100
+++ b/lib/plugins/stonith/external/ec2	Mon Sep 28 14:14:49 2015 +0900
@@ -47,7 +47,6 @@
 #######################################################################
 
 quiet=0
-port_default=""
 
 instance_not_found=0
 unknown_are_stopped=0
@@ -57,10 +56,9 @@
 
 sleep_time="1"
 
-ec2_tag=${tag}
+[ -n "$tag" ] && ec2_tag="$tag"
 
 : ${ec2_tag=${ec2_tag_default}}
-: ${port=${port_default}}
 
 function usage()
 {
@@ -94,7 +92,7 @@
 {
 	cat <<EOF
 <parameters>
-	<parameter name="port" unique="1" required="1">
+	<parameter name="port" unique="1" required="0">
 		<content type="string" />
 		<shortdesc lang="en">The name/id/tag of a instance to control/check</shortdesc>
 	</parameter>
@@ -102,7 +100,7 @@
 		<content type="string" default="default" />
 		<shortdesc lang="en">Use a specific profile from your credential file.</shortdesc>
 	</parameter>
-	<parameter name="tag" unique="0" required="1">
+	<parameter name="tag" unique="0" required="0">
 		<content type="string" default="Name" />
 		<shortdesc lang="en">Name of the tag containing the instances uname</shortdesc>
 	</parameter>
@@ -129,7 +127,7 @@
 		<content type="string" default="reboot" />
 		<shortdesc lang="en">Fencing Action</shortdesc>
 	</parameter>
-	<parameter name="port" unique="1" required="1">
+	<parameter name="port" unique="1" required="0">
 		<getopt mixed="-n, --port=[port]" />
 		<content type="string" />
 		<shortdesc lang="en">The name/id/tag of a instance to control/check</shortdesc>
@@ -139,7 +137,7 @@
 		<content type="string" default="default" />
 		<shortdesc lang="en">Use a specific profile from your credential file.</shortdesc>
 	</parameter>
-	<parameter name="tag" unique="0" required="1">
+	<parameter name="tag" unique="0" required="0">
 		<getopt mixed="-t, --tag=[tag]" />
 		<content type="string" default="Name" />
 		<shortdesc lang="en">Name of the tag containing the instances uname</shortdesc>
@@ -219,6 +217,11 @@
 	return $rc
 }
 
+function monitor()
+{
+		# Is the device ok?
+		aws ec2 describe-instances $options | grep INSTANCES &> /dev/null
+}
 
 TEMP=`getopt -o qVho:e:p:n:t:U --long version,help,action:,port:,option:,profile:,tag:,quiet,unknown-are-stopped \
      -n 'fence_ec2' -- "$@"`
@@ -265,6 +268,7 @@
 done
 
 [ -n "$1" ] && action=$1
+[ -n "$2" ] && node_to_fence=$2
 
 if [ -z "$ec2_profile"]; then
 	options="--output text --profile default"
@@ -324,6 +328,10 @@
 	exit 1
 fi
 
+if [ -z "$port" ]; then
+	port="$node_to_fence"
+fi
+
 # get target's instance id
 instance=""
 if [ ! -z "$port" ]; then
@@ -376,8 +384,7 @@
 		done
 	;;
 	monitor)
-		# Is the device ok?
-		aws ec2 describe-instances $options | grep INSTANCES &> /dev/null
+		monitor
 	;;
 	gethosts|hostlist|list)
 		# List of names we know about
@@ -388,7 +395,7 @@
 		echo $a
 	;;
 	stat|status)
-		instance_status $instance > /dev/null
+		monitor
 	;;
 	*) ha_log.sh err "Unknown action: $action"; exit 1;;
 esac
openSUSE Build Service is sponsored by