Revision 9491766c src/Ganeti/Config.hs

b/src/Ganeti/Config.hs
44 44
    , getGroupOfNode
45 45
    , getInstPrimaryNode
46 46
    , getInstMinorsForNode
47
    , getInstAllNodes
47 48
    , getNetwork
48 49
    , buildLinkIpInstnameMap
49 50
    , instNodes
50 51
    ) where
51 52

  
52 53
import Control.Monad (liftM)
53
import Data.List (foldl')
54
import Data.List (foldl', nub)
54 55
import qualified Data.Map as M
55 56
import qualified Data.Set as S
56 57
import qualified Text.JSON as J
......
241 242
getInstPrimaryNode cfg name =
242 243
  liftM instPrimaryNode (getInstance cfg name) >>= getNode cfg
243 244

  
245
-- | Retrieves all nodes hosting a DRBD disk
246
getDrbdDiskNodes :: ConfigData -> Disk -> [Node]
247
getDrbdDiskNodes cfg disk =
248
  let retrieved = case diskLogicalId disk of
249
                    LIDDrbd8 nodeA nodeB _ _ _ _ ->
250
                      justOk [getNode cfg nodeA, getNode cfg nodeB]
251
                    _                            -> []
252
  in retrieved ++ concatMap (getDrbdDiskNodes cfg) (diskChildren disk)
253

  
254
-- | Retrieves all the nodes of the instance.
255
--
256
-- As instances not using DRBD can be sent as a parameter as well,
257
-- the primary node has to be appended to the results.
258
getInstAllNodes :: ConfigData -> String -> ErrorResult [Node]
259
getInstAllNodes cfg name = do
260
  inst <- getInstance cfg name
261
  let diskNodes = concatMap (getDrbdDiskNodes cfg) $ instDisks inst
262
  pNode <- getInstPrimaryNode cfg name
263
  return . nub $ pNode:diskNodes
264

  
244 265
-- | Filters DRBD minors for a given node.
245 266
getDrbdMinorsForNode :: String -> Disk -> [(Int, String)]
246 267
getDrbdMinorsForNode node disk =

Also available in: Unified diff