From 1d077ee509415b5700a455cefd8c88064d98b940 Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Mon, 25 Feb 2013 16:27:11 -0800 Subject: [PATCH] Ship RBD OCF RA /w charm. The rbd OCF was not included with the ceph-resource-agents package until quantal. There is currently not an easy way to install from another repository as it will also upgrade other ceph package in the principle service. As a temporary alternative, ship the rbd OCF /w the charm for 12.04. Also improve logging for cases where principle has not passed minimum required corosync config. --- hooks/hooks.py | 10 ++ ocf/ceph/rbd | 296 +++++++++++++++++++++++++++++++++++++++++++++++++ revision | 2 +- 3 files changed, 307 insertions(+), 1 deletion(-) create mode 100755 ocf/ceph/rbd diff --git a/hooks/hooks.py b/hooks/hooks.py index 415331f..94124ff 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -7,6 +7,7 @@ # Andres Rodriguez # +import shutil import sys import time import os @@ -19,6 +20,12 @@ def install(): utils.juju_log('INFO', 'Begin install hook.') utils.configure_source() utils.install('corosync', 'pacemaker', 'python-netaddr', 'ipmitool') + # XXX rbd OCF only included with newer versions of ceph-resource-agents. + # Bundle /w charm until we figure out a better way to install it. + if not os.path.exists('/usr/lib/ocf/resource.d/ceph'): + os.makedirs('/usr/lib/ocf/resource.d/ceph') + if not os.path.isfile('/usr/lib/ocf/resource.d/ceph/rbd'): + shutil.copy('ocf/ceph/rbd', '/usr/lib/ocf/resource.d/ceph/rbd') utils.juju_log('INFO', 'End install hook.') @@ -38,6 +45,9 @@ def get_corosync_conf(): } if None not in conf.itervalues(): return conf + missing = [k for k, v in config.iteritems() if v == None] + utils.juju_log('INFO', + 'Missing required principle configuration: %s' % missing) return None diff --git a/ocf/ceph/rbd b/ocf/ceph/rbd new file mode 100755 index 0000000..bb284c7 --- /dev/null +++ b/ocf/ceph/rbd @@ -0,0 +1,296 @@ +#!/bin/sh +# +# OCF resource agent for mapping and unmapping +# RADOS Block Devices (RBDs) +# +# License: GNU Lesser General Public License (LGPL) 2.1 +# (c) 2012 Florian Haas, hastexo +# + +# Initialization: +: ${OCF_FUNCTIONS_DIR=${OCF_ROOT}/lib/heartbeat} +. ${OCF_FUNCTIONS_DIR}/ocf-shellfuncs + +# Convenience variables +# When sysconfdir isn't passed in as a configure flag, +# it's defined in terms of prefix +prefix=/usr + +# Defaults +OCF_RESKEY_pool_default="rbd" +OCF_RESKEY_cephconf_default="/etc/ceph/ceph.conf" +: ${OCF_RESKEY_pool=${OCF_RESKEY_pool_default}} +: ${OCF_RESKEY_cephconf=${OCF_RESKEY_cephconf_default}} + +rbd_meta_data() { + cat < + + + 0.1 + +Manages RADOS Block Devices (RBDs) as a highly available +resource. Maps and unmaps RBDs as needed. + + Maps and unmaps RADOS Block Devices + + + + Name of the RBD device. + + RBD device name + + + + + Name of the RADOS pool where the RBD has been created + + RADOS pool name + + + + + Name of the device snapshot to map. + + Snapshot name + + + + + Location of the Ceph configuration file + + Ceph configuration file + + + + + Address (or comma-separated list of addresses) of + monitor servers to connect to. Overrides values from + configuration file. + + Monitor address(es) + + + + + Username to use when mapping the device. Required + if Ceph authentication is enabled on the monitor. + + Authentication username + + + + + File containing an authentication secret. Required + if Ceph authentication is enabled on the monitor. + + Authentication secret file + + + + + + + + + + + +EOF +} + +rbd_usage() { + cat <