+-- | Sets the max disk usage ratio
+setMdsk :: Node -> Double -> Node
+setMdsk t val = t { m_dsk = val }
+
+-- | Sets the max cpu usage ratio
+setMcpu :: Node -> Double -> Node
+setMcpu t val = t { m_cpu = val }
+
+-- | Computes the maximum reserved memory for peers from a peer map.
+computeMaxRes :: PeerMap.PeerMap -> PeerMap.Elem
+computeMaxRes new_peers = PeerMap.maxElem new_peers
+
+-- | Builds the peer map for a given node.
+buildPeers :: Node -> Instance.List -> Node
+buildPeers t il =
+ let mdata = map
+ (\i_idx -> let inst = Container.find i_idx il
+ in (Instance.pnode inst, Instance.mem inst))
+ (slist t)
+ pmap = PeerMap.accumArray (+) mdata
+ new_rmem = computeMaxRes pmap
+ new_failN1 = computeFailN1 new_rmem (f_mem t) (f_dsk t)
+ new_prem = (fromIntegral new_rmem) / (t_mem t)
+ in t {peers=pmap, failN1 = new_failN1, r_mem = new_rmem, p_rem = new_prem}
+
+-- | Assigns an instance to a node as primary without other updates.
+setPri :: Node -> T.Idx -> Node
+setPri t idx = t { plist = idx:(plist t) }
+
+-- | Assigns an instance to a node as secondary without other updates.
+setSec :: Node -> T.Idx -> Node
+setSec t idx = t { slist = idx:(slist t) }
+
+-- | Add primary cpus to a node
+addCpus :: Node -> Int -> Node
+addCpus t count =
+ let new_count = (u_cpu t) + count
+ in t { u_cpu = new_count, p_cpu = (fromIntegral new_count) / (t_cpu t) }
+
+-- * Update functions
+
+-- | Sets the free memory.