]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #!/bin/sh |
2 | # | |
3 | # Generate a CRUSH location for the given entity | |
4 | # | |
5 | # The CRUSH location consists of a list of key=value pairs, separated | |
6 | # by spaces, all on a single line. This describes where in CRUSH | |
7 | # hierarhcy this entity should be placed. | |
8 | # | |
9 | # Arguments: | |
10 | # --cluster <clustername> name of the cluster (see /etc/ceph/$cluster.conf) | |
11 | # --type <osd|mds|client> daemon/entity type | |
12 | # --id <id> id (osd number, mds name, client name) | |
13 | # | |
14 | ||
15 | # if we start up as ./ceph-crush-location, assume everything else is | |
16 | # in the current directory too. | |
17 | if [ `dirname $0` = "." ] && [ $PWD != "/usr/bin" ]; then | |
18 | BINDIR=. | |
19 | SBINDIR=. | |
20 | LIBDIR=. | |
21 | ETCDIR=. | |
22 | else | |
23 | BINDIR=@bindir@ | |
24 | SBINDIR=@prefix@/sbin | |
25 | LIBDIR=@libdir@/ceph | |
26 | ETCDIR=@sysconfdir@/ceph | |
27 | fi | |
28 | ||
29 | usage_exit() { | |
30 | echo "usage: $0 [--cluster <cluster>] --id <id> --type <osd|mds|client>" | |
31 | exit | |
32 | } | |
33 | ||
34 | cluster="ceph" | |
35 | type="" | |
36 | id="" | |
37 | while [ $# -ge 1 ]; do | |
38 | case $1 in | |
39 | --cluster | -C) | |
40 | shift | |
41 | cluster="$1" | |
42 | shift | |
43 | ;; | |
44 | --id | -i) | |
45 | shift | |
46 | id="$1" | |
47 | shift | |
48 | ;; | |
49 | --type | -t) | |
50 | shift | |
51 | type="$1" | |
52 | shift | |
53 | ;; | |
54 | *) | |
55 | echo "unrecognized option '$1'" | |
56 | usage_exit | |
57 | ;; | |
58 | esac | |
59 | done | |
60 | ||
61 | if [ -z "$type" ]; then | |
62 | echo "must specify entity type" | |
63 | usage_exit | |
64 | fi | |
65 | ||
66 | if [ -z "$id" ]; then | |
67 | echo "must specify id" | |
68 | usage_exit | |
69 | fi | |
70 | ||
71 | # try a generic location | |
72 | location="$($BINDIR/ceph-conf --cluster=${cluster:-ceph} --name=$type.$id --lookup crush_location || :)" | |
73 | if [ -n "$location" ]; then | |
74 | echo $location | |
75 | exit 0 | |
76 | fi | |
77 | ||
78 | # spit out something generic | |
79 | echo "host=$(hostname -s) root=default" | |
80 |