blob: 17127db590f63ba19d4f525de3ad73a1d2573635 (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
$ crushtool -i "$TESTDIR/simple.template" --add-item 0 1.0 device0 --loc host host0 --loc cluster cluster0 -o one > /dev/null
$ crushtool -i one --add-item 1 1.0 device1 --loc host host0 --loc cluster cluster0 -o two > /dev/null
$ crushtool -i two --create-simple-rule simple-rule cluster0 host firstn -o two > /dev/null
$ crushtool -d two
# begin crush map
# devices
device 0 device0
device 1 device1
# types
type 0 device
type 1 host
type 2 cluster
# buckets
host host0 {
\tid -2\t\t# do not change unnecessarily (esc)
\t# weight 2.000 (esc)
\talg straw (esc)
\thash 0\t# rjenkins1 (esc)
\titem device0 weight 1.000 (esc)
\titem device1 weight 1.000 (esc)
}
cluster cluster0 {
\tid -1\t\t# do not change unnecessarily (esc)
\t# weight 2.000 (esc)
\talg straw (esc)
\thash 0\t# rjenkins1 (esc)
\titem host0 weight 2.000 (esc)
}
# rules
rule data {
\tid 0 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
rule metadata {
\tid 1 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
rule rbd {
\tid 2 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
rule simple-rule {
\tid 3 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
# end crush map
$ crushtool -i two --remove-rule simple-rule -o two > /dev/null
$ crushtool -d two
# begin crush map
# devices
device 0 device0
device 1 device1
# types
type 0 device
type 1 host
type 2 cluster
# buckets
host host0 {
\tid -2\t\t# do not change unnecessarily (esc)
\t# weight 2.000 (esc)
\talg straw (esc)
\thash 0\t# rjenkins1 (esc)
\titem device0 weight 1.000 (esc)
\titem device1 weight 1.000 (esc)
}
cluster cluster0 {
\tid -1\t\t# do not change unnecessarily (esc)
\t# weight 2.000 (esc)
\talg straw (esc)
\thash 0\t# rjenkins1 (esc)
\titem host0 weight 2.000 (esc)
}
# rules
rule data {
\tid 0 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
rule metadata {
\tid 1 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
rule rbd {
\tid 2 (esc)
\ttype replicated (esc)
\tmin_size 1 (esc)
\tmax_size 10 (esc)
\tstep take cluster0 (esc)
\tstep chooseleaf firstn 0 type host (esc)
\tstep emit (esc)
}
# end crush map
$ crushtool -d two -o final
$ cmp final "$TESTDIR/simple.template.two"
$ crushtool -i two --add-item 1 1.0 device1 --loc host host0 --loc cluster cluster0 -o three 2>/dev/null >/dev/null || echo FAIL
FAIL
$ crushtool -i two --remove-item device1 -o four > /dev/null
$ crushtool -d four -o final
$ cmp final "$TESTDIR/simple.template.four"
$ crushtool -i two --update-item 1 2.0 osd1 --loc host host1 --loc cluster cluster0 -o five > /dev/null
$ crushtool -d five -o final
$ cmp final "$TESTDIR/simple.template.five"
$ crushtool -i five --update-item 1 2.0 osd1 --loc host host1 --loc cluster cluster0 -o six > /dev/null
$ crushtool -i five --show-location 1
cluster\tcluster0 (esc)
host\thost1 (esc)
$ crushtool -d six -o final
$ cmp final "$TESTDIR/simple.template.five"
|