From ecde5f7699759af952e0e0f5320f54f0c955ada2 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 8 Oct 2012 15:06:09 +0100 Subject: [PATCH] Added support for remote OSD services --- hooks/hooks.py | 28 +++++++++++++++++++++++++++- hooks/osd-relation-joined | 1 + hooks/utils.py | 8 +++++++- metadata.yaml | 7 +++++++ revision | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) create mode 120000 hooks/osd-relation-joined diff --git a/hooks/hooks.py b/hooks/hooks.py index 4148c5d..423b493 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -12,7 +12,6 @@ import glob import os import subprocess import shutil -import socket import sys import ceph @@ -147,6 +146,8 @@ def mon_relation(): osdize(dev) subprocess.call(['udevadm', 'trigger', '--subsystem-match=block', '--action=add']) + + notify_osds() else: utils.juju_log('INFO', 'Not enough mons ({}), punting.'.format( @@ -155,6 +156,30 @@ def mon_relation(): utils.juju_log('INFO', 'End mon-relation hook.') +def notify_osds(): + utils.juju_log('INFO', 'Begin notify_osds.') + + for relid in utils.relation_ids('osd'): + utils.relation_set(fsid=utils.config_get('fsid'), + rid=relid) + + utils.juju_log('INFO', 'End notify_osds.') + + +def osd_relation(): + utils.juju_log('INFO', 'Begin osd-relation hook.') + + if ceph.is_quorum(): + utils.juju_log('INFO', + 'mon cluster in quorum - providing OSD with fsid') + utils.relation_set(fsid=utils.config_get('fsid')) + else: + utils.juju_log('INFO', + 'mon cluster not in quorum - deferring fsid provision') + + utils.juju_log('INFO', 'End osd-relation hook.') + + def upgrade_charm(): utils.juju_log('INFO', 'Begin upgrade-charm hook.') emit_cephconf() @@ -175,6 +200,7 @@ utils.do_hooks({ 'install': install, 'mon-relation-departed': mon_relation, 'mon-relation-joined': mon_relation, + 'osd-relation-joined': osd_relation, 'start': start, 'upgrade-charm': upgrade_charm, }) diff --git a/hooks/osd-relation-joined b/hooks/osd-relation-joined new file mode 120000 index 0000000..9416ca6 --- /dev/null +++ b/hooks/osd-relation-joined @@ -0,0 +1 @@ +hooks.py \ No newline at end of file diff --git a/hooks/utils.py b/hooks/utils.py index 64c578e..7e2da93 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -129,8 +129,14 @@ def relation_set(**kwargs): cmd = [ 'relation-set' ] + args = [] for k, v in kwargs.items(): - cmd.append('{}={}'.format(k, v)) + if k == 'rid': + cmd.append('-r') + cmd.append(v) + else: + args.append('{}={}'.format(k, v)) + cmd += args subprocess.check_call(cmd) diff --git a/metadata.yaml b/metadata.yaml index 6a36343..3f0147d 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -8,3 +8,10 @@ description: | peers: mon: interface: ceph-brolin +provides: + client: + interface: ceph-client + osd: + interface: ceph-osd + radosgw: + interface: ceph-radosgw diff --git a/revision b/revision index b5489e5..39f5b69 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -69 +71