Blame SOURCES/bz1607607-podman.patch

b4b3ce
From 07d283a6e20b8e559257c9694f7e36e155075014 Mon Sep 17 00:00:00 2001
b4b3ce
From: Michele Baldessari <michele@acksyn.org>
b4b3ce
Date: Sun, 22 Jul 2018 17:54:29 +0200
b4b3ce
Subject: [PATCH] Initial podman support
b4b3ce
b4b3ce
Tested with the following container:
b4b3ce
     podman container set: test_bundle [docker.io/sdelrio/docker-minimal-nginx]
b4b3ce
       test_bundle-podman-0 (ocf::heartbeat:podman):        Started nodea
b4b3ce
       test_bundle-podman-1 (ocf::heartbeat:podman):        Started nodeb
b4b3ce
       test_bundle-podman-2 (ocf::heartbeat:podman):        Started nodec
b4b3ce
b4b3ce
Tested a couple of stop/start cycles successfully. Needs the
b4b3ce
corresponding pacemaker support https://github.com/ClusterLabs/pacemaker/pull/1564
b4b3ce
---
b4b3ce
 doc/man/Makefile.am   |   1 +
b4b3ce
 heartbeat/Makefile.am |   1 +
b4b3ce
 heartbeat/podman      | 488 ++++++++++++++++++++++++++++++++++++++++++
b4b3ce
 3 files changed, 490 insertions(+)
b4b3ce
 create mode 100755 heartbeat/podman
b4b3ce
b4b3ce
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
b4b3ce
index 145e5fd50..0bef88740 100644
b4b3ce
--- a/doc/man/Makefile.am
b4b3ce
+++ b/doc/man/Makefile.am
b4b3ce
@@ -151,6 +151,7 @@ man_MANS	       = ocf_heartbeat_AoEtarget.7 \
b4b3ce
                           ocf_heartbeat_pgagent.7 \
b4b3ce
                           ocf_heartbeat_pgsql.7 \
b4b3ce
                           ocf_heartbeat_pingd.7 \
b4b3ce
+                          ocf_heartbeat_podman.7 \
b4b3ce
                           ocf_heartbeat_portblock.7 \
b4b3ce
                           ocf_heartbeat_postfix.7 \
b4b3ce
                           ocf_heartbeat_pound.7 \
b4b3ce
diff --git a/heartbeat/Makefile.am b/heartbeat/Makefile.am
b4b3ce
index e7a3a4fac..993bff042 100644
b4b3ce
--- a/heartbeat/Makefile.am
b4b3ce
+++ b/heartbeat/Makefile.am
b4b3ce
@@ -146,6 +146,7 @@ ocf_SCRIPTS	     =  AoEtarget		\
b4b3ce
 			pgagent			\
b4b3ce
 			pgsql			\
b4b3ce
 			pingd			\
b4b3ce
+			podman			\
b4b3ce
 			portblock		\
b4b3ce
 			postfix			\
b4b3ce
 			pound			\
b4b3ce
diff --git a/heartbeat/podman b/heartbeat/podman
b4b3ce
new file mode 100755
b4b3ce
index 000000000..88475f1df
b4b3ce
--- /dev/null
b4b3ce
+++ b/heartbeat/podman
b4b3ce
@@ -0,0 +1,488 @@
b4b3ce
+#!/bin/sh
b4b3ce
+#
b4b3ce
+# The podman HA resource agent creates and launches a podman container
b4b3ce
+# based off a supplied podman image. Containers managed by this agent
b4b3ce
+# are both created and removed upon the agent's start and stop actions.
b4b3ce
+#
b4b3ce
+# Copyright (c) 2014 David Vossel <davidvossel@gmail.com>
b4b3ce
+#                    Michele Baldessari <michele@acksyn.org>
b4b3ce
+#                    All Rights Reserved.
b4b3ce
+#
b4b3ce
+# This program is free software; you can redistribute it and/or modify
b4b3ce
+# it under the terms of version 2 of the GNU General Public License as
b4b3ce
+# published by the Free Software Foundation.
b4b3ce
+#
b4b3ce
+# This program is distributed in the hope that it would be useful, but
b4b3ce
+# WITHOUT ANY WARRANTY; without even the implied warranty of
b4b3ce
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
b4b3ce
+#
b4b3ce
+# Further, this software is distributed without any warranty that it is
b4b3ce
+# free of the rightful claim of any third person regarding infringement
b4b3ce
+# or the like.  Any license provided herein, whether implied or
b4b3ce
+# otherwise, applies only to this software file.  Patent licenses, if
b4b3ce
+# any, provided herein do not apply to combinations of this program with
b4b3ce
+# other software, or any other product whatsoever.
b4b3ce
+#
b4b3ce
+# You should have received a copy of the GNU General Public License
b4b3ce
+# along with this program; if not, write the Free Software Foundation,
b4b3ce
+# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
b4b3ce
+#
b4b3ce
+
b4b3ce
+#######################################################################
b4b3ce
+# Initialization:
b4b3ce
+
b4b3ce
+: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
b4b3ce
+. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
b4b3ce
+
b4b3ce
+#######################################################################
b4b3ce
+
b4b3ce
+meta_data()
b4b3ce
+{
b4b3ce
+	cat <
b4b3ce
+
b4b3ce
+
b4b3ce
+<resource-agent name="podman">
b4b3ce
+<version>1.0</version>
b4b3ce
+
b4b3ce
+<longdesc lang="en">
b4b3ce
+The podman HA resource agent creates and launches a podman container
b4b3ce
+based off a supplied podman image. Containers managed by this agent
b4b3ce
+are both created and removed upon the agent's start and stop actions.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">Podman container resource agent.</shortdesc>
b4b3ce
+
b4b3ce
+<parameters>
b4b3ce
+<parameter name="image" required="1" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+The podman image to base this container off of.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">podman image</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="name" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+The name to give the created container. By default this will
b4b3ce
+be that resource's instance name.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">podman container name</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="allow_pull" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Allow the image to be pulled from the configured podman registry when
b4b3ce
+the image does not exist locally. NOTE, this can drastically increase
b4b3ce
+the time required to start the container if the image repository is
b4b3ce
+pulled over the network.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">Allow pulling non-local images</shortdesc>
b4b3ce
+<content type="boolean"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="run_opts" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Add options to be appended to the 'podman run' command which is used
b4b3ce
+when creating the container during the start action. This option allows
b4b3ce
+users to do things such as setting a custom entry point and injecting
b4b3ce
+environment variables into the newly created container. Note the '-d'
b4b3ce
+option is supplied regardless of this value to force containers to run
b4b3ce
+in the background.
b4b3ce
+
b4b3ce
+NOTE: Do not explicitly specify the --name argument in the run_opts. This
b4b3ce
+agent will set --name using either the resource's instance or the name
b4b3ce
+provided in the 'name' argument of this agent.
b4b3ce
+
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">run options</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="run_cmd" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Specify a command to launch within the container once
b4b3ce
+it has initialized.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">run command</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="mount_points" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+A comma separated list of directories that the container is expecting to use.
b4b3ce
+The agent will ensure they exist by running 'mkdir -p'
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">Required mount points</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="monitor_cmd" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Specify the full path of a command to launch within the container to check
b4b3ce
+the health of the container. This command must return 0 to indicate that
b4b3ce
+the container is healthy. A non-zero return code will indicate that the
b4b3ce
+container has failed and should be recovered.
b4b3ce
+
b4b3ce
+If 'podman exec' is supported, it is used to execute the command. If not,
b4b3ce
+nsenter is used.
b4b3ce
+
b4b3ce
+Note: Using this method for monitoring processes inside a container
b4b3ce
+is not recommended, as containerd tries to track processes running
b4b3ce
+inside the container and does not deal well with many short-lived
b4b3ce
+processes being spawned. Ensure that your container monitors its
b4b3ce
+own processes and terminates on fatal error rather than invoking
b4b3ce
+a command from the outside.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">monitor command</shortdesc>
b4b3ce
+<content type="string"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="force_kill" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Kill a container immediately rather than waiting for it to gracefully
b4b3ce
+shutdown
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">force kill</shortdesc>
b4b3ce
+<content type="boolean"/>
b4b3ce
+</parameter>
b4b3ce
+
b4b3ce
+<parameter name="reuse" required="0" unique="0">
b4b3ce
+<longdesc lang="en">
b4b3ce
+Allow the container to be reused after stopping the container. By default
b4b3ce
+containers are removed after stop. With the reuse option containers
b4b3ce
+will persist after the container stops.
b4b3ce
+</longdesc>
b4b3ce
+<shortdesc lang="en">reuse container</shortdesc>
b4b3ce
+<content type="boolean"/>
b4b3ce
+</parameter>
b4b3ce
+</parameters>
b4b3ce
+
b4b3ce
+<actions>
b4b3ce
+<action name="start"        timeout="90s" />
b4b3ce
+<action name="stop"         timeout="90s" />
b4b3ce
+<action name="monitor"      timeout="30s" interval="30s" depth="0" />
b4b3ce
+<action name="meta-data"    timeout="5s" />
b4b3ce
+<action name="validate-all"   timeout="30s" />
b4b3ce
+</actions>
b4b3ce
+</resource-agent>
b4b3ce
+END
b4b3ce
+}
b4b3ce
+
b4b3ce
+#######################################################################
b4b3ce
+REQUIRE_IMAGE_PULL=0
b4b3ce
+
b4b3ce
+podman_usage()
b4b3ce
+{
b4b3ce
+	cat <
b4b3ce
+usage: $0 {start|stop|monitor|validate-all|meta-data}
b4b3ce
+
b4b3ce
+Expects to have a fully populated OCF RA-compliant environment set.
b4b3ce
+END
b4b3ce
+}
b4b3ce
+
b4b3ce
+
b4b3ce
+monitor_cmd_exec()
b4b3ce
+{
b4b3ce
+	local rc=$OCF_SUCCESS
b4b3ce
+	local out
b4b3ce
+
b4b3ce
+	if [ -z "$OCF_RESKEY_monitor_cmd" ]; then
b4b3ce
+		return $rc
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if podman exec --help >/dev/null 2>&1; then
b4b3ce
+		out=$(podman exec ${CONTAINER} $OCF_RESKEY_monitor_cmd 2>&1)
b4b3ce
+		rc=$?
b4b3ce
+	else
b4b3ce
+		out=$(echo "$OCF_RESKEY_monitor_cmd" | nsenter --target $(podman inspect --format {{.State.Pid}} ${CONTAINER}) --mount --uts --ipc --net --pid 2>&1)
b4b3ce
+		rc=$?
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ $rc -eq 127 ]; then
b4b3ce
+		ocf_log err "monitor cmd failed (rc=$rc), output: $out"
b4b3ce
+		ocf_exit_reason "monitor_cmd, ${OCF_RESKEY_monitor_cmd} , not found within container."
b4b3ce
+		# there is no recovering from this, exit immediately
b4b3ce
+		exit $OCF_ERR_ARGS
b4b3ce
+	elif [ $rc -ne 0 ]; then
b4b3ce
+		ocf_exit_reason "monitor cmd failed (rc=$rc), output: $out"
b4b3ce
+		rc=$OCF_ERR_GENERIC
b4b3ce
+	else
b4b3ce
+		ocf_log debug "monitor cmd passed: exit code = $rc"
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	return $rc
b4b3ce
+}
b4b3ce
+
b4b3ce
+container_exists()
b4b3ce
+{
b4b3ce
+	podman inspect --format {{.State.Running}} $CONTAINER | egrep '(true|false)' >/dev/null 2>&1
b4b3ce
+}
b4b3ce
+
b4b3ce
+remove_container()
b4b3ce
+{
b4b3ce
+	if ocf_is_true "$OCF_RESKEY_reuse"; then
b4b3ce
+		# never remove the container if we have reuse enabled.
b4b3ce
+		return 0
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	container_exists
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		# don't attempt to remove a container that doesn't exist
b4b3ce
+		return 0
b4b3ce
+	fi
b4b3ce
+	ocf_log notice "Cleaning up inactive container, ${CONTAINER}."
b4b3ce
+	ocf_run podman rm $CONTAINER
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_simple_status()
b4b3ce
+{
b4b3ce
+	local val
b4b3ce
+
b4b3ce
+	container_exists
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		return $OCF_NOT_RUNNING
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	# retrieve the 'Running' attribute for the container
b4b3ce
+	val=$(podman inspect --format {{.State.Running}} $CONTAINER 2>/dev/null)
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		#not running as a result of container not being found
b4b3ce
+		return $OCF_NOT_RUNNING
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if ocf_is_true "$val"; then
b4b3ce
+		# container exists and is running
b4b3ce
+		return $OCF_SUCCESS
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	return $OCF_NOT_RUNNING
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_monitor()
b4b3ce
+{
b4b3ce
+	local rc=0
b4b3ce
+
b4b3ce
+	podman_simple_status
b4b3ce
+	rc=$?
b4b3ce
+
b4b3ce
+	if [ $rc -ne 0 ]; then
b4b3ce
+		return $rc
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	monitor_cmd_exec
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_create_mounts() {
b4b3ce
+	oldIFS="$IFS"
b4b3ce
+	IFS=","
b4b3ce
+	for directory in $OCF_RESKEY_mount_points; do
b4b3ce
+		mkdir -p "$directory"
b4b3ce
+	done
b4b3ce
+	IFS="$oldIFS"
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_start()
b4b3ce
+{
b4b3ce
+	podman_create_mounts
b4b3ce
+	local run_opts="-d --name=${CONTAINER}"
b4b3ce
+	# check to see if the container has already started
b4b3ce
+	podman_simple_status
b4b3ce
+	if [ $? -eq $OCF_SUCCESS ]; then
b4b3ce
+		return $OCF_SUCCESS
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ -n "$OCF_RESKEY_run_opts" ]; then
b4b3ce
+		run_opts="$run_opts $OCF_RESKEY_run_opts"
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ $REQUIRE_IMAGE_PULL -eq 1 ]; then
b4b3ce
+		ocf_log notice "Beginning pull of image, ${OCF_RESKEY_image}"
b4b3ce
+		podman pull "${OCF_RESKEY_image}"
b4b3ce
+		if [ $? -ne 0 ]; then
b4b3ce
+			ocf_exit_reason "failed to pull image ${OCF_RESKEY_image}"
b4b3ce
+			return $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if ocf_is_true "$OCF_RESKEY_reuse" && container_exists; then
b4b3ce
+		ocf_log info "starting existing container $CONTAINER."
b4b3ce
+		ocf_run podman start $CONTAINER
b4b3ce
+	else
b4b3ce
+		# make sure any previous container matching our container name is cleaned up first.
b4b3ce
+		# we already know at this point it wouldn't be running
b4b3ce
+		remove_container
b4b3ce
+		ocf_log info "running container $CONTAINER for the first time"
b4b3ce
+		ocf_run podman run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		ocf_exit_reason "podman failed to launch container"
b4b3ce
+		return $OCF_ERR_GENERIC
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+
b4b3ce
+	# wait for monitor to pass before declaring that the container is started
b4b3ce
+	while true; do
b4b3ce
+		podman_simple_status
b4b3ce
+		if [ $? -ne $OCF_SUCCESS ]; then
b4b3ce
+			ocf_exit_reason "Newly created podman container exited after start"
b4b3ce
+			return $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
+
b4b3ce
+		monitor_cmd_exec
b4b3ce
+		if [ $? -eq $OCF_SUCCESS ]; then
b4b3ce
+			ocf_log notice "Container $CONTAINER  started successfully"
b4b3ce
+			return $OCF_SUCCESS
b4b3ce
+		fi
b4b3ce
+
b4b3ce
+		ocf_exit_reason "waiting on monitor_cmd to pass after start"
b4b3ce
+		sleep 1
b4b3ce
+	done
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_stop()
b4b3ce
+{
b4b3ce
+	local timeout=60
b4b3ce
+	podman_simple_status
b4b3ce
+	if [ $? -eq  $OCF_NOT_RUNNING ]; then
b4b3ce
+		remove_container
b4b3ce
+		return $OCF_SUCCESS
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
b4b3ce
+		timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000) -10 ))
b4b3ce
+		if [ $timeout -lt 10 ]; then
b4b3ce
+			timeout=10
b4b3ce
+		fi
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if ocf_is_true "$OCF_RESKEY_force_kill"; then
b4b3ce
+		ocf_run podman kill $CONTAINER
b4b3ce
+	else
b4b3ce
+		ocf_log debug "waiting $timeout second[s] before killing container"
b4b3ce
+		ocf_run podman stop -t=$timeout $CONTAINER
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		ocf_exit_reason "Failed to stop container, ${CONTAINER}, based on image, ${OCF_RESKEY_image}."
b4b3ce
+		return $OCF_ERR_GENERIC
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	remove_container
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		ocf_exit_reason "Failed to remove stopped container, ${CONTAINER}, based on image, ${OCF_RESKEY_image}."
b4b3ce
+		return $OCF_ERR_GENERIC
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	return $OCF_SUCCESS
b4b3ce
+}
b4b3ce
+
b4b3ce
+image_exists()
b4b3ce
+{
b4b3ce
+	# if no tag was specified, use default "latest"
b4b3ce
+	local COLON_FOUND=0
b4b3ce
+	local SLASH_FOUND=0
b4b3ce
+	local SERVER_NAME=""
b4b3ce
+	local IMAGE_NAME="${OCF_RESKEY_image}"
b4b3ce
+	local IMAGE_TAG="latest"
b4b3ce
+
b4b3ce
+	SLASH_FOUND="$(echo "${OCF_RESKEY_image}" | grep -o '/' | grep -c .)"
b4b3ce
+
b4b3ce
+	if [ ${SLASH_FOUND} -ge 1 ]; then
b4b3ce
+		SERVER_NAME="$(echo ${IMAGE_NAME} | cut -d / -f 1-${SLASH_FOUND})"
b4b3ce
+		IMAGE_NAME="$(echo ${IMAGE_NAME} | awk -F'/' '{print $NF}')"
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	COLON_FOUND="$(echo "${IMAGE_NAME}" | grep -o ':' | grep -c .)"
b4b3ce
+	if [ ${COLON_FOUND} -ge 1 ]; then
b4b3ce
+		IMAGE_TAG="$(echo ${IMAGE_NAME} | awk -F':' '{print $NF}')"
b4b3ce
+		IMAGE_NAME="$(echo ${IMAGE_NAME} | cut -d : -f 1-${COLON_FOUND})"
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	# IMAGE_NAME might be following formats:
b4b3ce
+	# - image
b4b3ce
+	# - repository:port/image
b4b3ce
+	# - docker.io/image (some distro will display "docker.io/" as prefix)
b4b3ce
+	podman images | awk '{print $1 ":" $2}' | egrep -q -s "^(docker.io\/|${SERVER_NAME}\/)?${IMAGE_NAME}:${IMAGE_TAG}\$"
b4b3ce
+	if [ $? -eq 0 ]; then
b4b3ce
+		# image found
b4b3ce
+		return 0
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if ocf_is_true "$OCF_RESKEY_allow_pull"; then
b4b3ce
+		REQUIRE_IMAGE_PULL=1
b4b3ce
+		ocf_log notice "Image (${OCF_RESKEY_image}) does not exist locally but will be pulled during start"
b4b3ce
+		return 0
b4b3ce
+	fi
b4b3ce
+	# image not found.
b4b3ce
+	return 1
b4b3ce
+}
b4b3ce
+
b4b3ce
+podman_validate()
b4b3ce
+{
b4b3ce
+	check_binary podman
b4b3ce
+	if [ -z "$OCF_RESKEY_image" ]; then
b4b3ce
+		ocf_exit_reason "'image' option is required"
b4b3ce
+		exit $OCF_ERR_CONFIGURED
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	if [ -n "$OCF_RESKEY_monitor_cmd" ]; then
b4b3ce
+		podman exec --help >/dev/null 2>&1
b4b3ce
+		if [ ! $? ]; then
b4b3ce
+			ocf_log info "checking for nsenter, which is required when 'monitor_cmd' is specified"
b4b3ce
+			check_binary nsenter
b4b3ce
+		fi
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	image_exists
b4b3ce
+	if [ $? -ne 0 ]; then
b4b3ce
+		ocf_exit_reason "base image, ${OCF_RESKEY_image}, could not be found."
b4b3ce
+		exit $OCF_ERR_CONFIGURED
b4b3ce
+	fi
b4b3ce
+
b4b3ce
+	return $OCF_SUCCESS
b4b3ce
+}
b4b3ce
+
b4b3ce
+# TODO :
b4b3ce
+# When a user starts plural clones in a node in globally-unique, a user cannot appoint plural name parameters.
b4b3ce
+# When a user appoints reuse, the resource agent cannot connect plural clones with a container.
b4b3ce
+
b4b3ce
+if ocf_is_true "$OCF_RESKEY_CRM_meta_globally_unique"; then
b4b3ce
+	if [ -n "$OCF_RESKEY_name" ]; then
b4b3ce
+		if [ -n "$OCF_RESKEY_CRM_meta_clone_node_max" ] && [ "$OCF_RESKEY_CRM_meta_clone_node_max" -ne 1 ]
b4b3ce
+		then
b4b3ce
+			ocf_exit_reason "Cannot make plural clones from the same name parameter."
b4b3ce
+			exit $OCF_ERR_CONFIGURED
b4b3ce
+		fi
b4b3ce
+		if [ -n "$OCF_RESKEY_CRM_meta_master_node_max" ] && [ "$OCF_RESKEY_CRM_meta_master_node_max" -ne 1 ]
b4b3ce
+		then
b4b3ce
+			ocf_exit_reason "Cannot make plural master from the same name parameter."
b4b3ce
+			exit $OCF_ERR_CONFIGURED
b4b3ce
+		fi
b4b3ce
+	fi
b4b3ce
+	: ${OCF_RESKEY_name=`echo ${OCF_RESOURCE_INSTANCE} | tr ':' '-'`}
b4b3ce
+else
b4b3ce
+	: ${OCF_RESKEY_name=${OCF_RESOURCE_INSTANCE}}
b4b3ce
+fi
b4b3ce
+
b4b3ce
+CONTAINER=$OCF_RESKEY_name
b4b3ce
+
b4b3ce
+case $__OCF_ACTION in
b4b3ce
+meta-data) meta_data
b4b3ce
+		exit $OCF_SUCCESS;;
b4b3ce
+start)
b4b3ce
+	podman_validate
b4b3ce
+	podman_start;;
b4b3ce
+stop)		podman_stop;;
b4b3ce
+monitor)	podman_monitor;;
b4b3ce
+validate-all)	podman_validate;;
b4b3ce
+usage|help)	podman_usage
b4b3ce
+		exit $OCF_SUCCESS
b4b3ce
+		;;
b4b3ce
+*)		podman_usage
b4b3ce
+		exit $OCF_ERR_UNIMPLEMENTED
b4b3ce
+		;;
b4b3ce
+esac
b4b3ce
+rc=$?
b4b3ce
+ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc"
b4b3ce
+exit $rc