X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fceph-crush-location.in;fp=src%2Fceph%2Fsrc%2Fceph-crush-location.in;h=a8c22a8dcf687236e5396f2e3194f4090d805b35;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/ceph-crush-location.in b/src/ceph/src/ceph-crush-location.in new file mode 100755 index 0000000..a8c22a8 --- /dev/null +++ b/src/ceph/src/ceph-crush-location.in @@ -0,0 +1,80 @@ +#!/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 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" +