From: Sage Weil Date: Tue, 29 Oct 2013 18:03:04 +0000 (-0700) Subject: ceph-crush-location: new crush location hook X-Git-Tag: v0.73~59^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9f6af8b4588390274043f01d2ef9b0a0146a1839;p=ceph.git ceph-crush-location: new crush location hook This generalizes the bit of code that builds a key=value pair list to update an entity's CRUSH location. Signed-off-by: Sage Weil --- diff --git a/ceph.spec.in b/ceph.spec.in index a9c5dc3c74b7..7aeca1a4ddb0 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -392,6 +392,7 @@ fi %{_bindir}/ceph-authtool %{_bindir}/ceph-syn %{_bindir}/ceph-post-file +%{_bindir}/ceph-crush-location %{_bindir}/ceph-run %{_bindir}/ceph-mon %{_bindir}/ceph-mds diff --git a/debian/ceph-common.install b/debian/ceph-common.install index 41453f5a6463..8e3e48b9b82f 100644 --- a/debian/ceph-common.install +++ b/debian/ceph-common.install @@ -6,6 +6,7 @@ usr/bin/ceph-conf usr/bin/ceph-dencoder usr/bin/ceph-rest-api usr/bin/ceph-syn +usr/bin/ceph-crush-location usr/bin/rados usr/bin/rbd usr/bin/ceph-post-file diff --git a/src/.gitignore b/src/.gitignore index 8542ba868f9d..817fee955ffa 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -11,6 +11,7 @@ Makefile /ceph-authtool /ceph-conf /ceph-coverage +/ceph-crush-location /ceph-debugpack /ceph-post-file /ceph-dencoder diff --git a/src/Makefile.am b/src/Makefile.am index d9189bde9cab..fa0224524170 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -128,7 +128,7 @@ editpaths = sed \ -e 's|@datadir[@]|$(pkgdatadir)|g' \ -e 's|@prefix[@]|$(prefix)|g' \ -e 's|@@GCOV_PREFIX_STRIP[@][@]|$(GCOV_PREFIX_STRIP)|g' -shell_scripts = ceph-debugpack ceph-post-file +shell_scripts = ceph-debugpack ceph-post-file ceph-crush-location $(shell_scripts): Makefile $(shell_scripts): %: %.in rm -f $@ $@.tmp @@ -180,6 +180,7 @@ EXTRA_DIST += \ ceph-disk-udev \ ceph-create-keys \ ceph-rest-api \ + ceph-crush-location \ mount.fuse.ceph \ rbdmap \ unittest_bufferlist.sh \ @@ -236,7 +237,8 @@ bin_SCRIPTS += \ ceph-clsinfo \ ceph-debugpack \ ceph-rbdnamer \ - ceph-post-file + ceph-post-file \ + ceph-crush-location BUILT_SOURCES += init-ceph su_sbin_SCRIPTS += mkcephfs diff --git a/src/ceph-crush-location.in b/src/ceph-crush-location.in new file mode 100755 index 000000000000..b5043f269a88 --- /dev/null +++ b/src/ceph-crush-location.in @@ -0,0 +1,87 @@ +#!/bin/sh +# +# Generate a CRUSH location for the given entity +# +# The CRUSH location consists of a list of key=value pairs, separated +# by spaces, all on a single line. This describes where in CRUSH +# hierarhcy this entity should be placed. +# +# Arguments: +# --cluster name of the cluster (see /etc/ceph/$cluster.conf) +# --type daemon/entity type +# --id id (osd number, mds name, client name) +# + +# if we start up as ./ceph-crush-location, assume everything else is +# in the current directory too. +if [ `dirname $0` = "." ] && [ $PWD != "/usr/bin" ]; then + BINDIR=. + SBINDIR=. + LIBDIR=. + ETCDIR=. +else + BINDIR=@bindir@ + SBINDIR=@prefix@/sbin + LIBDIR=@libdir@/ceph + ETCDIR=@sysconfdir@/ceph +fi + +usage_exit() { + echo "usage: $0 [--cluster ] --id --type " + exit +} + +cluster="ceph" +type="" +id="" +while [ $# -ge 1 ]; do + case $1 in + --cluster | -C) + shift + cluster="$1" + shift + ;; + --id | -i) + shift + id="$1" + shift + ;; + --type | -t) + shift + type="$1" + shift + ;; + *) + echo "unrecognized option '$1'" + usage_exit + ;; + esac +done + +if [ -z "$type" ]; then + echo "must specify entity type" + usage_exit +fi + +if [ -z "$id" ]; then + echo "must specify id" + usage_exit +fi + +# try a type-specific config, e.g. 'osd crush location' +location="$($BINDIR/ceph-conf --cluster=${cluster:-ceph} --name=$type.$id --lookup ${type}_crush_location || :)" +if [ -n "$location" ]; then + echo $location + exit 0 +fi + +# try a generic location +location="$($BINDIR/ceph-conf --cluster=${cluster:-ceph} --name=$type.$id --lookup crush_location || :)" +if [ -n "$location" ]; then + echo $location + exit 0 +fi + +# spit out something generic +echo "host=$(hostname -s) root=default" +