Revision 28f19313 htools/Ganeti/HTools/IAlloc.hs

b/htools/Ganeti/HTools/IAlloc.hs
49 49
-- 'Allocate' request share some common properties, which are read by
50 50
-- this function.
51 51
parseBaseInstance :: String
52
                  -> [(String, JSValue)]
52
                  -> JSRecord
53 53
                  -> Result (String, Instance.Instance)
54 54
parseBaseInstance n a = do
55 55
  let extract x = tryFromObj ("invalid data for instance '" ++ n ++ "'") a x
......
61 61
  return (n, Instance.create n mem disk vcpus running tags True 0 0)
62 62

  
63 63
-- | Parses an instance as found in the cluster instance listg.
64
parseInstance :: NameAssoc        -- ^ The node name-to-index association list
65
              -> String           -- ^ The name of the instance
66
              -> [(String, JSValue)] -- ^ The JSON object
64
parseInstance :: NameAssoc -- ^ The node name-to-index association list
65
              -> String    -- ^ The name of the instance
66
              -> JSRecord  -- ^ The JSON object
67 67
              -> Result (String, Instance.Instance)
68 68
parseInstance ktn n a = do
69 69
  base <- parseBaseInstance n a
......
78 78
  return (n, Instance.setBoth (snd base) pidx sidx)
79 79

  
80 80
-- | Parses a node as found in the cluster node list.
81
parseNode :: NameAssoc           -- ^ The group association
82
          -> String              -- ^ The node's name
83
          -> [(String, JSValue)] -- ^ The JSON object
81
parseNode :: NameAssoc   -- ^ The group association
82
          -> String      -- ^ The node's name
83
          -> JSRecord    -- ^ The JSON object
84 84
          -> Result (String, Node.Node)
85 85
parseNode ktg n a = do
86 86
  let desc = "invalid data for node '" ++ n ++ "'"
......
105 105
  return (n, node)
106 106

  
107 107
-- | Parses a group as found in the cluster group list.
108
parseGroup :: String              -- ^ The group UUID
109
           -> [(String, JSValue)] -- ^ The JSON object
108
parseGroup :: String     -- ^ The group UUID
109
           -> JSRecord   -- ^ The JSON object
110 110
           -> Result (String, Group.Group)
111 111
parseGroup u a = do
112 112
  let extract x = tryFromObj ("invalid data for group '" ++ u ++ "'") a x
......
114 114
  apol <- extract "alloc_policy"
115 115
  return (u, Group.create name u apol)
116 116

  
117
parseTargetGroups :: [(String, JSValue)] -- ^ The JSON object (request dict)
118
                  -> Group.List          -- ^ The existing groups
117
parseTargetGroups :: JSRecord      -- ^ The JSON object (request dict)
118
                  -> Group.List    -- ^ The existing groups
119 119
                  -> Result [Gdx]
120 120
parseTargetGroups req map_g = do
121 121
  group_uuids <- fromObjWithDefault req "target_groups" []

Also available in: Unified diff