]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-crush-location.in
bump version to 12.2.4-pve1
[ceph.git] / ceph / src / ceph-crush-location.in
CommitLineData
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.
17if [ `dirname $0` = "." ] && [ $PWD != "/usr/bin" ]; then
18 BINDIR=.
19 SBINDIR=.
20 LIBDIR=.
21 ETCDIR=.
22else
23 BINDIR=@bindir@
24 SBINDIR=@prefix@/sbin
25 LIBDIR=@libdir@/ceph
26 ETCDIR=@sysconfdir@/ceph
27fi
28
29usage_exit() {
30 echo "usage: $0 [--cluster <cluster>] --id <id> --type <osd|mds|client>"
31 exit
32}
33
34cluster="ceph"
35type=""
36id=""
37while [ $# -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
59done
60
61if [ -z "$type" ]; then
62 echo "must specify entity type"
63 usage_exit
64fi
65
66if [ -z "$id" ]; then
67 echo "must specify id"
68 usage_exit
69fi
70
71# try a generic location
72location="$($BINDIR/ceph-conf --cluster=${cluster:-ceph} --name=$type.$id --lookup crush_location || :)"
73if [ -n "$location" ]; then
74 echo $location
75 exit 0
76fi
77
78# spit out something generic
79echo "host=$(hostname -s) root=default"
80