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

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