summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/ceph-osd/files/ceph-crush-location.in
blob: d763751080c5a61ec0253c92b2926d3879cb6506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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 <clustername>   name of the cluster (see /etc/ceph/$cluster.conf)
#   --type <osd|mds|client>   daemon/entity type
#   --id <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 <cluster>] --id <id> --type <osd|mds|client>"
    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"