Subdirectories 'openstack/stx-ocf-scripts ' relocated to repo 'stx-ha'

Story: 2006166
Task: 35687
Depends-On: I665dc7fabbfffc798ad57843eb74dca16e7647a3
Change-Id: Icaad6fc701519855b3b4a689a263174e563e8973
Signed-off-by: Scott Little <scott.little@windriver.com>
Depends-On: I2c78d5fd86c9ef1ae61e444527dcd0127e250c7e
This commit is contained in:
Scott Little
2019-09-04 10:14:28 -04:00
parent 001b05f15b
commit d19158dcac
27 changed files with 0 additions and 8783 deletions

View File

@@ -1,2 +0,0 @@
SRC_DIR="$PKG_BASE/src"
TIS_PATCH_VER=3

View File

@@ -1,30 +0,0 @@
Summary: Miscellaneous OCF scripts added by StarlingX
Name: stx-ocf-scripts
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
Requires: openstack-ras
%description
Miscellaneous OCF scripts added by StarlingX
%prep
%setup
%build
%install
install -d -m 755 ${RPM_BUILD_ROOT}/usr/lib/ocf/resource.d/openstack
install -p -D -m 755 ocf/* ${RPM_BUILD_ROOT}/usr/lib/ocf/resource.d/openstack/
%files
%dir %attr(0755,root,root) /usr/lib/ocf/resource.d/openstack
%defattr(-,root,root,-)
/usr/lib/ocf/resource.d/openstack/*

View File

@@ -1,368 +0,0 @@
#!/bin/sh
#
#
# OpenStack Alarming API Service (aodh-api)
#
# Description: Manages an OpenStack Alarming API Service (aodh-api) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="aodh-api"
OCF_RESKEY_config_default="/etc/aodh/aodh.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8042"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Alarming API Service (aodh-api) process as an HA resource
The 'start' operation starts the aodh-api service.
The 'stop' operation stops the aodh-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the aodh-api service is running
The 'monitor' operation reports whether the aodh-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="aodh-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Alarming API Service (aodh-api)
May manage a aodh-api instance or a clone set that
creates a distributed aodh-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Alarming API Service (aodh-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming API server binary (aodh-api)
</longdesc>
<shortdesc lang="en">OpenStack Alarming API server binary (aodh-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming API Service (aodh-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Alarming API (aodh-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Alarming API Service (aodh-api)
</longdesc>
<shortdesc lang="en">OpenStack Alarming API Service (aodh-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Alarming API Service (aodh-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Alarming API Service (aodh-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the aodh-api server.
</longdesc>
<shortdesc lang="en">aodh-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Alarming API Service (aodh-api)
</longdesc>
<shortdesc lang="en">Additional parameters for aodh-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
aodh_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
aodh_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
aodh_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
aodh_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Alarming API (aodh-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Alarming API (aodh-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
aodh_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
aodh_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "aodh-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Alarming API (aodh-api) monitor succeeded"
return $OCF_SUCCESS
}
aodh_api_start() {
local rc
local host
aodh_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Alarming API (aodh-api) already running"
return $OCF_SUCCESS
fi
# run the actual aodh-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user}
/bin/python /usr/bin/gunicorn --config /usr/share/aodh/aodh-api.conf --pythonpath /usr/share/aodh aodh-api \
>> /var/log/aodh/aodh-api.log 2>&1 & echo $! > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
aodh_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Alarming API (aodh-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Alarming API (aodh-api) started"
return $OCF_SUCCESS
}
aodh_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
aodh_api_stop() {
local rc
local pid
aodh_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Alarming API (aodh-api) already stopped"
aodh_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Alarming API (aodh-api) couldn't be stopped"
aodh_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
aodh_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Alarming API (aodh-api) still hasn't stopped yet. Waiting ..."
done
aodh_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Alarming API (aodh-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
aodh_api_confirm_stop
ocf_log info "OpenStack Alarming API (aodh-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
aodh_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) aodh_api_start;;
stop) aodh_api_stop;;
status) aodh_api_status;;
monitor) aodh_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,358 +0,0 @@
#!/bin/sh
#
#
# OpenStack Alarming Evaluator Service (aodh-evaluator)
#
# Description: Manages an OpenStack Alarming Evaluator Service (aodh-evaluator) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="aodh-evaluator"
OCF_RESKEY_config_default="/etc/aodh/aodh.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Alarming Evaluator Service (aodh-evaluator) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="aodh-evaluator">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Alarming Evaluator Service (aodh-evaluator)
May manage a aodh-evaluator instance or a clone set that
creates a distributed aodh-evaluator cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Alarming Evaluator Service (aodh-evaluator)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Evaluator server binary (aodh-evaluator)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Evaluator server binary (aodh-evaluator)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Evaluator Service (aodh-evaluator) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Alarming Evaluator (aodh-evaluator registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Alarming Evaluator Service (aodh-evaluator)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Evaluator Service (aodh-evaluator) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Alarming Evaluator Service (aodh-evaluator) instance
</longdesc>
<shortdesc lang="en">OpenStack Alarming Evaluator Service (aodh-evaluator) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Alarming Evaluator Service (aodh-evaluator)
</longdesc>
<shortdesc lang="en">Additional parameters for aodh-evaluator</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
aodh_evaluator_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
aodh_evaluator_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
aodh_evaluator_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
aodh_evaluator_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Alarming Evaluator (aodh-evaluator) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
aodh_evaluator_monitor() {
local rc
local pid
local scheduler_amqp_check
aodh_evaluator_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Alarming Evaluator (aodh-evaluator) monitor succeeded"
return $OCF_SUCCESS
}
aodh_evaluator_start() {
local rc
aodh_evaluator_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) already running"
return $OCF_SUCCESS
fi
# run the actual aodh-evaluator daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
aodh_evaluator_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Alarming Evaluator (aodh-evaluator) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) started"
return $OCF_SUCCESS
}
aodh_evaluator_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
aodh_evaluator_stop() {
local rc
local pid
aodh_evaluator_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) already stopped"
aodh_evaluator_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Alarming Evaluator (aodh-evaluator) couldn't be stopped"
aodh_evaluator_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
aodh_evaluator_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Alarming Evaluator (aodh-evaluator) still hasn't stopped yet. Waiting ..."
done
aodh_evaluator_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
aodh_evaluator_confirm_stop
ocf_log info "OpenStack Alarming Evaluator (aodh-evaluator) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
aodh_evaluator_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) aodh_evaluator_start;;
stop) aodh_evaluator_stop;;
status) aodh_evaluator_status;;
monitor) aodh_evaluator_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,358 +0,0 @@
#!/bin/sh
#
#
# OpenStack Alarming Listener Service (aodh-listener)
#
# Description: Manages an OpenStack Alarming Listener Service (aodh-listener) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="aodh-listener"
OCF_RESKEY_config_default="/etc/aodh/aodh.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Alarming Listener Service (aodh-listener) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="aodh-listener">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Alarming Listener Service (aodh-listener)
May manage a aodh-listener instance or a clone set that
creates a distributed aodh-listener cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Alarming Listener Service (aodh-listener)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Listener server binary (aodh-listener)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Listener server binary (aodh-listener)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Listener Service (aodh-listener) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Alarming Listener (aodh-listener registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Alarming Listener Service (aodh-listener)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Listener Service (aodh-listener) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Alarming Listener Service (aodh-listener) instance
</longdesc>
<shortdesc lang="en">OpenStack Alarming Listener Service (aodh-listener) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Alarming Listener Service (aodh-listener)
</longdesc>
<shortdesc lang="en">Additional parameters for aodh-listener</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
aodh_listener_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
aodh_listener_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
aodh_listener_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
aodh_listener_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Alarming Listener (aodh-listener) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Alarming Listener (aodh-listener) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
aodh_listener_monitor() {
local rc
local pid
local scheduler_amqp_check
aodh_listener_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Alarming Listener (aodh-listener) monitor succeeded"
return $OCF_SUCCESS
}
aodh_listener_start() {
local rc
aodh_listener_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Alarming Listener (aodh-listener) already running"
return $OCF_SUCCESS
fi
# run the actual aodh-listener daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
aodh_listener_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Alarming Listener (aodh-listener) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Alarming Listener (aodh-listener) started"
return $OCF_SUCCESS
}
aodh_listener_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
aodh_listener_stop() {
local rc
local pid
aodh_listener_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Alarming Listener (aodh-listener) already stopped"
aodh_listener_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Alarming Listener (aodh-listener) couldn't be stopped"
aodh_listener_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
aodh_listener_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Alarming Listener (aodh-listener) still hasn't stopped yet. Waiting ..."
done
aodh_listener_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Alarming Listener (aodh-listener) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
aodh_listener_confirm_stop
ocf_log info "OpenStack Alarming Listener (aodh-listener) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
aodh_listener_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) aodh_listener_start;;
stop) aodh_listener_stop;;
status) aodh_listener_status;;
monitor) aodh_listener_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,358 +0,0 @@
#!/bin/sh
#
#
# OpenStack Alarming Notifier Service (aodh-notifier)
#
# Description: Manages an OpenStack Alarming Notifier Service (aodh-notifier) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="aodh-notifier"
OCF_RESKEY_config_default="/etc/aodh/aodh.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Alarming Notifier Service (aodh-notifier) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="aodh-notifier">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Alarming Notifier Service (aodh-notifier)
May manage a aodh-notifier instance or a clone set that
creates a distributed aodh-notifier cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Alarming Notifier Service (aodh-notifier)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Notifier server binary (aodh-notifier)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Notifier server binary (aodh-notifier)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Alarming Notifier Service (aodh-notifier) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Alarming Notifier (aodh-notifier registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Alarming Notifier Service (aodh-notifier)
</longdesc>
<shortdesc lang="en">OpenStack Alarming Notifier Service (aodh-notifier) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Alarming Notifier Service (aodh-notifier) instance
</longdesc>
<shortdesc lang="en">OpenStack Alarming Notifier Service (aodh-notifier) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Alarming Notifier Service (aodh-notifier)
</longdesc>
<shortdesc lang="en">Additional parameters for aodh-notifier</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
aodh_notifier_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
aodh_notifier_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
aodh_notifier_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
aodh_notifier_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Alarming Notifier (aodh-notifier) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
aodh_notifier_monitor() {
local rc
local pid
local scheduler_amqp_check
aodh_notifier_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Alarming Notifier (aodh-notifier) monitor succeeded"
return $OCF_SUCCESS
}
aodh_notifier_start() {
local rc
aodh_notifier_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) already running"
return $OCF_SUCCESS
fi
# run the actual aodh-notifier daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
aodh_notifier_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Alarming Notifier (aodh-notifier) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) started"
return $OCF_SUCCESS
}
aodh_notifier_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
aodh_notifier_stop() {
local rc
local pid
aodh_notifier_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) already stopped"
aodh_notifier_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Alarming Notifier (aodh-notifier) couldn't be stopped"
aodh_notifier_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
aodh_notifier_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Alarming Notifier (aodh-notifier) still hasn't stopped yet. Waiting ..."
done
aodh_notifier_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
aodh_notifier_confirm_stop
ocf_log info "OpenStack Alarming Notifier (aodh-notifier) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
aodh_notifier_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) aodh_notifier_start;;
stop) aodh_notifier_stop;;
status) aodh_notifier_status;;
monitor) aodh_notifier_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,363 +0,0 @@
#!/bin/sh
#
#
# OpenStack Key Management API Service (barbican-api)
#
# Description: Manages an OpenStack Key Management API Service as an HA resource
#
# Authors: Alex Kozyrev
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="/etc/barbican/gunicorn-config.py"
OCF_RESKEY_config_default="/etc/barbican/barbican.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="/run/barbican/pid"
OCF_RESKEY_server_port_default="9311"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 Manages an OpenStack Key Management API Service (barbican-api) process as an HA resource
The 'start' operation starts the barbican-api service.
The 'stop' operation stops the barbican-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the barbican-api service is running
The 'monitor' operation reports whether the barbican-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="barbican-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Key Management API Service (barbican-api)
May Manage a barbican-api instance or a clone set that
creates a distributed barbican-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Key Management API Service (barbican-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Key Management API server binary (barbican-api)
</longdesc>
<shortdesc lang="en">OpenStack Key Management API server binary (barbican-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Key Management API Service (barbican-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Key Management API (barbican-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Key Management API Service (barbican-api)
</longdesc>
<shortdesc lang="en">OpenStack Key Management API Service (barbican-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Key Management API Service (barbican-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Key Management API Service (barbican-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the barbican-api server.
</longdesc>
<shortdesc lang="en">barbican-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource Manager actions
barbican_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
barbican_api_validate() {
local rc
check_binary netstat
barbican_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
barbican_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Key Management API (barbican-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Key Management API \
(barbican-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
barbican_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
barbican_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "barbican-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Key Management API (barbican-api) monitor succeeded"
return $OCF_SUCCESS
}
barbican_api_start() {
local rc
local host
barbican_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Key Management API (barbican-api) already running"
return $OCF_SUCCESS
fi
# run the actual barbican-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user}
mkdir -p /run/barbican
chown barbican:barbican /run/barbican
/bin/python /usr/bin/gunicorn --pid $OCF_RESKEY_pid --config /etc/barbican/gunicorn-config.py \
--paste /etc/barbican/barbican-api-paste.ini >> /var/log/barbican/barbican-api.log 2>&1 &
# Restrict access to logfile
chmod 640 /var/log/barbican/barbican-api.log
# Spin waiting for the server to come up.
while true; do
barbican_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Key Management API (barbican-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Key Management API (barbican-api) started"
return $OCF_SUCCESS
}
barbican_api_confirm_stop() {
local my_bin
local my_processes
my_processes=`pgrep -l -f "gunicorn.*master.*barbican-api"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "gunicorn.*master.*barbican-api"
fi
}
barbican_api_stop() {
local rc
local pid
barbican_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Key Management API (barbican-api) already stopped"
barbican_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Key Management API (barbican-api) couldn't be stopped"
barbican_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
barbican_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Key Management API (barbican-api) still hasn't stopped yet. \
Waiting ..."
done
barbican_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Key Management API (barbican-api) failed to stop after \
${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
barbican_api_confirm_stop
ocf_log info "OpenStack Key Management API (barbican-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
barbican_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) barbican_api_start;;
stop) barbican_api_stop;;
status) barbican_api_status;;
monitor) barbican_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,307 +0,0 @@
#!/bin/sh
#
#
# OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener)
#
# Description: Manages an OpenStack Key Manager Keystone Listener Service
# (barbican-keystone-listener) process as an HA resource
#
# Authors: Alex Kozyrev
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_user
# OCF_RESKEY_pid
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="barbican-keystone-listener"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Key Manager Keystone Listener Service
(barbican-keystone-listener) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="barbican-keystone-listener">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener)
May manage a barbican-keystone-listener instance or a clone set that
creates a distributed barbican-keystone-listener cluster.
</longdesc>
<shortdesc lang="en">
Manages the OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener)
</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Key Manager Keystone Listener server binary (barbican-keystone-listener)
</longdesc>
<shortdesc lang="en">
OpenStack Key Manager Keystone Listener server binary (barbican-keystone-listener)
</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener)
</longdesc>
<shortdesc lang="en">
OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener) user
</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Key Manager Keystone Listener Service
(barbican-keystone-listener) instance
</longdesc>
<shortdesc lang="en">
OpenStack Key Manager Keystone Listener Service (barbican-keystone-listener) pid file
</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
barbican_keystone_listener_validate() {
local rc
check_binary $OCF_RESKEY_binary
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
barbican_keystone_listener_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Key Manager Keystone Listener \
(barbican-keystone-listener) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Key Manager Keystone Listener \
(barbican-keystone-listener) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
barbican_keystone_listener_monitor() {
local rc
local pid
barbican_keystone_listener_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Key Manager Keystone Listener \
(barbican-keystone-listener) monitor succeeded"
return $OCF_SUCCESS
}
barbican_keystone_listener_start() {
local rc
barbican_keystone_listener_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Key Manager Keystone Listener \
(barbican-keystone-listener) already running"
return $OCF_SUCCESS
fi
# run the actual barbican-keystone-listener daemon. Don't use ocf_run as we're sending the
# tool's output straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary}"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
barbican_keystone_listener_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) started"
return $OCF_SUCCESS
}
barbican_keystone_listener_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
barbican_keystone_listener_stop() {
local rc
local pid
barbican_keystone_listener_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) already stopped"
barbican_keystone_listener_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) couldn't be stopped"
barbican_keystone_listener_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
barbican_keystone_listener_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) still hasn't stopped yet. \
Waiting ..."
done
barbican_keystone_listener_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) failed to stop after \
${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
barbican_keystone_listener_confirm_stop
ocf_log info "OpenStack Key Manager Keystone Listener (barbican-keystone-listener) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
barbican_keystone_listener_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) barbican_keystone_listener_start;;
stop) barbican_keystone_listener_stop;;
status) barbican_keystone_listener_status;;
monitor) barbican_keystone_listener_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,294 +0,0 @@
#!/bin/sh
#
#
# OpenStack Key Manager Worker Service (barbican-worker)
#
# Description: Manages an OpenStack Key Manager Worker Service
# (barbican-worker) process as an HA resource
#
# Authors: Alex Kozyrev
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_user
# OCF_RESKEY_pid
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="barbican-worker"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Key Manager Worker Service
(barbican-worker) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="barbican-worker">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Key Manager Worker Service (barbican-worker)
May manage a barbican-worker instance or a clone set that
creates a distributed barbican-worker cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Key Manager Worker Service (barbican-worker)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Key Manager Worker server binary (barbican-worker)
</longdesc>
<shortdesc lang="en">OpenStack Key Manager Worker server binary (barbican-worker)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Key Manager Worker Service (barbican-worker)
</longdesc>
<shortdesc lang="en">OpenStack Key Manager Worker Service (barbican-worker) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Key Manager Worker Service (barbican-worker) instance
</longdesc>
<shortdesc lang="en">OpenStack Key Manager Worker Service (barbican-worker) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
barbican_worker_validate() {
local rc
check_binary $OCF_RESKEY_binary
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
barbican_worker_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Key Manager Worker (barbican-worker) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Key Manager Worker (barbican-worker) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
barbican_worker_monitor() {
local rc
local pid
barbican_worker_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Key Manager Worker (barbican-worker) monitor succeeded"
return $OCF_SUCCESS
}
barbican_worker_start() {
local rc
barbican_worker_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Key Manager Worker (barbican-worker) already running"
return $OCF_SUCCESS
fi
# run the actual barbican-worker daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary}"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
barbican_worker_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Key Manager Worker (barbican-worker) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Key Manager Worker (barbican-worker) started"
return $OCF_SUCCESS
}
barbican_worker_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
barbican_worker_stop() {
local rc
local pid
barbican_worker_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Key Manager Worker (barbican-worker) already stopped"
barbican_worker_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Key Manager Worker (barbican-worker) couldn't be stopped"
barbican_worker_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
barbican_worker_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Key Manager Worker (barbican-worker) still hasn't stopped yet. \
Waiting ..."
done
barbican_worker_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Key Manager Worker (barbican-worker) failed to stop after \
${shutdown_timeout}s using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
barbican_worker_confirm_stop
ocf_log info "OpenStack Key Manager Worker (barbican-worker) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
barbican_worker_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) barbican_worker_start;;
stop) barbican_worker_stop;;
status) barbican_worker_status;;
monitor) barbican_worker_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,370 +0,0 @@
#!/bin/sh
#
#
# OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification)
#
# Description: Manages an OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_pipeline
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="ceilometer-agent-notification"
OCF_RESKEY_config_default="/etc/ceilometer/ceilometer.conf"
OCF_RESKEY_pipeline_default="/opt/cgcs/ceilometer/${SW_VERSION}/pipeline.yaml"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_pipeline=${OCF_RESKEY_pipeline_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="ceilometer-agent-notification">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification)
May manage a ceilometer-agent-notification instance or a clone set that
creates a distributed ceilometer-agent-notification cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Ceilometer Central Agent server binary (ceilometer-agent-notification)
</longdesc>
<shortdesc lang="en">OpenStack Ceilometer Central Agent server binary (ceilometer-agent-notification)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Ceilometer Central Agent (ceilometer-agent-notification registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="pipeline" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) pipeline file
</longdesc>
<shortdesc lang="en">OpenStack Ceilometer Central Agent (ceilometer-agent-notification registry) pipeline file</shortdesc>
<content type="string" default="${OCF_RESKEY_pipeline_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification)
</longdesc>
<shortdesc lang="en">OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) instance
</longdesc>
<shortdesc lang="en">OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Ceilometer Central Agent Service (ceilometer-agent-notification)
</longdesc>
<shortdesc lang="en">Additional parameters for ceilometer-agent-notification</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
ceilometer_agent_notification_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
ceilometer_agent_notification_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
ceilometer_agent_notification_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
ceilometer_agent_notification_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Ceilometer Central Agent (ceilometer-agent-notification) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
ceilometer_agent_notification_monitor() {
local rc
local pid
local scheduler_amqp_check
ceilometer_agent_notification_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) monitor succeeded"
return $OCF_SUCCESS
}
ceilometer_agent_notification_start() {
local rc
ceilometer_agent_notification_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) already running"
return $OCF_SUCCESS
fi
# run the actual ceilometer-agent-notification daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
--pipeline_cfg_file=$OCF_RESKEY_pipeline \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
ceilometer_agent_notification_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) started"
return $OCF_SUCCESS
}
ceilometer_agent_notification_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
ceilometer_agent_notification_stop() {
local rc
local pid
ceilometer_agent_notification_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) already stopped"
ceilometer_agent_notification_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) couldn't be stopped"
ceilometer_agent_notification_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
ceilometer_agent_notification_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) still hasn't stopped yet. Waiting ..."
done
ceilometer_agent_notification_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
ceilometer_agent_notification_confirm_stop
ocf_log info "OpenStack Ceilometer Central Agent (ceilometer-agent-notification) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
ceilometer_agent_notification_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) ceilometer_agent_notification_start;;
stop) ceilometer_agent_notification_stop;;
status) ceilometer_agent_notification_status;;
monitor) ceilometer_agent_notification_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,413 +0,0 @@
#!/bin/sh
#
#
# OpenStack Cinder Backup (cinder-backup)
#
# Description: Manages an OpenStack Backup (cinder-backup) process as an HA resource
#
# Authors:
# Mainly inspired by the cinder volume resource agent written by Sébastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# (c) 2012 hastexo Professional Services GmbH
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# The right to copy, distribute, modify, or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="cinder-backup"
OCF_RESKEY_config_default="/etc/cinder/cinder.conf"
OCF_RESKEY_user_default="cinder"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Cinder Backup (cinder-backup) process as an HA resource
The 'start' operation starts the backup service.
The 'stop' operation stops the backup service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the backup service is running
The 'monitor' operation reports whether the backup service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="cinder-backup">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Cinder Backup (cinder-backup)
May manage a cinder-backup instance or a clone set that
creates a distributed cinder-backup cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Cinder Backup (cinder-backup)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Cinder Backup server binary (cinder-backup)
</longdesc>
<shortdesc lang="en">OpenStack Cinder Backup server binary (cinder-backup)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Cinder Backup (cinder-backup) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Cinder Backup (cinder-backup) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Cinder Backup (cinder-backup)
</longdesc>
<shortdesc lang="en">OpenStack Cinder Backup (cinder-backup) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Cinder Backup (cinder-backup) instance
</longdesc>
<shortdesc lang="en">OpenStack Cinder Backup (cinder-backup) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Mandatory to perform a monitor check
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Cinder Backup (cinder-backup)
</longdesc>
<shortdesc lang="en">Additional parameters for cinder-backup</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="10" />
<action name="status" timeout="10" />
<action name="monitor" timeout="5" interval="10" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
cinder_backup_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
cinder_backup_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Cinder Backup (cinder-backup) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Cinder Backup (cinder-backup) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
cinder_backup_get_service_status() {
local status_file=${VOLATILE_PATH}/cinder-backup.down-after
if [[ -f "${status_file}" ]]; then
echo "exists=True"
if [[ "$(date -u +'%Y-%m-%d %H:%M:%S.%N')" < "$(cat ${status_file})" ]]; then
echo "is_up=True"
else
echo "is_up=False"
fi
return 0
else
echo "exists=False"
echo "is_up=False"
return 1
fi
}
cinder_backup_monitor() {
local rc
local pid
local backup_amqp_check
local check_service_status=$1; shift
cinder_backup_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Grab cinder-backup PID
pid=`cat $OCF_RESKEY_pid`
# Check the connections according to the PID
# We are sure to hit the backup process and not other cinder process with the same connection
# behavior (for example nova-cert)
backup_amqp_check=`netstat -punt | grep -s "$OCF_RESKEY_amqp_server_port" | grep -s "$pid" | grep -qs "ESTABLISHED"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log info "Cinder Backup is not connected to the AMQP server: $rc"
return $OCF_NOT_RUNNING
fi
# Is this needed?
if [ $check_service_status == "check-service-status" ]; then
local retries_left
local retry_interval
retries_left=3
retry_interval=3
while [ $retries_left -gt 0 ]; do
retries_left=`expr $retries_left - 1`
status=$(cinder_backup_get_service_status)
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Unable to get Cinder Backup status"
if [ $retries_left -gt 0 ]; then
sleep $retry_interval
continue
else
return $OCF_ERR_GENERIC
fi
fi
local exists
local is_up
eval $status
if [ "$exists" == "True" ] && [ "$is_up" == "False" ]; then
ocf_log err "Cinder Backup service status is down"
if [ $retries_left -gt 0 ]; then
sleep $retry_interval
continue
else
ocf_log info "Trigger Cinder Backup guru meditation report"
ocf_run kill -s USR2 $pid
return $OCF_ERR_GENERIC
fi
fi
break
done
fi
ocf_log debug "OpenStack Cinder Backup (cinder-backup) monitor succeeded"
return $OCF_SUCCESS
}
cinder_backup_start() {
local rc
cinder_backup_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Cinder Backup (cinder-backup) already running"
return $OCF_SUCCESS
fi
# run the actual cinder-backup daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
while true; do
cinder_backup_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Cinder Backup (cinder-backup) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Cinder Backup (cinder-backup) started"
return $OCF_SUCCESS
}
cinder_backup_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
cinder_backup_stop() {
local rc
local pid
cinder_backup_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Cinder Backup (cinder-backup) already stopped"
cinder_backup_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Cinder Backup (cinder-backup) couldn't be stopped"
cinder_backup_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
cinder_backup_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Cinder backup (cinder-backup) still hasn't stopped yet. Waiting ..."
done
cinder_backup_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Cinder Backup (cinder-backup) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL -$pid
fi
cinder_backup_confirm_stop
ocf_log info "OpenStack Cinder Backup (cinder-backup) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
cinder_backup_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) cinder_backup_start;;
stop) cinder_backup_stop;;
status) cinder_backup_status;;
monitor) cinder_backup_monitor "check-service-status";;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,344 +0,0 @@
#!/bin/sh
#
#
# OpenStack mariadb monitor (dbmon)
#
# Description: Monitors local OpenStack mariadb pod as an HA resource
#
# Authors: Chris Friesen
#
# Support: starlingx-discuss@lists.starlingx.io
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
export KUBECONFIG=/etc/kubernetes/admin.conf
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|active|standby|monitor)
$0 monitors local OpenStack mariadb pod as an HA resource
The 'start' operation doesn't really do anything.
The 'stop' operation doesn't really do anything.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'monitor' operation reports whether the local mariadb pod is 'Primary'
The 'active' operation will try to ensure that the local mariadb pod is 'Primary'
The 'standby' operation will report whether the local mariadb pod is 'Primary'
UEND
}
# this apostrophe is to work around an editor highlighting bug: '
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="dbmon">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack mariadb monitor (dbmon)
This tries to ensure that the active controller node always has access
to a functional OpenStack database.
</longdesc>
<shortdesc lang="en">Monitors the OpenStack mariadb pod</shortdesc>
<parameters>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="monitor" timeout="10" interval="5" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
<action name="audit" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
dbmon_validate() {
local rc
check_binary base64
check_binary grep
check_binary cut
check_binary head
check_binary kubectl
true
}
active_controller() {
# "facter" will return "true" or "false"
eval $(FACTERLIB=/usr/share/puppet/modules/platform/lib/facter/ facter is_controller_active)
}
check_has_garbd_chart() {
helm list osh-openstack-garbd|grep -q osh-openstack-garbd
}
debuginfo() {
# Log some information on what's preventing us from getting the DB status
# The "timeout" call is in case we're in the middle of swacting and kubectl
# isn't responding, in which case the audit should catch any issues.
APP_STATUS='uninstalled'
# Check whether kubectl is working.
timeout -k 5 5 kubectl get node ${HOSTNAME} &> /dev/null
if [ $? -ne 0 ]; then
ocf_log info "kubectl isn't working."
STATUS="Primary"
return
fi
# Check whether the openstack namespace exists. This is a proxy
# for whether the application is installed.
kubectl get ns openstack &> /dev/null
if [ $? -ne 0 ]; then
ocf_log info "Openstack namespace doesn't exist."
# TODO: this is a hack until we can dynamically provision services in sm.
# Once that's available this should just return.
STATUS="Primary"
return
fi
# TODO: this is also a hack until we can dynamically provision services in sm.
# Check whether the helm chart is deployed. If not, we don't want to
# cause an alarm to be raised. The helm list command returns 0 even if the
# specified chart isn't found.
helm list osh-openstack-mariadb|grep -qe "osh-openstack-mariadb.*DEPLOYED"
if [ $? -ne 0 ]; then
ocf_log info "osh-openstack-mariadb helm chart not installed."
STATUS="Primary"
return
fi
APP_STATUS='initializing'
# Check that mariadb is running in the pod. If it's not, we could be still
# initializing.
INFO=`kubectl exec -n openstack -it ${PODNAME} -- ps -C mysqld`
if [ $? -ne 0 ]; then
ocf_log info "Mysqld not running in mariadb container."
# Setting STATUS so the audit will return $OCF_NOT_RUNNING instead
# of $OCF_ERR_GENERIC
STATUS="non-Primary"
fi
}
get_status() {
STATUS=`kubectl exec -n openstack -it ${PODNAME} -- mysql -sN -u root \
--password=${DBPASSWD} -e " select VARIABLE_VALUE from \
information_schema.GLOBAL_STATUS where VARIABLE_NAME='wsrep_cluster_status';"`
if [ $? -ne 0 ]; then
# something is wrong, can't query status
ocf_log info "Unknown error trying to query mariadb status"
return $OCF_ERR_GENERIC
fi
# In my testing there is a CR/LF at the end of STATUS, remove it.
STATUS=${STATUS%%[[:space:]]}
}
get_pod_and_status() {
# Get name of local mariadb pod.
# The "timeout" call is in case we're in the middle of swacting and kubectl
# isn't responding, in which case the audit should catch any issues.
PODNAME=`timeout -k 5 5 kubectl -n openstack get pod --field-selector spec.nodeName=${HOSTNAME} \
-l application=mariadb,component=server -o=jsonpath='{.items[0].metadata.name'}`
if [ $? -ne 0 ]; then
ocf_log info "Error getting mariadb server pod name on this node."
return $OCF_ERR_GENERIC
fi
# If this doesn't exist, the return code will still be zero
# but the variable will be blank.
DBPASSWD_ENCODED=`kubectl -n openstack get secret mariadb-dbadmin-password \
-o=jsonpath='{.data.MYSQL_DBADMIN_PASSWORD}'`
if [ "${DBPASSWD_ENCODED}" = '' ]; then
ocf_log info "Unable to get mariadb password. Exiting."
return $OCF_ERR_GENERIC
fi
DBPASSWD=`echo ${DBPASSWD_ENCODED}|base64 -d`
if [ $? -ne 0 ]; then
ocf_log info "Unable to decode mariadb password. Exiting."
return $OCF_ERR_GENERIC
fi
get_status
}
dbmon_status() {
get_pod_and_status
if [ $? -ne 0 ]; then
# The call to debuginfo may write to STATUS, once sysinv can dynamically
# add services that shouldn't be necessary any more.
debuginfo
fi
if [ "${STATUS}" == "Primary" ]; then
if active_controller ; then
return $OCF_RUNNING_MASTER
else
return $OCF_SUCCESS
fi
elif [ "${STATUS}" == "non-Primary" ]; then
ocf_log info "mariadb server is running but not primary."
return $OCF_NOT_RUNNING
else
ocf_log info "unexpected mariadb status of ${STATUS}"
return $OCF_ERR_GENERIC
fi
}
dbmon_monitor() {
dbmon_status
}
dbmon_standby() {
get_pod_and_status
if [ $? -ne 0 ]; then
# something is wrong, can't query status
debuginfo
ocf_log info "unable to query status, exiting"
# If the app isn't installed yet then there's no point in complaining.
if [ $APP_STATUS == 'uninstalled' ]; then
return $OCF_SUCCESS
else
return $OCF_NOT_RUNNING
fi
fi
if [ "${STATUS}" == "non-Primary" ]; then
return $OCF_NOT_RUNNING
elif [ "${STATUS}" == "Primary" ]; then
return $OCF_SUCCESS
else
ocf_log info "unexpected mariadb status of ${STATUS}"
return $OCF_ERR_GENERIC
fi
}
dbmon_active() {
get_pod_and_status
if [ $? -ne 0 ]; then
# something is wrong, can't query status
debuginfo
ocf_log info "unable to query status, exiting"
# If the app isn't installed yet we don't want to hold up the
# controller going active.
if [ $APP_STATUS == 'uninstalled' ]; then
return $OCF_SUCCESS
else
return $OCF_NOT_RUNNING
fi
fi
if [ "${STATUS}" == "non-Primary" ]; then
ocf_log info "mariadb server is running but not primary"
# If we're on a standard lab, exit before telling the server to become primary
check_has_garbd_chart
if [ $? -eq 0 ]; then
ocf_log info "in standard lab, exiting"
return $OCF_NOT_RUNNING
fi
# tell mysql to become primary
kubectl exec -n openstack -it ${PODNAME} -- mysql -u root --password=${DBPASSWD} \
-e "SET GLOBAL wsrep_provider_options='pc.bootstrap=YES';"
if [ $? -ne 0 ]; then
ocf_log info "Error telling mysql to become primary."
return $OCF_NOT_RUNNING
fi
# wait a bit then check the status
sleep 1
ocf_log info "checking status after bootstrapping"
get_status
if [ $? -ne 0 ]; then
# something is wrong, can't query status
debuginfo
ocf_log info "unable to query status, exiting"
return $OCF_NOT_RUNNING
fi
if [ "${STATUS}" == "non-Primary" ]; then
ocf_log info "mariadb server is running but still not primary"
return $OCF_NOT_RUNNING
fi
fi
# At this point status is either Primary or something unexpected
if [ "${STATUS}" == "Primary" ]; then
return $OCF_SUCCESS
else
ocf_log info "unexpected mariadb status of ${STATUS}"
return $OCF_ERR_GENERIC
fi
}
dbmon_start() {
return $OCF_SUCCESS
}
dbmon_stop() {
return $OCF_NOT_RUNNING
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
dbmon_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) dbmon_start;;
stop) dbmon_stop;;
monitor) dbmon_monitor;;
active) dbmon_active;;
standby) dbmon_standby;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Orchestration Engine Service (heat-api)
#
# Description: Manages an OpenStack Orchestration Engine Service (heat-api) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="heat-api"
OCF_RESKEY_config_default="/etc/heat/heat.conf"
OCF_RESKEY_user_default="heat"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8004"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Orchestration Engine Service (heat-api) process as an HA resource
The 'start' operation starts the heat-api service.
The 'stop' operation stops the heat-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the heat-api service is running
The 'monitor' operation reports whether the heat-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="heat-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Orchestration Engine Service (heat-api)
May manage a heat-api instance or a clone set that
creates a distributed heat-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Orchestration Engine Service (heat-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine server binary (heat-api)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine server binary (heat-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine Service (heat-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine (heat-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Orchestration Engine Service (heat-api)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Orchestration Engine Service (heat-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the heat-api server.
</longdesc>
<shortdesc lang="en">heat-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Orchestration Engine Service (heat-api)
</longdesc>
<shortdesc lang="en">Additional parameters for heat-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
heat_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
heat_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
heat_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
heat_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Orchestration Engine (heat-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
heat_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
heat_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "heat-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Orchestration Engine (heat-api) monitor succeeded"
return $OCF_SUCCESS
}
heat_api_start() {
local rc
heat_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api) already running"
return $OCF_SUCCESS
fi
# run the actual heat-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
heat_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Orchestration Engine (heat-api) started"
return $OCF_SUCCESS
}
heat_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
heat_api_stop() {
local rc
local pid
heat_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api) already stopped"
heat_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api) couldn't be stopped"
heat_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
heat_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Orchestration Engine (heat-api) still hasn't stopped yet. Waiting ..."
done
heat_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Orchestration Engine (heat-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
heat_api_confirm_stop
ocf_log info "OpenStack Orchestration Engine (heat-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
heat_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) heat_api_start;;
stop) heat_api_stop;;
status) heat_api_status;;
monitor) heat_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Orchestration Engine Service (heat-api-cfn)
#
# Description: Manages an OpenStack Orchestration Engine Service (heat-api-cfn) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="heat-api-cfn"
OCF_RESKEY_config_default="/etc/heat/heat.conf"
OCF_RESKEY_user_default="heat"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8000"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Orchestration Engine Service (heat-api-cfn) process as an HA resource
The 'start' operation starts the heat-api-cfn service.
The 'stop' operation stops the heat-api-cfn service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the heat-api-cfn service is running
The 'monitor' operation reports whether the heat-api-cfn service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="heat-api-cfn">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Orchestration Engine Service (heat-api-cfn)
May manage a heat-api-cfn instance or a clone set that
creates a distributed heat-api-cfn cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Orchestration Engine Service (heat-api-cfn)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine server binary (heat-api-cfn)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine server binary (heat-api-cfn)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine Service (heat-api-cfn) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine (heat-api-cfn) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Orchestration Engine Service (heat-api-cfn)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api-cfn) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Orchestration Engine Service (heat-api-cfn) instance
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api-cfn) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the heat-api-cfn server.
</longdesc>
<shortdesc lang="en">heat-api-cfn listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Orchestration Engine Service (heat-api-cfn)
</longdesc>
<shortdesc lang="en">Additional parameters for heat-api-cfn</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
heat_api_cfn_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
heat_api_cfn_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
heat_api_cfn_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
heat_api_cfn_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Orchestration Engine (heat-api-cfn) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
heat_api_cfn_monitor() {
local rc
local pid
local rc_db
local engine_db_check
heat_api_cfn_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "heat-api-cfn is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Orchestration Engine (heat-api-cfn) monitor succeeded"
return $OCF_SUCCESS
}
heat_api_cfn_start() {
local rc
heat_api_cfn_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) already running"
return $OCF_SUCCESS
fi
# run the actual heat-api-cfn daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
heat_api_cfn_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api-cfn) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) started"
return $OCF_SUCCESS
}
heat_api_cfn_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
heat_api_cfn_stop() {
local rc
local pid
heat_api_cfn_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) already stopped"
heat_api_cfn_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api-cfn) couldn't be stopped"
heat_api_cfn_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
heat_api_cfn_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Orchestration Engine (heat-api-cfn) still hasn't stopped yet. Waiting ..."
done
heat_api_cfn_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
heat_api_cfn_confirm_stop
ocf_log info "OpenStack Orchestration Engine (heat-api-cfn) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
heat_api_cfn_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) heat_api_cfn_start;;
stop) heat_api_cfn_stop;;
status) heat_api_cfn_status;;
monitor) heat_api_cfn_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Orchestration Engine Service (heat-api-cloudwatch)
#
# Description: Manages an OpenStack Orchestration Engine Service (heat-api-cloudwatch) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="heat-api-cloudwatch"
OCF_RESKEY_config_default="/etc/heat/heat.conf"
OCF_RESKEY_user_default="heat"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8000"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Orchestration Engine Service (heat-api-cloudwatch) process as an HA resource
The 'start' operation starts the heat-api-cloudwatch service.
The 'stop' operation stops the heat-api-cloudwatch service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the heat-api-cloudwatch service is running
The 'monitor' operation reports whether the heat-api-cloudwatch service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="heat-api-cloudwatch">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Orchestration Engine Service (heat-api-cloudwatch)
May manage a heat-api-cloudwatch instance or a clone set that
creates a distributed heat-api-cloudwatch cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Orchestration Engine Service (heat-api-cloudwatch)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine server binary (heat-api-cloudwatch)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine server binary (heat-api-cloudwatch)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Orchestration Engine Service (heat-api-cloudwatch) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine (heat-api-cloudwatch) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Orchestration Engine Service (heat-api-cloudwatch)
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api-cloudwatch) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Orchestration Engine Service (heat-api-cloudwatch) instance
</longdesc>
<shortdesc lang="en">OpenStack Orchestration Engine Service (heat-api-cloudwatch) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the heat-api-cloudwatch server.
</longdesc>
<shortdesc lang="en">heat-api-cloudwatch listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Orchestration Engine Service (heat-api-cloudwatch)
</longdesc>
<shortdesc lang="en">Additional parameters for heat-api-cloudwatch</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
heat_api_cloudwatch_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
heat_api_cloudwatch_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
heat_api_cloudwatch_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
heat_api_cloudwatch_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Orchestration Engine (heat-api-cloudwatch) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
heat_api_cloudwatch_monitor() {
local rc
local pid
local rc_db
local engine_db_check
heat_api_cloudwatch_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "heat-api-cloudwatch is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Orchestration Engine (heat-api-cloudwatch) monitor succeeded"
return $OCF_SUCCESS
}
heat_api_cloudwatch_start() {
local rc
heat_api_cloudwatch_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) already running"
return $OCF_SUCCESS
fi
# run the actual heat-api-cloudwatch daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
heat_api_cloudwatch_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api-cloudwatch) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) started"
return $OCF_SUCCESS
}
heat_api_cloudwatch_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
heat_api_cloudwatch_stop() {
local rc
local pid
heat_api_cloudwatch_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) already stopped"
heat_api_cloudwatch_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Orchestration Engine (heat-api-cloudwatch) couldn't be stopped"
heat_api_cloudwatch_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
heat_api_cloudwatch_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Orchestration Engine (heat-api-cloudwatch) still hasn't stopped yet. Waiting ..."
done
heat_api_cloudwatch_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
heat_api_cloudwatch_confirm_stop
ocf_log info "OpenStack Orchestration Engine (heat-api-cloudwatch) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
heat_api_cloudwatch_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) heat_api_cloudwatch_start;;
stop) heat_api_cloudwatch_stop;;
status) heat_api_cloudwatch_status;;
monitor) heat_api_cloudwatch_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Container Orchestration Engine Provisioning API Service (ironic-api)
#
# Description: Manages an OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="ironic-api"
OCF_RESKEY_config_default="/etc/ironic/ironic.conf"
OCF_RESKEY_user_default="ironic"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="6485"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) process as an HA resource
The 'start' operation starts the ironic-api service.
The 'stop' operation stops the ironic-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the ironic-api service is running
The 'monitor' operation reports whether the ironic-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="ironic-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Container Orchestration Engine Provisioning API Service (ironic-api)
May manage a ironic-api instance or a clone set that
creates a distributed ironic-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Container Orchestration Engine Provisioning API Service (ironic-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning API server binary (ironic-api)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API server binary (ironic-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API (ironic-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Container Orchestration Engine Provisioning API Service (ironic-api)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API Service (ironic-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the ironic-api server.
</longdesc>
<shortdesc lang="en">ironic-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Container Orchestration Engine Provisioning API Service (ironic-api)
</longdesc>
<shortdesc lang="en">Additional parameters for ironic-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
ironic_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
ironic_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
ironic_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
ironic_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Container Orchestration Engine Provisioning API (ironic-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
ironic_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
ironic_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "ironic-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Container Orchestration Engine Provisioning API (ironic-api) monitor succeeded"
return $OCF_SUCCESS
}
ironic_api_start() {
local rc
ironic_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) already running"
return $OCF_SUCCESS
fi
# run the actual ironic-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
ironic_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Container Orchestration Engine Provisioning API (ironic-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) started"
return $OCF_SUCCESS
}
ironic_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
ironic_api_stop() {
local rc
local pid
ironic_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) already stopped"
ironic_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Bare Metal Provisioning Service API (ironic-api) couldn't be stopped"
ironic_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
ironic_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Container Orchestration Engine Provisioning API (ironic-api) still hasn't stopped yet. Waiting ..."
done
ironic_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
ironic_api_confirm_stop
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (ironic-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
ironic_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) ironic_api_start;;
stop) ironic_api_stop;;
status) ironic_api_status;;
monitor) ironic_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,376 +0,0 @@
#!/bin/sh
#
#
# OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor)
#
# Description: Manages an OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
# OCF_RESKEY_tftproot
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="ironic-conductor"
OCF_RESKEY_config_default="/etc/ironic/ironic.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
OCF_RESKEY_tftproot_default="/opt/cgcs/ironic/"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
: ${OCF_RESKEY_tftproot=${OCF_RESKEY_tftproot_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="ironic-conductor">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor)
May manage a ironic-conductor instance or a clone set that
creates a distributed ironic-conductor cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Bare Metal Provisioning Service Conductor server binary (ironic-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Conductor server binary (ironic-conductor)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) instance
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Bare Metal Provisioning Service Conductor Service (ironic-conductor)
</longdesc>
<shortdesc lang="en">Additional parameters for ironic-conductor</shortdesc>
<content type="string" />
</parameter>
<parameter name="tftproot" unique="0" required="0">
<longdesc lang="en">
TFTP root directory to copy the base tftp files to
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service TFTP root</shortdesc>
<content type="string" default="${OCF_RESKEY_tftproot_default}" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
ironic_conductor_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
ironic_conductor_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
ironic_conductor_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
ironic_conductor_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
ironic_conductor_monitor() {
local rc
local pid
local scheduler_amqp_check
ironic_conductor_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) monitor succeeded"
return $OCF_SUCCESS
}
ironic_conductor_start() {
local rc
ironic_conductor_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) already running"
return $OCF_SUCCESS
fi
# copy tftp server required files: pxelinux.0 and chain.c32
rsync -c \
/usr/share/syslinux/pxelinux.0 \
/usr/share/syslinux/chain.c32 \
${OCF_RESKEY_tftproot}/
chown ironic ${OCF_RESKEY_tftproot}/pxelinux.0 ${OCF_RESKEY_tftproot}/chain.c32
# run the actual ironic-conductor daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
ironic_conductor_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) started"
return $OCF_SUCCESS
}
ironic_conductor_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
ironic_conductor_stop() {
local rc
local pid
ironic_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) already stopped"
ironic_conductor_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) couldn't be stopped"
ironic_conductor_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
ironic_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) still hasn't stopped yet. Waiting ..."
done
ironic_conductor_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
ironic_conductor_confirm_stop
ocf_log info "OpenStack Bare Metal Provisioning Service Conductor (ironic-conductor) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
ironic_conductor_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) ironic_conductor_start;;
stop) ironic_conductor_stop;;
status) ironic_conductor_status;;
monitor) ironic_conductor_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Container Orchestration Engine Provisioning API Service (magnum-api)
#
# Description: Manages an OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="magnum-api"
OCF_RESKEY_config_default="/etc/magnum/magnum.conf"
OCF_RESKEY_user_default="magnum"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="9511"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) process as an HA resource
The 'start' operation starts the magnum-api service.
The 'stop' operation stops the magnum-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the magnum-api service is running
The 'monitor' operation reports whether the magnum-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="magnum-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Container Orchestration Engine Provisioning API Service (magnum-api)
May manage a magnum-api instance or a clone set that
creates a distributed magnum-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Container Orchestration Engine Provisioning API Service (magnum-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning API server binary (magnum-api)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API server binary (magnum-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API (magnum-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Container Orchestration Engine Provisioning API Service (magnum-api)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning API Service (magnum-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the magnum-api server.
</longdesc>
<shortdesc lang="en">magnum-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Container Orchestration Engine Provisioning API Service (magnum-api)
</longdesc>
<shortdesc lang="en">Additional parameters for magnum-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
magnum_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
magnum_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
magnum_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
magnum_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Container Orchestration Engine Provisioning API (magnum-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
magnum_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
magnum_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "magnum-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Container Orchestration Engine Provisioning API (magnum-api) monitor succeeded"
return $OCF_SUCCESS
}
magnum_api_start() {
local rc
magnum_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) already running"
return $OCF_SUCCESS
fi
# run the actual magnum-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
magnum_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Container Orchestration Engine Provisioning API (magnum-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) started"
return $OCF_SUCCESS
}
magnum_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
magnum_api_stop() {
local rc
local pid
magnum_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) already stopped"
magnum_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Container Orchestration Engine Provisioning API (magnum-api) couldn't be stopped"
magnum_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
magnum_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Container Orchestration Engine Provisioning API (magnum-api) still hasn't stopped yet. Waiting ..."
done
magnum_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
magnum_api_confirm_stop
ocf_log info "OpenStack Container Orchestration Engine Provisioning API (magnum-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
magnum_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) magnum_api_start;;
stop) magnum_api_stop;;
status) magnum_api_status;;
monitor) magnum_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,358 +0,0 @@
#!/bin/sh
#
#
# OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor)
#
# Description: Manages an OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="magnum-conductor"
OCF_RESKEY_config_default="/etc/magnum/magnum.conf"
OCF_RESKEY_user_default="magnum"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="magnum-conductor">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor)
May manage a magnum-conductor instance or a clone set that
creates a distributed magnum-conductor cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning Conductor server binary (magnum-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning Conductor server binary (magnum-conductor)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) instance
</longdesc>
<shortdesc lang="en">OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Container Orchestration Engine Provisioning Conductor Service (magnum-conductor)
</longdesc>
<shortdesc lang="en">Additional parameters for magnum-conductor</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
magnum_conductor_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
magnum_conductor_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
magnum_conductor_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
magnum_conductor_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
magnum_conductor_monitor() {
local rc
local pid
local scheduler_amqp_check
magnum_conductor_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) monitor succeeded"
return $OCF_SUCCESS
}
magnum_conductor_start() {
local rc
magnum_conductor_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) already running"
return $OCF_SUCCESS
fi
# run the actual magnum-conductor daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
magnum_conductor_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) started"
return $OCF_SUCCESS
}
magnum_conductor_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
magnum_conductor_stop() {
local rc
local pid
magnum_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) already stopped"
magnum_conductor_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) couldn't be stopped"
magnum_conductor_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
magnum_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) still hasn't stopped yet. Waiting ..."
done
magnum_conductor_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
magnum_conductor_confirm_stop
ocf_log info "OpenStack Container Orchestration Engine Provisioning Conductor (magnum-conductor) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
magnum_conductor_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) magnum_conductor_start;;
stop) magnum_conductor_stop;;
status) magnum_conductor_status;;
monitor) magnum_conductor_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,366 +0,0 @@
#!/bin/sh
#
#
# OpenStack Application Catalog API Service (murano-api)
#
# Description: Manages an OpenStack Application Catalog API Service (murano-api) process as an HA resource
#
# Authors: Emilien Macchi
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="murano-api"
OCF_RESKEY_config_default="/etc/murano/murano.conf"
OCF_RESKEY_user_default="murano"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8082"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Application Catalog API Service (murano-api) process as an HA resource
The 'start' operation starts the murano-api service.
The 'stop' operation stops the murano-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the murano-api service is running
The 'monitor' operation reports whether the murano-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="murano-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Application Catalog API Service (murano-api)
May manage a murano-api instance or a clone set that
creates a distributed murano-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Application Catalog API Service (murano-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Application Catalog API server binary (murano-api)
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog API server binary (murano-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Application Catalog API Service (murano-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog API (murano-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Application Catalog API Service (murano-api)
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog API Service (murano-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Application Catalog API Service (murano-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog API Service (murano-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the murano-api server.
</longdesc>
<shortdesc lang="en">murano-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Application Catalog API Service (murano-api)
</longdesc>
<shortdesc lang="en">Additional parameters for murano-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
murano_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
murano_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
murano_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
murano_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Application Catalog API (murano-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Application Catalog API (murano-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
murano_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
murano_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "murano-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Application Catalog API (murano-api) monitor succeeded"
return $OCF_SUCCESS
}
murano_api_start() {
local rc
murano_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Application Catalog API (murano-api) already running"
return $OCF_SUCCESS
fi
# run the actual murano-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
murano_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Application Catalog API (murano-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Application Catalog API (murano-api) started"
return $OCF_SUCCESS
}
murano_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
murano_api_stop() {
local rc
local pid
murano_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Application Catalog API (murano-api) already stopped"
murano_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Application Catalog API (murano-api) couldn't be stopped"
murano_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
murano_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Application Catalog API (murano-api) still hasn't stopped yet. Waiting ..."
done
murano_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Application Catalog API (murano-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
murano_api_confirm_stop
ocf_log info "OpenStack Application Catalog API (murano-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
murano_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) murano_api_start;;
stop) murano_api_stop;;
status) murano_api_status;;
monitor) murano_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,358 +0,0 @@
#!/bin/sh
#
#
# OpenStack Application Catalog Engine Service (murano-engine)
#
# Description: Manages an OpenStack Application Catalog Engine Service (murano-engine) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014-2016 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="murano-engine"
OCF_RESKEY_config_default="/etc/murano/murano.conf"
OCF_RESKEY_user_default="murano"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Application Catalog Engine Service (murano-engine) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="murano-engine">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Application Catalog Engine Service (murano-engine)
May manage a murano-engine instance or a clone set that
creates a distributed murano-engine cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Application Catalog Engine Service (murano-engine)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Application Catalog Engine server binary (murano-engine)
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog Engine server binary (murano-engine)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Application Catalog Engine Service (murano-engine) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog Engine (murano-engine registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Application Catalog Engine Service (murano-engine)
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog Engine Service (murano-engine) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Application Catalog Engine Service (murano-engine) instance
</longdesc>
<shortdesc lang="en">OpenStack Application Catalog Engine Service (murano-engine) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Application Catalog Engine Service (murano-engine)
</longdesc>
<shortdesc lang="en">Additional parameters for murano-engine</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
murano_engine_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
murano_engine_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
murano_engine_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
murano_engine_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Application Catalog Engine (murano-engine) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Application Catalog Engine (murano-engine) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
murano_engine_monitor() {
local rc
local pid
local scheduler_amqp_check
murano_engine_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Application Catalog Engine (murano-engine) monitor succeeded"
return $OCF_SUCCESS
}
murano_engine_start() {
local rc
murano_engine_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Application Catalog Engine (murano-engine) already running"
return $OCF_SUCCESS
fi
# run the actual murano-engine daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
murano_engine_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Application Catalog Engine (murano-engine) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Application Catalog Engine (murano-engine) started"
return $OCF_SUCCESS
}
murano_engine_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
murano_engine_stop() {
local rc
local pid
murano_engine_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Application Catalog Engine (murano-engine) already stopped"
murano_engine_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Application Catalog Engine (murano-engine) couldn't be stopped"
murano_engine_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
murano_engine_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Application Catalog Engine (murano-engine) still hasn't stopped yet. Waiting ..."
done
murano_engine_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Application Catalog Engine (murano-engine) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
murano_engine_confirm_stop
ocf_log info "OpenStack Application Catalog Engine (murano-engine) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
murano_engine_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) murano_engine_start;;
stop) murano_engine_stop;;
status) murano_engine_status;;
monitor) murano_engine_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,359 +0,0 @@
#!/bin/sh
#
#
# OpenStack Bare Metal Provisioning Service Compute Service (nova-compute)
#
# Description: Manages an OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) process as an HA resource
#
# Authors: Emilien Macchi
# Mainly inspired by the Nova Scheduler resource agent written by Sebastien Han
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
. /usr/bin/tsconfig
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="nova-compute"
OCF_RESKEY_config_default="/etc/nova/nova-ironic.conf"
OCF_RESKEY_user_default="nova"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_amqp_server_port_default="5672"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) process as an HA resource
The 'start' operation starts the scheduler service.
The 'stop' operation stops the scheduler service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the scheduler service is running
The 'monitor' operation reports whether the scheduler service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="nova-compute">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Bare Metal Provisioning Service Compute Service (nova-compute)
May manage a nova-compute instance or a clone set that
creates a distributed nova-compute cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Bare Metal Provisioning Service Compute Service (nova-compute)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Bare Metal Provisioning Service Compute server binary (nova-compute)
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Compute server binary (nova-compute)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Compute (nova-compute registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Bare Metal Provisioning Service Compute Service (nova-compute)
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) instance
</longdesc>
<shortdesc lang="en">OpenStack Bare Metal Provisioning Service Compute Service (nova-compute) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Bare Metal Provisioning Service Compute Service (nova-compute)
</longdesc>
<shortdesc lang="en">Additional parameters for nova-compute</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
nova_compute_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
nova_compute_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
nova_compute_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
nova_compute_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Bare Metal Provisioning Service Compute (nova-compute) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
nova_compute_monitor() {
local rc
local pid
local scheduler_amqp_check
nova_compute_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
ocf_log debug "OpenStack Bare Metal Provisioning Service Compute (nova-compute) monitor succeeded"
return $OCF_SUCCESS
}
nova_compute_start() {
local rc
nova_compute_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) already running"
return $OCF_SUCCESS
fi
# run the actual nova-compute daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
nova_compute_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Bare Metal Provisioning Service Compute (nova-compute) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) started"
return $OCF_SUCCESS
}
nova_compute_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
nova_compute_stop() {
local rc
local pid
nova_compute_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) already stopped"
nova_compute_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Bare Metal Provisioning Service Compute (nova-compute) couldn't be stopped"
nova_compute_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=2
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
nova_compute_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Bare Metal Provisioning Service Compute (nova-compute) still hasn't stopped yet. Waiting ..."
done
nova_compute_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
nova_compute_confirm_stop
ocf_log info "OpenStack Bare Metal Provisioning Service Compute (nova-compute) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
nova_compute_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) nova_compute_start;;
stop) nova_compute_stop;;
status) nova_compute_status;;
monitor) nova_compute_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,435 +0,0 @@
#!/bin/sh
#
#
# OpenStack Conductor Service (nova-conductor)
#
# Description: Manages an OpenStack Conductor Service (nova-conductor) process as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_database_server_port
# OCF_RESKEY_amqp_server_port
# OCF_RESKEY_zeromq
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="nova-conductor"
OCF_RESKEY_config_default="/etc/nova/nova.conf"
OCF_RESKEY_user_default="nova"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_database_server_port_default="3306"
OCF_RESKEY_amqp_server_port_default="5672"
OCF_RESKEY_zeromq_default="false"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_database_server_port=${OCF_RESKEY_database_server_port_default}}
: ${OCF_RESKEY_amqp_server_port=${OCF_RESKEY_amqp_server_port_default}}
: ${OCF_RESKEY_zeromq=${OCF_RESKEY_zeromq_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack ConductorService (nova-conductor) process as an HA resource
The 'start' operation starts the conductor service.
The 'stop' operation stops the conductor service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the conductor service is running
The 'monitor' operation reports whether the conductor service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="nova-conductor">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Nova Conductor Service (nova-conductor)
May manage a nova-conductor instance or a clone set that
creates a distributed nova-conductor cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Conductor Service (nova-conductor)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Nova Conductor server binary (nova-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Nova Conductor server binary (nova-conductor)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Conductor Service (nova-conductor) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Nova Conductor (nova-conductor) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Conductor Service (nova-conductor)
</longdesc>
<shortdesc lang="en">OpenStack Conductor Service (nova-conductor) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Conductor Service (nova-conductor) instance
</longdesc>
<shortdesc lang="en">OpenStack Conductor Service (nova-conductor) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="database_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the database server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">Database listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_database_server_port_default}" />
</parameter>
<parameter name="amqp_server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">AMQP listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_amqp_server_port_default}" />
</parameter>
<parameter name="zeromq" unique="0" required="0">
<longdesc lang="en">
If zeromq is used, this will disable the connection test to the AMQP server. Use for monitoring purposes
</longdesc>
<shortdesc lang="en">Zero-MQ usage</shortdesc>
<content type="boolean" default="${OCF_RESKEY_zeromq_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Conductor Service (nova-conductor)
</longdesc>
<shortdesc lang="en">Additional parameters for nova-conductor</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
nova_conductor_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
nova_conductor_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
nova_conductor_check_port $OCF_RESKEY_database_server_port
nova_conductor_check_port $OCF_RESKEY_amqp_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
nova_conductor_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Nova Conductor (nova-conductor) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Conductor (nova-conductor) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
check_port() {
local port=$1
local pid=$2
netstat -punt | grep -s "$port" | grep -s "$pid" | grep -qs "ESTABLISHED"
rc=$?
if [ $rc -eq 0 ]; then
return 0
else
return 1
fi
}
nova_conductor_monitor() {
local rc
local pid
local rc_db
local rc_amqp
local conductor_db_check
local conductor_amqp_check
nova_conductor_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the connections according to the PID.
# We are sure to hit the conductor process and not other nova process with the same connection behavior (for example nova-cert)
if ocf_is_true "$OCF_RESKEY_zeromq"; then
pid=`cat $OCF_RESKEY_pid`
rc_db=`check_port $OCF_RESKEY_database_server_port $pid`
if [ $rc_db -ne 0 ]; then
ocf_log err "Nova Conductor is not connected to the database server: $rc_db"
return $OCF_NOT_RUNNING
fi
else
pid=`cat $OCF_RESKEY_pid`
rc_db=`check_port $OCF_RESKEY_database_server_port $pid`
rc_amqp=`check_port $OCF_RESKEY_amqp_server_port $pid`
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
# may have multiple workers, in which case $pid is the parent and we want to check the children
# If there are no children or at least one child is not connected to both DB and AMQP then we fail.
KIDPIDS=`pgrep -P $pid -f nova-conductor`
if [ ! -z "$KIDPIDS" ]; then
for pid in $KIDPIDS
do
rc_db=`check_port $OCF_RESKEY_database_server_port $pid`
rc_amqp=`check_port $OCF_RESKEY_amqp_server_port $pid`
if [ $rc_amqp -ne 0 ] || [ $rc_db -ne 0 ]; then
ocf_log err "Nova Conductor pid $pid is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
return $OCF_NOT_RUNNING
fi
done
else
ocf_log err "Nova Conductor pid $pid is not connected to the AMQP server and/or the database server: AMQP connection test returned $rc_amqp and database connection test returned $rc_db"
return $OCF_NOT_RUNNING
fi
fi
fi
ocf_log debug "OpenStack Nova Conductor (nova-conductor) monitor succeeded"
return $OCF_SUCCESS
}
nova_conductor_start() {
local rc
nova_conductor_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova Conductor (nova-conductor) already running"
return $OCF_SUCCESS
fi
# Change the working dir to /, to be sure it's accesible
cd /
# Run the pre-start hooks. This can be used to trigger a nova database sync, for example.
/usr/bin/nova-controller-runhooks
# run the actual nova-conductor daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
nova_conductor_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Nova Conductor (nova-conductor) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Nova Conductor (nova-conductor) started"
return $OCF_SUCCESS
}
nova_conductor_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
nova_conductor_stop() {
local rc
local pid
nova_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova Conductor (nova-conductor) already stopped"
nova_conductor_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova Conductor (nova-conductor) couldn't be stopped"
nova_conductor_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
nova_conductor_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Conductor (nova-conductor) still hasn't stopped yet. Waiting ..."
done
nova_conductor_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Conductor (nova-conductor) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
nova_conductor_confirm_stop
ocf_log info "OpenStack Nova Conductor (nova-conductor) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
nova_conductor_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) nova_conductor_start;;
stop) nova_conductor_stop;;
status) nova_conductor_status;;
monitor) nova_conductor_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,412 +0,0 @@
#!/bin/sh
#
#
# OpenStack NovaAPI (nova-placement-api)
#
# Description: Manages an OpenStack Nova Placement API (nova-placement-api) process as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the Glance API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_os_username
# OCF_RESKEY_os_password
# OCF_RESKEY_os_tenant_name
# OCF_RESKEY_keystone_get_token_url
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="nova-placement-api"
OCF_RESKEY_config_default="/etc/nova/nova.conf"
OCF_RESKEY_user_default="nova"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_host_default="127.0.0.1"
OCF_RESKEY_server_port_default="8778"
OCF_RESKEY_url_default="http://127.0.0.1:$OCF_RESKEY_server_port_default/"
OCF_RESKEY_keystone_get_token_url_default="http://127.0.0.1:5000/v2.0/tokens"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_host=${OCF_RESKEY_host_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
: ${OCF_RESKEY_url=${OCF_RESKEY_url_default}}
: ${OCF_RESKEY_keystone_get_token_url=${OCF_RESKEY_keystone_get_token_url_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack NovaAPI (nova-placement-api) process as an HA resource
The 'start' operation starts the nova-placement-api service.
The 'stop' operation stops the nova-placement-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the nova-placement-api service is running
The 'monitor' operation reports whether the nova-placement-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="nova-placement-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Nova Placement API Service (nova-placement-api)
May manage a nova-placement-api instance or a clone set that
creates a distributed nova-placement-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Nova Placement API (nova-placement-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Nova Placement API server binary (nova-placement-api)
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API server binary (nova-placement-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Nova Placement API (nova-placement-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Nova Placement API (nova-placement-api)
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Nova Placement API (nova-placement-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="host" unique="0" required="0">
<longdesc lang="en">
The default listening host of nova-placement-api.
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) monitor host</shortdesc>
<content type="string" default="${OCF_RESKEY_host_default}" />
</parameter>
<parameter name="port" unique="0" required="0">
<longdesc lang="en">
The default listening port of nova-placement-api.
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) monitor port</shortdesc>
<content type="string" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="url" unique="0" required="0">
<longdesc lang="en">
The default URL to use for monitoring this instance (nova-placement-api) via curl. Important note: the monitor function doesn't accept http return code different than 200, for instance redirection code will generate an error. Don't forget the '/' at the end of your url endpoint. For example http://127.0.0.1:8778/v1.1 won't work and http://127.0.0.1:8778/v1.1/ will.
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) monitor url</shortdesc>
<content type="string" default="${OCF_RESKEY_url_default}" />
</parameter>
<parameter name="keystone_get_token_url" unique="0" required="0">
<longdesc lang="en">
The default URL to use to acquire a Nova Placement API (nova-placement-api) token for monitoring this instance
of OpenStack Nova Placement API (nova-placement-api)
</longdesc>
<shortdesc lang="en">OpenStack Nova Placement API (nova-placement-api) url</shortdesc>
<content type="string" default="${OCF_RESKEY_keystone_get_token_url_default}" />
</parameter>
<parameter name="os_username" unique="0" required="0">
<longdesc lang="en">
The username to use when connecting with Nova Placement API (nova-placement-api) for monitoring purposes
</longdesc>
<shortdesc lang="en">Nova Placement API (nova-placement-api) monitoring login</shortdesc>
<content type="string" />
</parameter>
<parameter name="os_password" unique="0" required="0">
<longdesc lang="en">
The password to use when connecting Nova Placement API (nova-placement-api) for monitoring purposes
</longdesc>
<shortdesc lang="en">Nova Placement API (nova-placement-api) monitoring password</shortdesc>
<content type="string" />
</parameter>
<parameter name="os_tenant_name" unique="0" required="0">
<longdesc lang="en">
The tenant to use when connecting Nova Placement API (nova-placement-api) for monitoring purposes
</longdesc>
<shortdesc lang="en">Nova Placement API (nova-placement-api) monitoring tenant</shortdesc>
<content type="string" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Nova Placement API (nova-placement-api)
</longdesc>
<shortdesc lang="en">Additional parameters for nova-placement-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="10" interval="5" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
nova_placement_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary curl
check_binary tr
check_binary grep
check_binary cut
check_binary head
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
nova_placement_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Nova Placement API (nova-placement-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Placement API (nova-placement-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
nova_placement_api_monitor() {
local rc
nova_placement_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check detailed information about this specific version of the Placement API.
if [ -n "$OCF_RESKEY_os_username"] && [ -n "$OCF_RESKEY_os_tenant_name" ] && [ -n "$OCF_RESKEY_keystone_get_token_url" ]; then
./validation $OCF_RESKEY_keystone_get_token_url $OCF_RESKEY_os_username $OCF_RESKEY_os_tenant_name
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Failed to connect to the OpenStack Nova Placement API (nova-placement-api): $rc"
return $OCF_NOT_RUNNING
fi
fi
ocf_log debug "OpenStack Nova Placement API (nova-placement-api) monitor succeeded"
return $OCF_SUCCESS
}
nova_placement_api_start() {
local rc
nova_placement_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova Placement API (nova-placement-api) already running"
return $OCF_SUCCESS
fi
# Change the working dir to /, to be sure it's accesible
cd /
# Run the pre-start hooks. This can be used to trigger a nova database sync, for example.
/usr/bin/nova-controller-runhooks
# run the actual nova-placement-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} -p ${OCF_RESKEY_server_port} -b ${OCF_RESKEY_host} "' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
while true; do
nova_placement_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Nova Placement API (nova-placement-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Nova Placement API (nova-placement-api) started"
return $OCF_SUCCESS
}
nova_placement_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
nova_placement_api_stop() {
local rc
local pid
nova_placement_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova Placement API (nova-placement-api) already stopped"
nova_placement_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova Placement API (nova-placement-api) couldn't be stopped"
nova_placement_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
nova_placement_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Placement API (nova-placement-api) still hasn't stopped yet. Waiting ..."
done
nova_placement_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Placement API (nova-placement-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
nova_placement_api_confirm_stop
ocf_log info "OpenStack Nova Placement API (nova-placement-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
nova_placement_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) nova_placement_api_start;;
stop) nova_placement_api_stop;;
status) nova_placement_api_status;;
monitor) nova_placement_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,349 +0,0 @@
#!/bin/sh
#
#
# OpenStack Nova Serial Console (nova-serialproxy)
#
# Description: Manages an OpenStack Nova Serialproxy (nova-serialproxy) process as an HA resource
#
# Authors: Sébastien Han
# Mainly inspired by the novnc API resource agent written by Martin Gerhard Loschwitz from Hastexo: http://goo.gl/whLpr
#
# Support: openstack@lists.launchpad.net
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2018 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_console_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="nova-serialproxy"
OCF_RESKEY_config_default="/etc/nova/nova-ironic.conf"
OCF_RESKEY_user_default="nova"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_console_port_default="6083"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_console_port=${OCF_RESKEY_console_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Nova Serial proxy (nova-serialproxy) process as an HA resource
The 'start' operation starts the console service.
The 'stop' operation stops the console service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the console service is running
The 'monitor' operation reports whether the console service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="nova-serialproxy">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Nova Serialproxy Service (nova-serialproxy)
May manage a nova-serialproxy instance or a clone set that
creates a distributed nova-serialproxy cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Nova Serial Console (nova-serialproxy)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Nova Serial Console server binary (nova-serialproxy)
</longdesc>
<shortdesc lang="en">OpenStack Nova Serial Console server binary (nova-serialproxy)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Nova Serial Console (nova-serialproxy) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Nova Serial Console (nova-serialproxy registry) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Nova Serial proxy (nova-serialproxy)
</longdesc>
<shortdesc lang="en">OpenStack Nova Serialproxy (nova-serialproxy) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="console_port" unique="0" required="0">
<longdesc lang="en">
Serial console type running: nova-serialproxy
</longdesc>
<shortdesc lang="en">OpenStack Nova Serial Console (nova-serialproxy) console type</shortdesc>
<content type="integer" default="${OCF_RESKEY_console_port_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Nova Serial Console (nova-serialproxy) instance
</longdesc>
<shortdesc lang="en">OpenStack Nova VNC Console (nova-serialproxy) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Nova Serialproxy (nova-serialproxy)
</longdesc>
<shortdesc lang="en">Additional parameters for nova-serialproxy</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="10" />
<action name="stop" timeout="15" />
<action name="status" timeout="10" />
<action name="monitor" timeout="5" interval="10" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
nova_serial_console_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
nova_serial_console_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Nova Serialproxy (nova-serialproxy) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Nova Serialproxy (nova-serialproxy) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
nova_serial_console_monitor() {
local rc
local serial_list_check
nova_serial_console_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check whether we are supposed to monitor by logging into nova-serialproxy
# and do it if that's the case.
# Adding -n to netstat so that dns delays will not impact this.
serial_list_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "Nova Serial Console doesn't seem to listen on his default port: $rc"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Nova Serial Console (nova-serialproxy) monitor succeeded"
return $OCF_SUCCESS
}
nova_serial_console_start() {
local rc
nova_serial_console_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Nova Serial Console (nova-serialproxy) already running"
return $OCF_SUCCESS
fi
# Change the working dir to /, to be sure it's accesible
cd /
# run the actual nova-serialproxy daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user} -s /bin/sh -c "${OCF_RESKEY_binary} --config-file=$OCF_RESKEY_config \
$OCF_RESKEY_additional_parameters"' >> /dev/null 2>&1 & echo $!' > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
# Let the CRM/LRM time us out if required
while true; do
nova_serial_console_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Nova Serial Console (nova-serialproxy) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Nova Serial Console (nova-serialproxy) started"
return $OCF_SUCCESS
}
nova_serial_console_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
nova_serial_console_stop() {
local rc
local pid
nova_serial_console_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Nova Serial Console (nova-serialproxy) already stopped"
nova_serial_console_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Nova Serial Console (nova-serialproxy) couldn't be stopped"
nova_serial_console_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
nova_serial_console_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Nova Serial Console (nova-serialproxy) still hasn't stopped yet. Waiting ..."
done
nova_serial_console_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Nova Serial Console (nova-serialproxy) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
nova_serial_console_confirm_stop
ocf_log info "OpenStack Nova Serial Console (nova-serialproxy) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
nova_serial_console_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) nova_serial_console_start;;
stop) nova_serial_console_stop;;
status) nova_serial_console_status;;
monitor) nova_serial_console_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,365 +0,0 @@
#!/bin/sh
#
#
# OpenStack Panko API Service (panko-api)
#
# Description: Manages an OpenStack Panko API Service (panko-api) process as an HA resource
#
# License: Apache Software License (ASL) 2.0
#
# Copyright (c) 2017 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# See usage() function below for more details ...
#
# OCF instance parameters:
# OCF_RESKEY_binary
# OCF_RESKEY_config
# OCF_RESKEY_user
# OCF_RESKEY_pid
# OCF_RESKEY_monitor_binary
# OCF_RESKEY_server_port
# OCF_RESKEY_additional_parameters
#######################################################################
# Initialization:
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat}
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs
#######################################################################
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default="panko-api"
OCF_RESKEY_config_default="/etc/panko/panko.conf"
OCF_RESKEY_user_default="root"
OCF_RESKEY_pid_default="$HA_RSCTMP/$OCF_RESOURCE_INSTANCE.pid"
OCF_RESKEY_server_port_default="8977"
: ${OCF_RESKEY_binary=${OCF_RESKEY_binary_default}}
: ${OCF_RESKEY_config=${OCF_RESKEY_config_default}}
: ${OCF_RESKEY_user=${OCF_RESKEY_user_default}}
: ${OCF_RESKEY_pid=${OCF_RESKEY_pid_default}}
: ${OCF_RESKEY_server_port=${OCF_RESKEY_server_port_default}}
#######################################################################
usage() {
cat <<UEND
usage: $0 (start|stop|validate-all|meta-data|status|monitor)
$0 manages an OpenStack Panko API Service (panko-api) process as an HA resource
The 'start' operation starts the panko-api service.
The 'stop' operation stops the panko-api service.
The 'validate-all' operation reports whether the parameters are valid
The 'meta-data' operation reports this RA's meta-data information
The 'status' operation reports whether the panko-api service is running
The 'monitor' operation reports whether the panko-api service seems to be working
UEND
}
meta_data() {
cat <<END
<?xml version="1.0"?>
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
<resource-agent name="panko-api">
<version>1.0</version>
<longdesc lang="en">
Resource agent for the OpenStack Panko API Service (panko-api)
May manage a panko-api instance or a clone set that
creates a distributed panko-api cluster.
</longdesc>
<shortdesc lang="en">Manages the OpenStack Panko API Service (panko-api)</shortdesc>
<parameters>
<parameter name="binary" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Panko API server binary (panko-api)
</longdesc>
<shortdesc lang="en">OpenStack Panko API server binary (panko-api)</shortdesc>
<content type="string" default="${OCF_RESKEY_binary_default}" />
</parameter>
<parameter name="config" unique="0" required="0">
<longdesc lang="en">
Location of the OpenStack Panko API Service (panko-api) configuration file
</longdesc>
<shortdesc lang="en">OpenStack Panko API (panko-api) config file</shortdesc>
<content type="string" default="${OCF_RESKEY_config_default}" />
</parameter>
<parameter name="user" unique="0" required="0">
<longdesc lang="en">
User running OpenStack Panko API Service (panko-api)
</longdesc>
<shortdesc lang="en">OpenStack Panko API Service (panko-api) user</shortdesc>
<content type="string" default="${OCF_RESKEY_user_default}" />
</parameter>
<parameter name="pid" unique="0" required="0">
<longdesc lang="en">
The pid file to use for this OpenStack Panko API Service (panko-api) instance
</longdesc>
<shortdesc lang="en">OpenStack Panko API Service (panko-api) pid file</shortdesc>
<content type="string" default="${OCF_RESKEY_pid_default}" />
</parameter>
<parameter name="server_port" unique="0" required="0">
<longdesc lang="en">
The listening port number of the panko-api server.
</longdesc>
<shortdesc lang="en">panko-api listening port</shortdesc>
<content type="integer" default="${OCF_RESKEY_server_port_default}" />
</parameter>
<parameter name="additional_parameters" unique="0" required="0">
<longdesc lang="en">
Additional parameters to pass on to the OpenStack Panko API Service (panko-api)
</longdesc>
<shortdesc lang="en">Additional parameters for panko-api</shortdesc>
<content type="string" />
</parameter>
</parameters>
<actions>
<action name="start" timeout="20" />
<action name="stop" timeout="20" />
<action name="status" timeout="20" />
<action name="monitor" timeout="30" interval="20" />
<action name="validate-all" timeout="5" />
<action name="meta-data" timeout="5" />
</actions>
</resource-agent>
END
}
#######################################################################
# Functions invoked by resource manager actions
panko_api_check_port() {
# This function has been taken from the squid RA and improved a bit
# The length of the integer must be 4
# Examples of valid port: "1080", "0080"
# Examples of invalid port: "1080bad", "0", "0000", ""
local int
local cnt
int="$1"
cnt=${#int}
echo $int |egrep -qx '[0-9]+(:[0-9]+)?(,[0-9]+(:[0-9]+)?)*'
if [ $? -ne 0 ] || [ $cnt -ne 4 ]; then
ocf_log err "Invalid port number: $1"
exit $OCF_ERR_CONFIGURED
fi
}
panko_api_validate() {
local rc
check_binary $OCF_RESKEY_binary
check_binary netstat
panko_api_check_port $OCF_RESKEY_server_port
# A config file on shared storage that is not available
# during probes is OK.
if [ ! -f $OCF_RESKEY_config ]; then
if ! ocf_is_probe; then
ocf_log err "Config $OCF_RESKEY_config doesn't exist"
return $OCF_ERR_INSTALLED
fi
ocf_log_warn "Config $OCF_RESKEY_config not available during a probe"
fi
getent passwd $OCF_RESKEY_user >/dev/null 2>&1
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "User $OCF_RESKEY_user doesn't exist"
return $OCF_ERR_INSTALLED
fi
true
}
panko_api_status() {
local pid
local rc
if [ ! -f $OCF_RESKEY_pid ]; then
ocf_log info "OpenStack Panko API (panko-api) is not running"
return $OCF_NOT_RUNNING
else
pid=`cat $OCF_RESKEY_pid`
fi
ocf_run -warn kill -s 0 $pid
rc=$?
if [ $rc -eq 0 ]; then
return $OCF_SUCCESS
else
ocf_log info "Old PID file found, but OpenStack Panko API (panko-api) is not running"
rm -f $OCF_RESKEY_pid
return $OCF_NOT_RUNNING
fi
}
panko_api_monitor() {
local rc
local pid
local rc_db
local engine_db_check
panko_api_status
rc=$?
# If status returned anything but success, return that immediately
if [ $rc -ne $OCF_SUCCESS ]; then
return $rc
fi
# Check the server is listening on the server port
engine_db_check=`netstat -an | grep -s "$OCF_RESKEY_console_port" | grep -qs "LISTEN"`
rc_db=$?
if [ $rc_db -ne 0 ]; then
ocf_log err "panko-api is not listening on $OCF_RESKEY_console_port: $rc_db"
return $OCF_NOT_RUNNING
fi
ocf_log debug "OpenStack Panko API (panko-api) monitor succeeded"
return $OCF_SUCCESS
}
panko_api_start() {
local rc
local host
panko_api_status
rc=$?
if [ $rc -eq $OCF_SUCCESS ]; then
ocf_log info "OpenStack Panko API (panko-api) already running"
return $OCF_SUCCESS
fi
# run the actual panko-api daemon. Don't use ocf_run as we're sending the tool's output
# straight to /dev/null anyway and using ocf_run would break stdout-redirection here.
su ${OCF_RESKEY_user}
/bin/python /usr/bin/gunicorn --config /usr/share/panko/panko-api.conf --access-logfile /dev/null \
--pythonpath /usr/share/panko panko-api >> /var/log/panko/panko-api.log 2>&1 & echo $! > $OCF_RESKEY_pid
# Spin waiting for the server to come up.
while true; do
panko_api_monitor
rc=$?
[ $rc -eq $OCF_SUCCESS ] && break
if [ $rc -ne $OCF_NOT_RUNNING ]; then
ocf_log err "OpenStack Panko API (panko-api) start failed"
exit $OCF_ERR_GENERIC
fi
sleep 1
done
ocf_log info "OpenStack Panko API (panko-api) started"
return $OCF_SUCCESS
}
panko_api_confirm_stop() {
local my_bin
local my_processes
my_binary=`which ${OCF_RESKEY_binary}`
my_processes=`pgrep -l -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"`
if [ -n "${my_processes}" ]
then
ocf_log info "About to SIGKILL the following: ${my_processes}"
pkill -KILL -f "^(python|/usr/bin/python|/usr/bin/python2) ${my_binary}([^\w-]|$)"
fi
}
panko_api_stop() {
local rc
local pid
panko_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
ocf_log info "OpenStack Panko API (panko-api) already stopped"
panko_api_confirm_stop
return $OCF_SUCCESS
fi
# Try SIGTERM
pid=`cat $OCF_RESKEY_pid`
ocf_run kill -s TERM $pid
rc=$?
if [ $rc -ne 0 ]; then
ocf_log err "OpenStack Panko API (panko-api) couldn't be stopped"
panko_api_confirm_stop
exit $OCF_ERR_GENERIC
fi
# stop waiting
shutdown_timeout=15
if [ -n "$OCF_RESKEY_CRM_meta_timeout" ]; then
shutdown_timeout=$((($OCF_RESKEY_CRM_meta_timeout/1000)-5))
fi
count=0
while [ $count -lt $shutdown_timeout ]; do
panko_api_status
rc=$?
if [ $rc -eq $OCF_NOT_RUNNING ]; then
break
fi
count=`expr $count + 1`
sleep 1
ocf_log debug "OpenStack Panko API (panko-api) still hasn't stopped yet. Waiting ..."
done
panko_api_status
rc=$?
if [ $rc -ne $OCF_NOT_RUNNING ]; then
# SIGTERM didn't help either, try SIGKILL
ocf_log info "OpenStack Panko API (panko-api) failed to stop after ${shutdown_timeout}s \
using SIGTERM. Trying SIGKILL ..."
ocf_run kill -s KILL $pid
fi
panko_api_confirm_stop
ocf_log info "OpenStack Panko API (panko-api) stopped"
rm -f $OCF_RESKEY_pid
return $OCF_SUCCESS
}
#######################################################################
case "$1" in
meta-data) meta_data
exit $OCF_SUCCESS;;
usage|help) usage
exit $OCF_SUCCESS;;
esac
# Anything except meta-data and help must pass validation
panko_api_validate || exit $?
# What kind of method was invoked?
case "$1" in
start) panko_api_start;;
stop) panko_api_stop;;
status) panko_api_status;;
monitor) panko_api_monitor;;
validate-all) ;;
*) usage
exit $OCF_ERR_UNIMPLEMENTED;;
esac

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env python
#
# Copyright (c) 2014 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from keystoneclient import probe
probe.main()