Revision 4cd428db

b/htools/Ganeti/Config.hs
31 31
    , getInstancesIpByLink
32 32
    , getNode
33 33
    , getInstance
34
    , getGroup
34 35
    , getInstPrimaryNode
35 36
    , getInstMinorsForNode
36 37
    , buildLinkIpInstnameMap
......
132 133
getInstance cfg name =
133 134
  getItem "Instance" name (fromContainer $ configInstances cfg)
134 135

  
136
-- | Looks up a node group. This is more tricky than for
137
-- node/instances since the groups map is indexed by uuid, not name.
138
getGroup :: ConfigData -> String -> Result NodeGroup
139
getGroup cfg name =
140
  let groups = fromContainer (configNodegroups cfg)
141
  in case getItem "NodeGroup" name groups of
142
       -- if not found by uuid, we need to look it up by name, slow
143
       Ok grp -> Ok grp
144
       Bad _ -> let by_name = M.mapKeys
145
                              (\k -> groupName ((M.!) groups k )) groups
146
                in getItem "NodeGroup" name by_name
147

  
135 148
-- | Looks up an instance's primary node.
136 149
getInstPrimaryNode :: ConfigData -> String -> Result Node
137 150
getInstPrimaryNode cfg name =

Also available in: Unified diff