Revision d81ec8b7 htools/Ganeti/Config.hs
b/htools/Ganeti/Config.hs | ||
---|---|---|
32 | 32 |
, getNode |
33 | 33 |
, getInstance |
34 | 34 |
, getInstPrimaryNode |
35 |
, getInstMinorsForNode |
|
35 | 36 |
, buildLinkIpInstnameMap |
36 | 37 |
, instNodes |
37 | 38 |
) where |
... | ... | |
133 | 134 |
getInstPrimaryNode cfg name = |
134 | 135 |
getInstance cfg name >>= return . instPrimaryNode >>= getNode cfg |
135 | 136 |
|
137 |
-- | Filters DRBD minors for a given node. |
|
138 |
getDrbdMinorsForNode :: String -> Disk -> [(Int, String)] |
|
139 |
getDrbdMinorsForNode node disk = |
|
140 |
let child_minors = concatMap (getDrbdMinorsForNode node) (diskChildren disk) |
|
141 |
this_minors = |
|
142 |
case diskLogicalId disk of |
|
143 |
LIDDrbd8 nodeA nodeB _ minorA minorB _ |
|
144 |
| nodeA == node -> [(minorA, nodeB)] |
|
145 |
| nodeB == node -> [(minorB, nodeA)] |
|
146 |
_ -> [] |
|
147 |
in this_minors ++ child_minors |
|
148 |
|
|
149 |
-- | String for primary role. |
|
150 |
rolePrimary :: String |
|
151 |
rolePrimary = "primary" |
|
152 |
|
|
153 |
-- | String for secondary role. |
|
154 |
roleSecondary :: String |
|
155 |
roleSecondary = "secondary" |
|
156 |
|
|
157 |
-- | Gets the list of DRBD minors for an instance that are related to |
|
158 |
-- a given node. |
|
159 |
getInstMinorsForNode :: String -> Instance |
|
160 |
-> [(String, Int, String, String, String, String)] |
|
161 |
getInstMinorsForNode node inst = |
|
162 |
let role = if node == instPrimaryNode inst |
|
163 |
then rolePrimary |
|
164 |
else roleSecondary |
|
165 |
iname = instName inst |
|
166 |
-- FIXME: the disk/ build there is hack-ish; unify this in a |
|
167 |
-- separate place, or reuse the iv_name (but that is deprecated on |
|
168 |
-- the Python side) |
|
169 |
in concatMap (\(idx, dsk) -> |
|
170 |
[(node, minor, iname, "disk/" ++ show idx, role, peer) |
|
171 |
| (minor, peer) <- getDrbdMinorsForNode node dsk]) . |
|
172 |
zip [(0::Int)..] . instDisks $ inst |
|
173 |
|
|
136 | 174 |
-- | Builds link -> ip -> instname map. |
137 | 175 |
-- |
138 | 176 |
-- TODO: improve this by splitting it into multiple independent functions: |
Also available in: Unified diff