Blame SOURCES/bz1759115-aws-vpc-route53-2-add-public-and-secondary-ip-support.patch

02ddf4
From 9b77d06bfe3308692946b8ac08bc7ec3399a762b Mon Sep 17 00:00:00 2001
02ddf4
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
02ddf4
Date: Thu, 2 Apr 2020 13:38:30 +0200
02ddf4
Subject: [PATCH 1/2] aws-vpc-route53: cleanup and improvements
02ddf4
02ddf4
---
02ddf4
 heartbeat/aws-vpc-route53.in | 73 ++++++++++++++++++++----------------
02ddf4
 1 file changed, 41 insertions(+), 32 deletions(-)
02ddf4
02ddf4
diff --git a/heartbeat/aws-vpc-route53.in b/heartbeat/aws-vpc-route53.in
02ddf4
index b276dfb3c..1cfc2b01f 100644
02ddf4
--- a/heartbeat/aws-vpc-route53.in
02ddf4
+++ b/heartbeat/aws-vpc-route53.in
02ddf4
@@ -43,8 +43,14 @@
02ddf4
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
02ddf4
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
02ddf4
 
02ddf4
+OCF_RESKEY_hostedzoneid_default=""
02ddf4
+OCF_RESKEY_fullname_default=""
02ddf4
+OCF_RESKEY_ip_default="local"
02ddf4
 OCF_RESKEY_ttl_default=10
02ddf4
 
02ddf4
+: ${OCF_RESKEY_hostedzoneid:=${OCF_RESKEY_hostedzoneid_default}}
02ddf4
+: ${OCF_RESKEY_fullname:=${OCF_RESKEY_fullname_default}}
02ddf4
+: ${OCF_RESKEY_ip:=${OCF_RESKEY_ip_default}}
02ddf4
 : ${OCF_RESKEY_ttl:=${OCF_RESKEY_ttl_default}}
02ddf4
 
02ddf4
 #######################################################################
02ddf4
@@ -104,7 +110,7 @@ Hosted zone ID of Route 53. This is the table of
02ddf4
 the Route 53 record.
02ddf4
 </longdesc>
02ddf4
 <shortdesc lang="en">AWS hosted zone ID</shortdesc>
02ddf4
-<content type="string" default="" />
02ddf4
+<content type="string" default="${OCF_RESKEY_hostedzoneid_default}" />
02ddf4
 </parameter>
02ddf4
 <parameter name="fullname" required="1">
02ddf4
 <longdesc lang="en">
02ddf4
@@ -113,7 +119,7 @@ Example: service.cloud.example.corp.
02ddf4
 Note: The trailing dot is important to Route53!
02ddf4
 </longdesc>
02ddf4
 <shortdesc lang="en">Full service name</shortdesc>
02ddf4
-<content type="string" default="" />
02ddf4
+<content type="string" default="${OCF_RESKEY_fullname_default}" />
02ddf4
 </parameter>
02ddf4
 <parameter name="ttl" required="0">
02ddf4
 <longdesc lang="en">
02ddf4
@@ -189,6 +195,31 @@ r53_validate() {
02ddf4
 	return $OCF_SUCCESS
02ddf4
 }
02ddf4
 
02ddf4
+r53_start() {
02ddf4
+	#
02ddf4
+	# Start agent and config DNS in Route53
02ddf4
+	#
02ddf4
+	ocf_log info "Starting Route53 DNS update...."
02ddf4
+	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
02ddf4
+	r53_monitor
02ddf4
+	if [ $? != $OCF_SUCCESS ]; then
02ddf4
+		ocf_log info "Could not start agent - check configurations"
02ddf4
+		return $OCF_ERR_GENERIC
02ddf4
+	fi
02ddf4
+	return $OCF_SUCCESS
02ddf4
+}
02ddf4
+
02ddf4
+r53_stop() {
02ddf4
+	#
02ddf4
+	# Stop operation doesn't perform any API call or try to remove the DNS record
02ddf4
+	# this mostly because this is not necessarily mandatory or desired
02ddf4
+	# the start and monitor functions will take care of changing the DNS record
02ddf4
+	# if the agent starts in a different cluster node
02ddf4
+	#
02ddf4
+	ocf_log info "Bringing down Route53 agent. (Will NOT remove Route53 DNS record)"
02ddf4
+	return $OCF_SUCCESS
02ddf4
+}
02ddf4
+
02ddf4
 r53_monitor() {
02ddf4
 	#
02ddf4
 	# For every start action the agent  will call Route53 API to check for DNS record
02ddf4
@@ -339,31 +370,6 @@ _update_record() {
02ddf4
 	done
02ddf4
 }
02ddf4
 
02ddf4
-r53_stop() {
02ddf4
-	#
02ddf4
-	# Stop operation doesn't perform any API call or try to remove the DNS record
02ddf4
-	# this mostly because this is not necessarily mandatory or desired
02ddf4
-	# the start and monitor functions will take care of changing the DNS record
02ddf4
-	# if the agent starts in a different cluster node
02ddf4
-	#
02ddf4
-	ocf_log info "Bringing down Route53 agent. (Will NOT remove Route53 DNS record)"
02ddf4
-	return $OCF_SUCCESS
02ddf4
-}
02ddf4
-
02ddf4
-r53_start() {
02ddf4
-	#
02ddf4
-	# Start agent and config DNS in Route53
02ddf4
-	#
02ddf4
-	ocf_log info "Starting Route53 DNS update...."
02ddf4
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
02ddf4
-	r53_monitor
02ddf4
-	if [ $? != $OCF_SUCCESS ]; then
02ddf4
-		ocf_log info "Could not start agent - check configurations"
02ddf4
-		return $OCF_ERR_GENERIC
02ddf4
-	fi
02ddf4
-	return $OCF_SUCCESS
02ddf4
-}
02ddf4
-
02ddf4
 ###############################################################################
02ddf4
 
02ddf4
 case $__OCF_ACTION in
02ddf4
@@ -375,20 +381,23 @@ case $__OCF_ACTION in
02ddf4
 		metadata
02ddf4
 		exit $OCF_SUCCESS
02ddf4
 		;;
02ddf4
-	monitor)
02ddf4
-		r53_monitor
02ddf4
+	start)
02ddf4
+		r53_validate || exit $?
02ddf4
+		r53_start
02ddf4
 		;;
02ddf4
 	stop)
02ddf4
 		r53_stop
02ddf4
 		;;
02ddf4
+	monitor)
02ddf4
+		r53_monitor
02ddf4
+		;;
02ddf4
 	validate-all)
02ddf4
 		r53_validate
02ddf4
 		;;
02ddf4
-	start)
02ddf4
-		r53_start
02ddf4
-		;;
02ddf4
 	*)
02ddf4
 		usage
02ddf4
 		exit $OCF_ERR_UNIMPLEMENTED
02ddf4
 		;;
02ddf4
 esac
02ddf4
+
02ddf4
+exit $?
02ddf4
02ddf4
From 745c6b9b3e331ed3705a641f1ec03a2604de3a1d Mon Sep 17 00:00:00 2001
02ddf4
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
02ddf4
Date: Thu, 2 Apr 2020 13:40:33 +0200
02ddf4
Subject: [PATCH 2/2] aws-vpc-route53: add support for public and secondary
02ddf4
 private IPs
02ddf4
02ddf4
---
02ddf4
 heartbeat/aws-vpc-route53.in | 31 +++++++++++++++++++++++++++++--
02ddf4
 1 file changed, 29 insertions(+), 2 deletions(-)
02ddf4
02ddf4
diff --git a/heartbeat/aws-vpc-route53.in b/heartbeat/aws-vpc-route53.in
02ddf4
index 1cfc2b01f..ca6556951 100644
02ddf4
--- a/heartbeat/aws-vpc-route53.in
02ddf4
+++ b/heartbeat/aws-vpc-route53.in
02ddf4
@@ -121,6 +121,15 @@ Note: The trailing dot is important to Route53!
02ddf4
 <shortdesc lang="en">Full service name</shortdesc>
02ddf4
 <content type="string" default="${OCF_RESKEY_fullname_default}" />
02ddf4
 </parameter>
02ddf4
+<parameter name="ip" required="0">
02ddf4
+<longdesc lang="en">
02ddf4
+IP (local (default), public or secondary private IP address (e.g. 10.0.0.1).
02ddf4
+
02ddf4
+A secondary private IP can be setup with the awsvip agent.
02ddf4
+</longdesc>
02ddf4
+<shortdesc lang="en">Type of IP or secondary private IP address (local, public or e.g. 10.0.0.1)</shortdesc>
02ddf4
+<content type="string" default="${OCF_RESKEY_ip_default}" />
02ddf4
+</parameter>
02ddf4
 <parameter name="ttl" required="0">
02ddf4
 <longdesc lang="en">
02ddf4
 Time to live for Route53 ARECORD
02ddf4
@@ -173,6 +182,15 @@ r53_validate() {
02ddf4
 	# Hosted Zone ID
02ddf4
 	[[ -z "$OCF_RESKEY_hostedzoneid" ]] && ocf_log error "Hosted Zone ID parameter not set $OCF_RESKEY_hostedzoneid!" && exit $OCF_ERR_CONFIGURED
02ddf4
 
02ddf4
+	# Type of IP/secondary IP address
02ddf4
+	case $OCF_RESKEY_ip in
02ddf4
+		local|public|*.*.*.*)
02ddf4
+			;;
02ddf4
+		*)
02ddf4
+			ocf_exit_reason "Invalid value for ip: ${OCF_RESKEY_ip}"
02ddf4
+			exit $OCF_ERR_CONFIGURED
02ddf4
+	esac
02ddf4
+
02ddf4
 	# profile
02ddf4
 	[[ -z "$OCF_RESKEY_profile" ]] && ocf_log error "AWS CLI profile not set $OCF_RESKEY_profile!" && exit $OCF_ERR_CONFIGURED
02ddf4
 
02ddf4
@@ -200,7 +218,7 @@ r53_start() {
02ddf4
 	# Start agent and config DNS in Route53
02ddf4
 	#
02ddf4
 	ocf_log info "Starting Route53 DNS update...."
02ddf4
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
02ddf4
+	_get_ip
02ddf4
 	r53_monitor
02ddf4
 	if [ $? != $OCF_SUCCESS ]; then
02ddf4
 		ocf_log info "Could not start agent - check configurations"
02ddf4
@@ -239,7 +257,7 @@ r53_monitor() {
02ddf4
 	r53_validate
02ddf4
 	ocf_log debug "Checking Route53 record sets"
02ddf4
 	#
02ddf4
-	IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)"
02ddf4
+	_get_ip
02ddf4
 	#
02ddf4
 	if [ "$__OCF_ACTION" = "start" ] || ocf_is_probe ; then
02ddf4
 		#
02ddf4
@@ -308,6 +326,15 @@ r53_monitor() {
02ddf4
 	return $OCF_SUCCESS
02ddf4
 }
02ddf4
 
02ddf4
+_get_ip() {
02ddf4
+	case $OCF_RESKEY_ip in
02ddf4
+		local|public)
02ddf4
+			IPADDRESS="$(curl -s http://169.254.169.254/latest/meta-data/${OCF_RESKEY_ip}-ipv4)";;
02ddf4
+		*.*.*.*)
02ddf4
+			IPADDRESS="${OCF_RESKEY_ip}";;
02ddf4
+	esac
02ddf4
+}
02ddf4
+
02ddf4
 _update_record() {
02ddf4
 	#
02ddf4
 	# This function is the one that will actually execute Route53's API call