From ab84949da204da4a94473f353b4b0f3cc764e31e Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Tue, 2 Oct 2012 16:53:35 -0700 Subject: [PATCH] ceph-disk-activate: Use mount options from ceph.conf Always uses default cluster name ("ceph") for now, see http://tracker.newdream.net/issues/3253 Closes: #2548 Signed-off-by: Tommi Virtanen --- src/ceph-disk-activate | 46 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/ceph-disk-activate b/src/ceph-disk-activate index 3062d1c25780c..9ada2198ff5f3 100755 --- a/src/ceph-disk-activate +++ b/src/ceph-disk-activate @@ -315,6 +315,37 @@ def detect_fstype( return fstype +def get_conf(cluster, variable): + try: + p = subprocess.Popen( + args=[ + 'ceph-conf', + '--cluster={cluster}'.format( + cluster=cluster, + ), + '--name=osd.', + '--lookup', + variable, + ], + stdout=subprocess.PIPE, + close_fds=True, + ) + except OSError as e: + raise ActivateError('error executing ceph-conf', e) + (out, _err) = p.communicate() + ret = p.wait() + if ret == 1: + # config entry not found + return None + elif ret != 0: + raise ActivateError('getting variable from configuration failed') + value = out.split('\n', 1)[0] + # don't differentiate between "var=" and no var set + if not value: + return None + return value + + MOUNT_OPTIONS = dict( ext4='user_xattr', ) @@ -323,9 +354,11 @@ MOUNT_OPTIONS = dict( def mount( dev, fstype, + options, ): # pick best-of-breed mount options based on fs type - options = MOUNT_OPTIONS.get(fstype, '') + if options is None: + options = MOUNT_OPTIONS.get(fstype, '') # mount path = tempfile.mkdtemp( @@ -384,7 +417,16 @@ def activate( e, ) - path = mount(dev=path, fstype=fstype) + mount_options = get_conf( + # TODO always using mount options from cluster=ceph for + # now; see http://tracker.newdream.net/issues/3253 + cluster='ceph', + variable='osd_fs_mount_options_{fstype}'.format( + fstype=fstype, + ), + ) + + path = mount(dev=path, fstype=fstype, options=mount_options) try: check_osd_magic(path) -- 2.39.5