| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# |
| 4 |
# geostore OCF RA. Just an example on how to use |
| 5 |
# geo-attr.sh |
| 6 |
# |
| 7 |
# Copyright (c) 2015 Dejan Muhamedagic <[email protected]> |
| 8 |
# All Rights Reserved. |
| 9 |
# |
| 10 |
# This program is free software; you can redistribute it and/or modify |
| 11 |
# it under the terms of version 2 of the GNU General Public License as |
| 12 |
# published by the Free Software Foundation. |
| 13 |
# |
| 14 |
# This program is distributed in the hope that it would be useful, but |
| 15 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 17 |
# |
| 18 |
# Further, this software is distributed without any warranty that it is |
| 19 |
# free of the rightful claim of any third person regarding infringement |
| 20 |
# or the like. Any license provided herein, whether implied or |
| 21 |
# otherwise, applies only to this software file. Patent licenses, if |
| 22 |
# any, provided herein do not apply to combinations of this program with |
| 23 |
# other software, or any other product whatsoever. |
| 24 |
# |
| 25 |
# You should have received a copy of the GNU General Public License along |
| 26 |
# with this program; if not, write to the Free Software Foundation, Inc., |
| 27 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 28 |
# |
| 29 |
|
| 30 |
####################################################################### |
| 31 |
# Initialization: |
| 32 |
|
| 33 |
: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} |
| 34 |
# shellcheck source=/usr/lib/ocf/lib/heartbeat/ocf-shellfuncs |
| 35 |
. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs |
| 36 |
# shellcheck source=script/ocf/geo_attr.sh |
| 37 |
. ${OCF_ROOT}/lib/booth/geo_attr.sh |
| 38 |
|
| 39 |
####################################################################### |
| 40 |
|
| 41 |
geostore_meta_data() { |
| 42 |
cat <<END |
| 43 |
<?xml version="1.0"?> |
| 44 |
<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> |
| 45 |
<resource-agent name="$NAME" version="0.9"> |
| 46 |
<version>1.0</version> |
| 47 |
|
| 48 |
<longdesc lang="en"> |
| 49 |
This is the geostore Resource Agent. It's a sample for how to use |
| 50 |
geo_attr.sh. |
| 51 |
</longdesc> |
| 52 |
<shortdesc lang="en">Sample GEO attribute RA</shortdesc> |
| 53 |
|
| 54 |
<parameters> |
| 55 |
`geo_attr_meta_data` |
| 56 |
</parameters> |
| 57 |
|
| 58 |
<actions> |
| 59 |
<action name="start" timeout="20" /> |
| 60 |
<action name="stop" timeout="20" /> |
| 61 |
<action name="monitor" timeout="20" interval="10" depth="0" /> |
| 62 |
<action name="reload" timeout="20" /> |
| 63 |
<action name="migrate_to" timeout="20" /> |
| 64 |
<action name="migrate_from" timeout="20" /> |
| 65 |
<action name="meta-data" timeout="5" /> |
| 66 |
<action name="validate-all" timeout="20" /> |
| 67 |
</actions> |
| 68 |
</resource-agent> |
| 69 |
END |
| 70 |
} |
| 71 |
|
| 72 |
####################################################################### |
| 73 |
|
| 74 |
geostore_usage() { |
| 75 |
cat <<END |
| 76 |
usage: $0 {start|stop|monitor|migrate_to|migrate_from|validate-all|meta-data} |
| 77 |
|
| 78 |
Expects to have a fully populated OCF RA-compliant environment set. |
| 79 |
END |
| 80 |
} |
| 81 |
|
| 82 |
geostore_start() { |
| 83 |
if [ -n "$OCF_RESKEY_booth_ticket" ]; then |
| 84 |
geo_attr_geo_attr 1 |
| 85 |
ocf_log info "set GEO attribute to `geo_attr_read_attr`" |
| 86 |
fi |
| 87 |
ha_pseudo_resource geostore_${OCF_RESOURCE_INSTANCE} start |
| 88 |
} |
| 89 |
|
| 90 |
geostore_stop() { |
| 91 |
if [ -n "$OCF_RESKEY_booth_ticket" ]; then |
| 92 |
geo_attr_geo_attr 0 |
| 93 |
ocf_log info "removed GEO attribute" |
| 94 |
fi |
| 95 |
ha_pseudo_resource geostore_${OCF_RESOURCE_INSTANCE} stop |
| 96 |
} |
| 97 |
|
| 98 |
geostore_monitor() { |
| 99 |
if ha_pseudo_resource geostore_${OCF_RESOURCE_INSTANCE} monitor |
| 100 |
then |
| 101 |
return $OCF_SUCCESS |
| 102 |
else |
| 103 |
return $OCF_NOT_RUNNING |
| 104 |
fi |
| 105 |
} |
| 106 |
|
| 107 |
geostore_validate_all() { |
| 108 |
if ! geo_attr_validate_all; then |
| 109 |
return $OCF_ERR_INSTALL |
| 110 |
fi |
| 111 |
return $OCF_SUCCESS |
| 112 |
} |
| 113 |
|
| 114 |
ocf_rarun $* |