The information about which node is the master node is a cluster-wide
setting, in most formats provided independently of the node information.
Most backends therefore have to set the isMaster bit indepently in the
obtained node list. This patch provides a utility function for this.
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
( mergeData
, checkData
, assignIndices
+ , setMaster
, lookupNode
, lookupInstance
, lookupGroup
. zip [0..] $ name_element
in (M.fromList name_idx, Container.fromList idx_element)
+-- | Given am indexed node list, and the name of the master, mark it as such.
+setMaster :: (Monad m) => NameAssoc -> Node.List -> String -> m Node.List
+setMaster node_names node_idx master = do
+ kmaster <- maybe (fail $ "Master node " ++ master ++ " unknown") return $
+ M.lookup master node_names
+ let mnode = Container.find kmaster node_idx
+ return $ Container.add kmaster (Node.setMaster mnode True) node_idx
+
-- | For each instance, add its index to its primary and secondary nodes.
fixNodes :: Node.List
-> Instance.Instance