Blame SOURCES/bz1908146-bz1908147-bz1908148-bz1949114-update-openstack-agents.patch

c45d6b
diff --color -uNr a/heartbeat/Makefile.am b/heartbeat/Makefile.am
c45d6b
--- a/heartbeat/Makefile.am	2022-03-15 16:14:29.355209012 +0100
c45d6b
+++ b/heartbeat/Makefile.am	2022-03-15 16:18:35.917048467 +0100
c45d6b
@@ -217,6 +217,7 @@
c45d6b
 			  lvm-clvm.sh		\
c45d6b
 			  lvm-plain.sh		\
c45d6b
 			  lvm-tag.sh		\
c45d6b
+			  openstack-common.sh	\
c45d6b
 			  ora-common.sh		\
c45d6b
 			  mysql-common.sh	\
c45d6b
 			  nfsserver-redhat.sh	\
c45d6b
diff --color -uNr a/heartbeat/openstack-cinder-volume b/heartbeat/openstack-cinder-volume
c45d6b
--- a/heartbeat/openstack-cinder-volume	2022-03-15 16:14:29.370209063 +0100
c45d6b
+++ b/heartbeat/openstack-cinder-volume	2022-03-15 16:17:36.231840008 +0100
c45d6b
@@ -34,11 +34,11 @@
c45d6b
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
c45d6b
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
c45d6b
 
c45d6b
+. ${OCF_FUNCTIONS_DIR}/openstack-common.sh
c45d6b
+
c45d6b
 # Defaults
c45d6b
-OCF_RESKEY_openstackcli_default="/usr/bin/openstack"
c45d6b
 OCF_RESKEY_volume_local_check_default="true"
c45d6b
 
c45d6b
-: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}}
c45d6b
 : ${OCF_RESKEY_volume_local_check=${OCF_RESKEY_volume_local_check_default}}
c45d6b
 
c45d6b
 #######################################################################
c45d6b
@@ -68,14 +68,11 @@
c45d6b
 <shortdesc lang="en">Attach a cinder volume</shortdesc>
c45d6b
 
c45d6b
 <parameters>
c45d6b
-<parameter name="openstackcli">
c45d6b
-<longdesc lang="en">
c45d6b
-Path to command line tools for openstack.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">Path to Openstack CLI tool</shortdesc>
c45d6b
-<content type="string" default="${OCF_RESKEY_openstackcli_default}" />
c45d6b
-</parameter>
c45d6b
+END
c45d6b
 
c45d6b
+common_meta_data
c45d6b
+
c45d6b
+cat <
c45d6b
 <parameter name="volume_local_check">
c45d6b
 <longdesc lang="en">
c45d6b
 This option allows the cluster to monitor the cinder volume presence without 
c45d6b
@@ -85,28 +82,19 @@
c45d6b
 <content type="boolean" default="${OCF_RESKEY_volume_local_check_default}" />
c45d6b
 </parameter>
c45d6b
 
c45d6b
-<parameter name="openrc" required="1">
c45d6b
-<longdesc lang="en">
c45d6b
-Valid Openstack credentials as openrc file from api_access/openrc.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">openrc file</shortdesc>
c45d6b
-<content type="string" />
c45d6b
-</parameter>
c45d6b
-
c45d6b
 <parameter name="volume_id" required="1">
c45d6b
 <longdesc lang="en">
c45d6b
-Cinder volume identifier to use to attach the bloc storage.
c45d6b
+Cinder volume identifier to use to attach the block storage.
c45d6b
 </longdesc>
c45d6b
 <shortdesc lang="en">Volume ID</shortdesc>
c45d6b
 <content type="string" />
c45d6b
 </parameter>
c45d6b
-
c45d6b
 </parameters>
c45d6b
 
c45d6b
 <actions>
c45d6b
 <action name="start" timeout="180s" />
c45d6b
 <action name="stop" timeout="180s" />
c45d6b
-<action name="monitor" depth="0" timeout="30s" interval="60s" />
c45d6b
+<action name="monitor" depth="0" timeout="180s" interval="60s" />
c45d6b
 <action name="validate-all" timeout="5s" />
c45d6b
 <action name="meta-data" timeout="5s" />
c45d6b
 </actions>
c45d6b
@@ -127,17 +115,7 @@
c45d6b
 osvol_validate() {
c45d6b
 	check_binary "$OCF_RESKEY_openstackcli"
c45d6b
 	
c45d6b
-	if [ -z "$OCF_RESKEY_openrc" ]; then
c45d6b
-		ocf_exit_reason "openrc parameter not set"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	if [ ! -f "$OCF_RESKEY_openrc" ] ; then
c45d6b
-		ocf_exit_reason "openrc file not found"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	. $OCF_RESKEY_openrc
c45d6b
+	get_config
c45d6b
 
c45d6b
 	if ! $OCF_RESKEY_openstackcli volume list|grep -q $OCF_RESKEY_volume_id ; then
c45d6b
 		ocf_exit_reason "volume-id $OCF_RESKEY_volume_id not found"
c45d6b
diff --color -uNr a/heartbeat/openstack-common.sh b/heartbeat/openstack-common.sh
c45d6b
--- a/heartbeat/openstack-common.sh	1970-01-01 01:00:00.000000000 +0100
c45d6b
+++ b/heartbeat/openstack-common.sh	2022-03-15 16:17:36.232840011 +0100
c45d6b
@@ -0,0 +1,147 @@
c45d6b
+OCF_RESKEY_openstackcli_default="/usr/bin/openstack"
c45d6b
+OCF_RESKEY_insecure_default="false"
c45d6b
+
c45d6b
+: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}}
c45d6b
+: ${OCF_RESKEY_insecure=${OCF_RESKEY_insecure_default}}
c45d6b
+
c45d6b
+if ocf_is_true "${OCF_RESKEY_insecure}"; then
c45d6b
+	OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --insecure"
c45d6b
+fi
c45d6b
+
c45d6b
+common_meta_data() {
c45d6b
+	cat <
c45d6b
+
c45d6b
+<parameter name="cloud" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Openstack cloud (from ~/.config/openstack/clouds.yaml or /etc/openstack/clouds.yaml).
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Cloud from clouds.yaml</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="openrc" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Openstack credentials as openrc file from api_access/openrc.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">openrc file</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="auth_url" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Keystone Auth URL
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Keystone Auth URL</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="username" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Username.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Username</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="password" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Password.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Password</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="project_name" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Keystone Project.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Keystone Project</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="user_domain_name" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Keystone User Domain Name.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Keystone User Domain Name</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="project_domain_name" required="0">
c45d6b
+<longdesc lang="en">
c45d6b
+Keystone Project Domain Name.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Keystone Project Domain Name</shortdesc>
c45d6b
+<content type="string" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="openstackcli">
c45d6b
+<longdesc lang="en">
c45d6b
+Path to command line tools for openstack.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Path to Openstack CLI tool</shortdesc>
c45d6b
+<content type="string" default="${OCF_RESKEY_openstackcli_default}" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="insecure">
c45d6b
+<longdesc lang="en">
c45d6b
+Allow insecure connections
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Allow insecure connections</shortdesc>
c45d6b
+<content type="boolean" default="${OCF_RESKEY_insecure_default}" />
c45d6b
+</parameter>
c45d6b
+END
c45d6b
+}
c45d6b
+
c45d6b
+get_config() {
c45d6b
+	if [ -n "$OCF_RESKEY_cloud" ]; then
c45d6b
+		TILDE=$(echo ~)
c45d6b
+		clouds_yaml="$TILDE/.config/openstack/clouds.yaml"
c45d6b
+		if [ ! -f "$clouds_yaml" ]; then
c45d6b
+			clouds_yaml="/etc/openstack/clouds.yaml"
c45d6b
+		fi
c45d6b
+		if [ ! -f "$clouds_yaml" ]; then
c45d6b
+			ocf_exit_reason "~/.config/openstack/clouds.yaml and /etc/openstack/clouds.yaml does not exist"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-cloud $OCF_RESKEY_cloud"
c45d6b
+	elif [ -n "$OCF_RESKEY_openrc" ]; then
c45d6b
+		if [ ! -f "$OCF_RESKEY_openrc" ]; then
c45d6b
+			ocf_exit_reason "$OCF_RESKEY_openrc does not exist"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		. $OCF_RESKEY_openrc
c45d6b
+	else
c45d6b
+		if [ -z "$OCF_RESKEY_auth_url" ]; then
c45d6b
+			ocf_exit_reason "auth_url not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		if [ -z "$OCF_RESKEY_username" ]; then
c45d6b
+			ocf_exit_reason "username not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		if [ -z "$OCF_RESKEY_password" ]; then
c45d6b
+			ocf_exit_reason "password not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		if [ -z "$OCF_RESKEY_project_name" ]; then
c45d6b
+			ocf_exit_reason "project_name not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		if [ -z "$OCF_RESKEY_user_domain_name" ]; then
c45d6b
+			ocf_exit_reason "user_domain_name not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+		if [ -z "$OCF_RESKEY_project_domain_name" ]; then
c45d6b
+			ocf_exit_reason " not set"
c45d6b
+			exit $OCF_ERR_CONFIGURED
c45d6b
+		fi
c45d6b
+
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-auth-url $OCF_RESKEY_auth_url"
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-username $OCF_RESKEY_username"
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-password $OCF_RESKEY_password"
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-project-name $OCF_RESKEY_project_name"
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-user-domain-name $OCF_RESKEY_user_domain_name"
c45d6b
+		OCF_RESKEY_openstackcli="${OCF_RESKEY_openstackcli} --os-project-domain-name $OCF_RESKEY_project_domain_name"
c45d6b
+	fi
c45d6b
+}
c45d6b
diff --color -uNr a/heartbeat/openstack-floating-ip b/heartbeat/openstack-floating-ip
c45d6b
--- a/heartbeat/openstack-floating-ip	2022-03-15 16:14:29.370209063 +0100
c45d6b
+++ b/heartbeat/openstack-floating-ip	2022-03-15 16:17:36.233840014 +0100
c45d6b
@@ -34,10 +34,9 @@
c45d6b
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
c45d6b
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
c45d6b
 
c45d6b
-# Defaults
c45d6b
-OCF_RESKEY_openstackcli_default="/usr/bin/openstack"
c45d6b
+. ${OCF_FUNCTIONS_DIR}/openstack-common.sh
c45d6b
 
c45d6b
-: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}}
c45d6b
+# Defaults
c45d6b
 
c45d6b
 #######################################################################
c45d6b
 
c45d6b
@@ -67,22 +66,11 @@
c45d6b
 <shortdesc lang="en">Move a floating IP</shortdesc>
c45d6b
 
c45d6b
 <parameters>
c45d6b
-<parameter name="openstackcli">
c45d6b
-<longdesc lang="en">
c45d6b
-Path to command line tools for openstack.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">Path to Openstack CLI tool</shortdesc>
c45d6b
-<content type="string" default="${OCF_RESKEY_openstackcli_default}" />
c45d6b
-</parameter>
c45d6b
+END
c45d6b
 
c45d6b
-<parameter name="openrc" required="1">
c45d6b
-<longdesc lang="en">
c45d6b
-Valid Openstack credentials as openrc file from api_access/openrc.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">openrc file</shortdesc>
c45d6b
-<content type="string" />
c45d6b
-</parameter>
c45d6b
+common_meta_data
c45d6b
 
c45d6b
+cat <
c45d6b
 <parameter name="ip_id" required="1">
c45d6b
 <longdesc lang="en">
c45d6b
 Floating IP Identifier.
c45d6b
@@ -104,7 +92,7 @@
c45d6b
 <actions>
c45d6b
 <action name="start" timeout="180s" />
c45d6b
 <action name="stop" timeout="180s" />
c45d6b
-<action name="monitor" depth="0" timeout="30s" interval="60s" />
c45d6b
+<action name="monitor" depth="0" timeout="180s" interval="60s" />
c45d6b
 <action name="validate-all" timeout="5s" />
c45d6b
 <action name="meta-data" timeout="5s" />
c45d6b
 </actions>
c45d6b
@@ -115,17 +103,7 @@
c45d6b
 osflip_validate() {
c45d6b
 	check_binary "$OCF_RESKEY_openstackcli"
c45d6b
 
c45d6b
-	if [ -z "$OCF_RESKEY_openrc" ]; then
c45d6b
-		ocf_exit_reason "openrc parameter not set"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	if [ ! -f "$OCF_RESKEY_openrc" ] ; then
c45d6b
-		ocf_exit_reason "openrc file not found"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	. $OCF_RESKEY_openrc
c45d6b
+	get_config
c45d6b
 
c45d6b
 	if ! $OCF_RESKEY_openstackcli floating ip list|grep -q $OCF_RESKEY_ip_id ; then
c45d6b
 		ocf_exit_reason "ip-id $OCF_RESKEY_ip_id not found"
c45d6b
diff --color -uNr a/heartbeat/openstack-info b/heartbeat/openstack-info
c45d6b
--- a/heartbeat/openstack-info	1970-01-01 01:00:00.000000000 +0100
c45d6b
+++ b/heartbeat/openstack-info	2022-03-15 16:17:36.234840018 +0100
c45d6b
@@ -0,0 +1,270 @@
c45d6b
+#!/bin/sh
c45d6b
+#
c45d6b
+#
c45d6b
+# OCF resource agent to set attributes from Openstack instance details.
c45d6b
+# It records (in the CIB) various attributes of a node
c45d6b
+#
c45d6b
+# Copyright (c) 2018 Mathieu Grzybek
c45d6b
+#          All Rights Reserved.
c45d6b
+#
c45d6b
+# This program is free software; you can redistribute it and/or modify
c45d6b
+# it under the terms of version 2 of the GNU General Public License as
c45d6b
+# published by the Free Software Foundation.
c45d6b
+#
c45d6b
+# This program is distributed in the hope that it would be useful, but
c45d6b
+# WITHOUT ANY WARRANTY; without even the implied warranty of
c45d6b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
c45d6b
+#
c45d6b
+# Further, this software is distributed without any warranty that it is
c45d6b
+# free of the rightful claim of any third person regarding infringement
c45d6b
+# or the like. Any license provided herein, whether implied or
c45d6b
+# otherwise, applies only to this software file. Patent licenses, if
c45d6b
+# any, provided herein do not apply to combinations of this program with
c45d6b
+# other software, or any other product whatsoever.
c45d6b
+#
c45d6b
+# You should have received a copy of the GNU General Public License
c45d6b
+# along with this program; if not, write the Free Software Foundation,
c45d6b
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
c45d6b
+#
c45d6b
+#######################################################################
c45d6b
+# Initialization:
c45d6b
+
c45d6b
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
c45d6b
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
c45d6b
+
c45d6b
+. ${OCF_FUNCTIONS_DIR}/openstack-common.sh
c45d6b
+
c45d6b
+# Defaults
c45d6b
+OCF_RESKEY_pidfile_default="$HA_RSCTMP/OSInfo-${OCF_RESOURCE_HOSTNAME}"
c45d6b
+OCF_RESKEY_delay_default="0"
c45d6b
+OCF_RESKEY_clone_default="0"
c45d6b
+OCF_RESKEY_curlcli_default="/usr/bin/curl"
c45d6b
+OCF_RESKEY_pythoncli_default="/usr/bin/python"
c45d6b
+
c45d6b
+: ${OCF_RESKEY_curlcli=${OCF_RESKEY_curlcli_default}}
c45d6b
+: ${OCF_RESKEY_pythoncli=${OCF_RESKEY_pythoncli_default}}
c45d6b
+: ${OCF_RESKEY_pidfile=${OCF_RESKEY_pidfile_default}}
c45d6b
+: ${OCF_RESKEY_delay=${OCF_RESKEY_delay_default}}
c45d6b
+: ${OCF_RESKEY_clone=${OCF_RESKEY_clone_default}}
c45d6b
+
c45d6b
+#######################################################################
c45d6b
+
c45d6b
+meta_data() {
c45d6b
+	cat <
c45d6b
+
c45d6b
+
c45d6b
+<resource-agent name="openstack-info" version="1.0">
c45d6b
+<version>1.0</version>
c45d6b
+
c45d6b
+<longdesc lang="en">
c45d6b
+OCF resource agent to set attributes from Openstack instance details.
c45d6b
+It records (in the CIB) various attributes of a node.
c45d6b
+Sample output:
c45d6b
+	openstack_az      : nova
c45d6b
+	openstack_flavor  : c1.small
c45d6b
+	openstack_id      : 60ac4343-5828-49b1-8aac-7c69b1417f31
c45d6b
+	openstack_ports   : 7960d889-9750-4160-bf41-c69a41ad72d9:96530d18-57a3-4718-af32-30f2a74c22a2,b0e55a06-bd75-468d-8baa-22cfeb65799f:a55ae917-8016-4b1e-8ffa-04311b9dc7d6
c45d6b
+
c45d6b
+The layout of openstack_ports is a comma-separated list of tuples "subnet_id:port_id".
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Records various node attributes in the CIB</shortdesc>
c45d6b
+
c45d6b
+<parameters>
c45d6b
+END
c45d6b
+
c45d6b
+common_meta_data
c45d6b
+
c45d6b
+	cat <
c45d6b
+<parameter name="pidfile" unique="0">
c45d6b
+<longdesc lang="en">PID file</longdesc>
c45d6b
+<shortdesc lang="en">PID file</shortdesc>
c45d6b
+<content type="string" default="${OCF_RESKEY_pidfile_default}" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="delay" unique="0">
c45d6b
+<longdesc lang="en">Interval to allow values to stabilize</longdesc>
c45d6b
+<shortdesc lang="en">Dampening Delay</shortdesc>
c45d6b
+<content type="string" default="${OCF_RESKEY_delay_default}" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="curlcli">
c45d6b
+<longdesc lang="en">
c45d6b
+Path to command line cURL binary.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Path to cURL binary</shortdesc>
c45d6b
+<content type="string" default="${OCF_RESKEY_curlcli_default}" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+<parameter name="pythoncli">
c45d6b
+<longdesc lang="en">
c45d6b
+Path to command line Python interpreter.
c45d6b
+</longdesc>
c45d6b
+<shortdesc lang="en">Path to Python interpreter</shortdesc>
c45d6b
+<content type="string" default="${OCF_RESKEY_pythoncli_default}" />
c45d6b
+</parameter>
c45d6b
+
c45d6b
+</parameters>
c45d6b
+
c45d6b
+<actions>
c45d6b
+<action name="start"  timeout="180s" />
c45d6b
+<action name="stop" timeout="180s" />
c45d6b
+<action name="monitor" timeout="30s" interval="60s"/>
c45d6b
+<action name="meta-data" timeout="5s" />
c45d6b
+<action name="validate-all" timeout="20s" />
c45d6b
+</actions>
c45d6b
+</resource-agent>
c45d6b
+END
c45d6b
+}
c45d6b
+
c45d6b
+#######################################################################
c45d6b
+
c45d6b
+OSInfoStats() {
c45d6b
+	local result
c45d6b
+	local value
c45d6b
+	local node
c45d6b
+	local node_id
c45d6b
+
c45d6b
+	get_config
c45d6b
+
c45d6b
+	# Nova data: server ID
c45d6b
+	node_id=$($OCF_RESKEY_curlcli \
c45d6b
+		-s http://169.254.169.254/openstack/latest/meta_data.json |
c45d6b
+		$OCF_RESKEY_pythoncli -m json.tool |
c45d6b
+		grep -P '\"uuid\": \".*\",$' |
c45d6b
+		grep -P -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
c45d6b
+
c45d6b
+	if [ $? -ne 0 ] ; then
c45d6b
+		ocf_exit_reason "Cannot find server ID"
c45d6b
+		exit $OCF_ERR_GENERIC
c45d6b
+	fi
c45d6b
+
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_id -v "$node_id"
c45d6b
+
c45d6b
+	# Nova data: flavor
c45d6b
+	value=$($OCF_RESKEY_openstackcli server show \
c45d6b
+		--format value \
c45d6b
+		--column flavor \
c45d6b
+		$node_id)
c45d6b
+
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_flavor -v "$value"
c45d6b
+
c45d6b
+	# Nova data: availability zone
c45d6b
+	value=$($OCF_RESKEY_openstackcli server show \
c45d6b
+		--format value \
c45d6b
+		--column OS-EXT-AZ:availability_zone \
c45d6b
+		$node_id)
c45d6b
+
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_az -v "$value"
c45d6b
+
c45d6b
+	# Network data: ports
c45d6b
+	value=""
c45d6b
+	for port_id in $($OCF_RESKEY_openstackcli port list \
c45d6b
+		--format value \
c45d6b
+		--column id \
c45d6b
+		--server $node_id); do
c45d6b
+		subnet_id=$($OCF_RESKEY_openstackcli port show \
c45d6b
+			--format json \
c45d6b
+			--column fixed_ips \
c45d6b
+			${port_id} | grep -P '\"subnet_id\": \".*\",$' |
c45d6b
+			grep -P -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
c45d6b
+		value+="${subnet_id}:${port_id},"
c45d6b
+	done
c45d6b
+	value=$(echo ${value} | sed -e 's/,$//g')
c45d6b
+
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_ports -v "$value"
c45d6b
+
c45d6b
+	if [ ! -z "$OS_REGION_NAME" ] ; then
c45d6b
+		${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_region -v "$OS_REGION_NAME"
c45d6b
+	fi
c45d6b
+
c45d6b
+	if [ ! -z "$OS_TENANT_ID" ] ; then
c45d6b
+		${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_tenant_id -v "$OS_TENANT_ID"
c45d6b
+
c45d6b
+		if [ ! -z "$OS_TENANT_NAME" ] ; then
c45d6b
+			${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_tenant_name -v "$OS_TENANT_NAME"
c45d6b
+		fi
c45d6b
+	else
c45d6b
+		${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_project_id -v "$OS_PROJECT_ID"
c45d6b
+
c45d6b
+		if [ ! -z "$OS_PROJECT_NAME" ] ; then
c45d6b
+			${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -n openstack_project_name -v "$OS_PROJECT_NAME"
c45d6b
+		fi
c45d6b
+	fi
c45d6b
+
c45d6b
+}
c45d6b
+
c45d6b
+OSInfo_usage() {
c45d6b
+	cat <
c45d6b
+usage: $0 {start|stop|monitor|validate-all|meta-data}
c45d6b
+
c45d6b
+Expects to have a fully populated OCF RA-compliant environment set.
c45d6b
+END
c45d6b
+}
c45d6b
+
c45d6b
+OSInfo_start() {
c45d6b
+	echo $OCF_RESKEY_clone > $OCF_RESKEY_pidfile
c45d6b
+	OSInfoStats
c45d6b
+	exit $OCF_SUCCESS
c45d6b
+}
c45d6b
+
c45d6b
+OSInfo_stop() {
c45d6b
+	rm -f $OCF_RESKEY_pidfile
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_id
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_flavor
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_az
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_ports
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_region
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_tenant_id
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_tenant_name
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_project_id
c45d6b
+	${HA_SBIN_DIR}/attrd_updater ${OCF_RESKEY_delay} -D -n openstack_project_name
c45d6b
+	exit $OCF_SUCCESS
c45d6b
+}
c45d6b
+
c45d6b
+OSInfo_monitor() {
c45d6b
+	if [ -f "$OCF_RESKEY_pidfile" ] ; then
c45d6b
+		OSInfoStats
c45d6b
+		exit $OCF_RUNNING
c45d6b
+	fi
c45d6b
+	exit $OCF_NOT_RUNNING
c45d6b
+}
c45d6b
+
c45d6b
+OSInfo_validate() {
c45d6b
+	check_binary "$OCF_RESKEY_curlcli"
c45d6b
+	check_binary "$OCF_RESKEY_openstackcli"
c45d6b
+	check_binary "$OCF_RESKEY_pythoncli"
c45d6b
+
c45d6b
+	return $OCF_SUCCESS
c45d6b
+}
c45d6b
+
c45d6b
+if [ $# -ne 1 ]; then
c45d6b
+	OSInfo_usage
c45d6b
+	exit $OCF_ERR_ARGS
c45d6b
+fi
c45d6b
+
c45d6b
+if [ x != x${OCF_RESKEY_delay} ]; then
c45d6b
+	OCF_RESKEY_delay="-d ${OCF_RESKEY_delay}"
c45d6b
+fi
c45d6b
+
c45d6b
+case $__OCF_ACTION in
c45d6b
+meta-data)	meta_data
c45d6b
+		exit $OCF_SUCCESS
c45d6b
+		;;
c45d6b
+start)		OSInfo_validate || exit $?
c45d6b
+		OSInfo_start
c45d6b
+		;;
c45d6b
+stop)		OSInfo_stop
c45d6b
+		;;
c45d6b
+monitor)	OSInfo_monitor
c45d6b
+		;;
c45d6b
+validate-all)	OSInfo_validate
c45d6b
+		;;
c45d6b
+usage|help)	OSInfo_usage
c45d6b
+		exit $OCF_SUCCESS
c45d6b
+		;;
c45d6b
+*)		OSInfo_usage
c45d6b
+		exit $OCF_ERR_UNIMPLEMENTED
c45d6b
+		;;
c45d6b
+esac
c45d6b
+
c45d6b
+exit $?
c45d6b
diff --color -uNr a/heartbeat/openstack-info.in b/heartbeat/openstack-info.in
c45d6b
--- a/heartbeat/openstack-info.in	2022-03-15 16:14:29.370209063 +0100
c45d6b
+++ b/heartbeat/openstack-info.in	2022-03-15 16:17:36.234840018 +0100
c45d6b
@@ -32,16 +32,16 @@
c45d6b
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
c45d6b
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
c45d6b
 
c45d6b
+. ${OCF_FUNCTIONS_DIR}/openstack-common.sh
c45d6b
+
c45d6b
 # Defaults
c45d6b
 OCF_RESKEY_pidfile_default="$HA_RSCTMP/OSInfo-${OCF_RESOURCE_HOSTNAME}"
c45d6b
 OCF_RESKEY_delay_default="0"
c45d6b
 OCF_RESKEY_clone_default="0"
c45d6b
 OCF_RESKEY_curlcli_default="/usr/bin/curl"
c45d6b
-OCF_RESKEY_openstackcli_default="/usr/bin/openstack"
c45d6b
 OCF_RESKEY_pythoncli_default="@PYTHON@"
c45d6b
 
c45d6b
 : ${OCF_RESKEY_curlcli=${OCF_RESKEY_curlcli_default}}
c45d6b
-: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}}
c45d6b
 : ${OCF_RESKEY_pythoncli=${OCF_RESKEY_pythoncli_default}}
c45d6b
 : ${OCF_RESKEY_pidfile=${OCF_RESKEY_pidfile_default}}
c45d6b
 : ${OCF_RESKEY_delay=${OCF_RESKEY_delay_default}}
c45d6b
@@ -70,25 +70,23 @@
c45d6b
 <shortdesc lang="en">Records various node attributes in the CIB</shortdesc>
c45d6b
 
c45d6b
 <parameters>
c45d6b
+END
c45d6b
+
c45d6b
+common_meta_data
c45d6b
+
c45d6b
+	cat <
c45d6b
 <parameter name="pidfile" unique="0">
c45d6b
 <longdesc lang="en">PID file</longdesc>
c45d6b
 <shortdesc lang="en">PID file</shortdesc>
c45d6b
 <content type="string" default="${OCF_RESKEY_pidfile_default}" />
c45d6b
 </parameter>
c45d6b
+
c45d6b
 <parameter name="delay" unique="0">
c45d6b
 <longdesc lang="en">Interval to allow values to stabilize</longdesc>
c45d6b
 <shortdesc lang="en">Dampening Delay</shortdesc>
c45d6b
 <content type="string" default="${OCF_RESKEY_delay_default}" />
c45d6b
 </parameter>
c45d6b
 
c45d6b
-<parameter name="openrc" required="1">
c45d6b
-<longdesc lang="en">
c45d6b
-Valid Openstack credentials as openrc file from api_access/openrc.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">openrc file</shortdesc>
c45d6b
-<content type="string" />
c45d6b
-</parameter>
c45d6b
-
c45d6b
 <parameter name="curlcli">
c45d6b
 <longdesc lang="en">
c45d6b
 Path to command line cURL binary.
c45d6b
@@ -97,14 +95,6 @@
c45d6b
 <content type="string" default="${OCF_RESKEY_curlcli_default}" />
c45d6b
 </parameter>
c45d6b
 
c45d6b
-<parameter name="openstackcli">
c45d6b
-<longdesc lang="en">
c45d6b
-Path to command line tools for openstack.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">Path to Openstack CLI tool</shortdesc>
c45d6b
-<content type="string" default="${OCF_RESKEY_openstackcli_default}" />
c45d6b
-</parameter>
c45d6b
-
c45d6b
 <parameter name="pythoncli">
c45d6b
 <longdesc lang="en">
c45d6b
 Path to command line Python interpreter.
c45d6b
@@ -116,9 +106,9 @@
c45d6b
 </parameters>
c45d6b
 
c45d6b
 <actions>
c45d6b
-<action name="start"  timeout="20s" />
c45d6b
-<action name="stop" timeout="20s" />
c45d6b
-<action name="monitor" timeout="20s" interval="60s"/>
c45d6b
+<action name="start"  timeout="180s" />
c45d6b
+<action name="stop" timeout="180s" />
c45d6b
+<action name="monitor" timeout="180s" interval="60s"/>
c45d6b
 <action name="meta-data" timeout="5s" />
c45d6b
 <action name="validate-all" timeout="20s" />
c45d6b
 </actions>
c45d6b
@@ -134,7 +124,7 @@
c45d6b
 	local node
c45d6b
 	local node_id
c45d6b
 
c45d6b
-	. $OCF_RESKEY_openrc
c45d6b
+	get_config
c45d6b
 
c45d6b
 	# Nova data: server ID
c45d6b
 	node_id=$($OCF_RESKEY_curlcli \
c45d6b
@@ -244,16 +234,6 @@
c45d6b
 	check_binary "$OCF_RESKEY_openstackcli"
c45d6b
 	check_binary "$OCF_RESKEY_pythoncli"
c45d6b
 
c45d6b
-	if [ -z "$OCF_RESKEY_openrc" ]; then
c45d6b
-		ocf_exit_reason "openrc parameter not set"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	if [ ! -f "$OCF_RESKEY_openrc" ] ; then
c45d6b
-		ocf_exit_reason "openrc file not found"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
 	return $OCF_SUCCESS
c45d6b
 }
c45d6b
 
c45d6b
diff --color -uNr a/heartbeat/openstack-virtual-ip b/heartbeat/openstack-virtual-ip
c45d6b
--- a/heartbeat/openstack-virtual-ip	2022-03-15 16:14:29.370209063 +0100
c45d6b
+++ b/heartbeat/openstack-virtual-ip	2022-03-15 16:17:36.235840021 +0100
c45d6b
@@ -34,10 +34,9 @@
c45d6b
 : ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
c45d6b
 . ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
c45d6b
 
c45d6b
-# Defaults
c45d6b
-OCF_RESKEY_openstackcli_default="/usr/bin/openstack"
c45d6b
+. ${OCF_FUNCTIONS_DIR}/openstack-common.sh
c45d6b
 
c45d6b
-: ${OCF_RESKEY_openstackcli=${OCF_RESKEY_openstackcli_default}}
c45d6b
+# Defaults
c45d6b
 
c45d6b
 #######################################################################
c45d6b
 
c45d6b
@@ -68,22 +67,11 @@
c45d6b
 <shortdesc lang="en">Move a virtual IP</shortdesc>
c45d6b
 
c45d6b
 <parameters>
c45d6b
-<parameter name="openstackcli">
c45d6b
-<longdesc lang="en">
c45d6b
-Path to command line tools for openstack.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">Path to Openstack CLI tool</shortdesc>
c45d6b
-<content type="string" default="${OCF_RESKEY_openstackcli_default}" />
c45d6b
-</parameter>
c45d6b
+END
c45d6b
 
c45d6b
-<parameter name="openrc" required="1">
c45d6b
-<longdesc lang="en">
c45d6b
-Valid Openstack credentials as openrc file from api_access/openrc.
c45d6b
-</longdesc>
c45d6b
-<shortdesc lang="en">openrc file</shortdesc>
c45d6b
-<content type="string" />
c45d6b
-</parameter>
c45d6b
+common_meta_data
c45d6b
 
c45d6b
+cat <
c45d6b
 <parameter name="ip" required="1">
c45d6b
 <longdesc lang="en">
c45d6b
 Virtual IP Address.
c45d6b
@@ -105,7 +93,7 @@
c45d6b
 <actions>
c45d6b
 <action name="start" timeout="180s" />
c45d6b
 <action name="stop" timeout="180s" />
c45d6b
-<action name="monitor" depth="0" timeout="30s" interval="60s" />
c45d6b
+<action name="monitor" depth="0" timeout="180s" interval="60s" />
c45d6b
 <action name="validate-all" timeout="5s" />
c45d6b
 <action name="meta-data" timeout="5s" />
c45d6b
 </actions>
c45d6b
@@ -128,17 +116,7 @@
c45d6b
 osvip_validate() {
c45d6b
 	check_binary "$OCF_RESKEY_openstackcli"
c45d6b
 
c45d6b
-	if [ -z "$OCF_RESKEY_openrc" ]; then
c45d6b
-		ocf_exit_reason "openrc parameter not set"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	if [ ! -f "$OCF_RESKEY_openrc" ] ; then
c45d6b
-		ocf_exit_reason "openrc file not found"
c45d6b
-		return $OCF_ERR_CONFIGURED
c45d6b
-	fi
c45d6b
-
c45d6b
-	. $OCF_RESKEY_openrc
c45d6b
+	get_config
c45d6b
 
c45d6b
 	${HA_SBIN_DIR}/attrd_updater --query -n openstack_ports -N $(crm_node -n) > /dev/null 2>&1
c45d6b
 	if [ $? -ne 0 ] ; then