Revision adb77e3a htools/Ganeti/Objects.hs

b/htools/Ganeti/Objects.hs
61 61
  , NodeGroup(..)
62 62
  , IpFamily(..)
63 63
  , ipFamilyToVersion
64
  , fillDict
64 65
  , Cluster(..)
65 66
  , ConfigData(..)
66 67
  ) where
67 68

  
69
import Data.List (foldl')
68 70
import Data.Maybe
71
import qualified Data.Map as Map
69 72
import Text.JSON (makeObj, showJSON, readJSON, JSON, JSValue(..))
70 73
import qualified Text.JSON as J
71 74

  
......
74 77

  
75 78
import Ganeti.THH
76 79

  
80
-- * Generic definitions
81

  
82
-- | Fills one map with keys from the other map, if not already
83
-- existing. Mirrors objects.py:FillDict.
84
fillDict :: (Ord k) => Map.Map k v -> Map.Map k v -> [k] -> Map.Map k v
85
fillDict defaults custom skip_keys =
86
  let updated = Map.union custom defaults
87
  in foldl' (flip Map.delete) updated skip_keys
88

  
77 89
-- * NIC definitions
78 90

  
79 91
$(declareSADT "NICMode"

Also available in: Unified diff