Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / HTools / Text.hs @ e8fa4ff6

History | View | Annotate | Download (12.1 kB)

1 525bfb36 Iustin Pop
{-| Parsing data from text-files.
2 040afc35 Iustin Pop
3 040afc35 Iustin Pop
This module holds the code for loading the cluster state from text
4 525bfb36 Iustin Pop
files, as produced by @gnt-node@ and @gnt-instance@ @list@ command.
5 040afc35 Iustin Pop
6 040afc35 Iustin Pop
-}
7 040afc35 Iustin Pop
8 e2fa2baf Iustin Pop
{-
9 e2fa2baf Iustin Pop
10 b37f4a76 Iustin Pop
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
11 e2fa2baf Iustin Pop
12 e2fa2baf Iustin Pop
This program is free software; you can redistribute it and/or modify
13 e2fa2baf Iustin Pop
it under the terms of the GNU General Public License as published by
14 e2fa2baf Iustin Pop
the Free Software Foundation; either version 2 of the License, or
15 e2fa2baf Iustin Pop
(at your option) any later version.
16 e2fa2baf Iustin Pop
17 e2fa2baf Iustin Pop
This program is distributed in the hope that it will be useful, but
18 e2fa2baf Iustin Pop
WITHOUT ANY WARRANTY; without even the implied warranty of
19 e2fa2baf Iustin Pop
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 e2fa2baf Iustin Pop
General Public License for more details.
21 e2fa2baf Iustin Pop
22 e2fa2baf Iustin Pop
You should have received a copy of the GNU General Public License
23 e2fa2baf Iustin Pop
along with this program; if not, write to the Free Software
24 e2fa2baf Iustin Pop
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 e2fa2baf Iustin Pop
02110-1301, USA.
26 e2fa2baf Iustin Pop
27 e2fa2baf Iustin Pop
-}
28 e2fa2baf Iustin Pop
29 040afc35 Iustin Pop
module Ganeti.HTools.Text
30 ebf38064 Iustin Pop
  ( loadData
31 ebf38064 Iustin Pop
  , parseData
32 ebf38064 Iustin Pop
  , loadInst
33 ebf38064 Iustin Pop
  , loadNode
34 bcd17bf0 Iustin Pop
  , loadISpec
35 bcd17bf0 Iustin Pop
  , loadIPolicy
36 ebf38064 Iustin Pop
  , serializeInstances
37 ebf38064 Iustin Pop
  , serializeNode
38 ebf38064 Iustin Pop
  , serializeNodes
39 bcd17bf0 Iustin Pop
  , serializeGroup
40 bcd17bf0 Iustin Pop
  , serializeISpec
41 bcd17bf0 Iustin Pop
  , serializeIPolicy
42 ebf38064 Iustin Pop
  , serializeCluster
43 ebf38064 Iustin Pop
  ) where
44 040afc35 Iustin Pop
45 040afc35 Iustin Pop
import Control.Monad
46 3bf75b7d Iustin Pop
import Data.List
47 3bf75b7d Iustin Pop
48 3bf75b7d Iustin Pop
import Text.Printf (printf)
49 040afc35 Iustin Pop
50 040afc35 Iustin Pop
import Ganeti.HTools.Utils
51 040afc35 Iustin Pop
import Ganeti.HTools.Loader
52 e4c5beaf Iustin Pop
import Ganeti.HTools.Types
53 3bf75b7d Iustin Pop
import qualified Ganeti.HTools.Container as Container
54 a679e9dc Iustin Pop
import qualified Ganeti.HTools.Group as Group
55 040afc35 Iustin Pop
import qualified Ganeti.HTools.Node as Node
56 040afc35 Iustin Pop
import qualified Ganeti.HTools.Instance as Instance
57 040afc35 Iustin Pop
58 b37f4a76 Iustin Pop
-- * Helper functions
59 b37f4a76 Iustin Pop
60 b37f4a76 Iustin Pop
-- | Simple wrapper over sepSplit
61 b37f4a76 Iustin Pop
commaSplit :: String -> [String]
62 b37f4a76 Iustin Pop
commaSplit = sepSplit ','
63 b37f4a76 Iustin Pop
64 525bfb36 Iustin Pop
-- * Serialisation functions
65 525bfb36 Iustin Pop
66 525bfb36 Iustin Pop
-- | Serialize a single group.
67 e4d8071d Iustin Pop
serializeGroup :: Group.Group -> String
68 e4d8071d Iustin Pop
serializeGroup grp =
69 ebf38064 Iustin Pop
  printf "%s|%s|%s" (Group.name grp) (Group.uuid grp)
70 ebf38064 Iustin Pop
           (allocPolicyToRaw (Group.allocPolicy grp))
71 e4d8071d Iustin Pop
72 525bfb36 Iustin Pop
-- | Generate group file data from a group list.
73 e4d8071d Iustin Pop
serializeGroups :: Group.List -> String
74 e4d8071d Iustin Pop
serializeGroups = unlines . map serializeGroup . Container.elems
75 e4d8071d Iustin Pop
76 525bfb36 Iustin Pop
-- | Serialize a single node.
77 525bfb36 Iustin Pop
serializeNode :: Group.List -- ^ The list of groups (needed for group uuid)
78 525bfb36 Iustin Pop
              -> Node.Node  -- ^ The node to be serialised
79 525bfb36 Iustin Pop
              -> String
80 10ef6b4e Iustin Pop
serializeNode gl node =
81 ebf38064 Iustin Pop
  printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s" (Node.name node)
82 ebf38064 Iustin Pop
           (Node.tMem node) (Node.nMem node) (Node.fMem node)
83 ebf38064 Iustin Pop
           (Node.tDsk node) (Node.fDsk node) (Node.tCpu node)
84 ebf38064 Iustin Pop
           (if Node.offline node then 'Y' else 'N')
85 ebf38064 Iustin Pop
           (Group.uuid grp)
86 10ef6b4e Iustin Pop
    where grp = Container.find (Node.group node) gl
87 3bf75b7d Iustin Pop
88 525bfb36 Iustin Pop
-- | Generate node file data from node objects.
89 10ef6b4e Iustin Pop
serializeNodes :: Group.List -> Node.List -> String
90 10ef6b4e Iustin Pop
serializeNodes gl = unlines . map (serializeNode gl) . Container.elems
91 3bf75b7d Iustin Pop
92 525bfb36 Iustin Pop
-- | Serialize a single instance.
93 525bfb36 Iustin Pop
serializeInstance :: Node.List         -- ^ The node list (needed for
94 525bfb36 Iustin Pop
                                       -- node names)
95 525bfb36 Iustin Pop
                  -> Instance.Instance -- ^ The instance to be serialised
96 525bfb36 Iustin Pop
                  -> String
97 3bf75b7d Iustin Pop
serializeInstance nl inst =
98 ebf38064 Iustin Pop
  let iname = Instance.name inst
99 ebf38064 Iustin Pop
      pnode = Container.nameOf nl (Instance.pNode inst)
100 ebf38064 Iustin Pop
      sidx = Instance.sNode inst
101 ebf38064 Iustin Pop
      snode = (if sidx == Node.noSecondary
102 ebf38064 Iustin Pop
                 then ""
103 ebf38064 Iustin Pop
                 else Container.nameOf nl sidx)
104 ebf38064 Iustin Pop
  in printf "%s|%d|%d|%d|%s|%s|%s|%s|%s|%s"
105 ebf38064 Iustin Pop
       iname (Instance.mem inst) (Instance.dsk inst)
106 ebf38064 Iustin Pop
       (Instance.vcpus inst) (instanceStatusToRaw (Instance.runSt inst))
107 ebf38064 Iustin Pop
       (if Instance.autoBalance inst then "Y" else "N")
108 ebf38064 Iustin Pop
       pnode snode (diskTemplateToRaw (Instance.diskTemplate inst))
109 ebf38064 Iustin Pop
       (intercalate "," (Instance.tags inst))
110 3bf75b7d Iustin Pop
111 525bfb36 Iustin Pop
-- | Generate instance file data from instance objects.
112 3bf75b7d Iustin Pop
serializeInstances :: Node.List -> Instance.List -> String
113 3bf75b7d Iustin Pop
serializeInstances nl =
114 ebf38064 Iustin Pop
  unlines . map (serializeInstance nl) . Container.elems
115 3bf75b7d Iustin Pop
116 b37f4a76 Iustin Pop
-- | Generate a spec data from a given ISpec object.
117 b37f4a76 Iustin Pop
serializeISpec :: ISpec -> String
118 b37f4a76 Iustin Pop
serializeISpec ispec =
119 b37f4a76 Iustin Pop
  -- this needs to be kept in sync with the object definition
120 b37f4a76 Iustin Pop
  let ISpec mem_s cpu_c disk_s disk_c nic_c = ispec
121 b37f4a76 Iustin Pop
      strings = [show mem_s, show cpu_c, show disk_s, show disk_c, show nic_c]
122 b37f4a76 Iustin Pop
  in intercalate "," strings
123 b37f4a76 Iustin Pop
124 b37f4a76 Iustin Pop
-- | Generate disk template data.
125 b37f4a76 Iustin Pop
serializeDiskTemplates :: [DiskTemplate] -> String
126 b37f4a76 Iustin Pop
serializeDiskTemplates = intercalate "," . map diskTemplateToRaw
127 b37f4a76 Iustin Pop
128 b37f4a76 Iustin Pop
-- | Generate policy data from a given policy object.
129 b37f4a76 Iustin Pop
serializeIPolicy :: String -> IPolicy -> String
130 b37f4a76 Iustin Pop
serializeIPolicy owner ipol =
131 e8fa4ff6 Iustin Pop
  let IPolicy stdspec minspec maxspec dts vcpu_ratio = ipol
132 b37f4a76 Iustin Pop
      strings = [ owner
133 b37f4a76 Iustin Pop
                , serializeISpec stdspec
134 b37f4a76 Iustin Pop
                , serializeISpec minspec
135 b37f4a76 Iustin Pop
                , serializeISpec maxspec
136 b37f4a76 Iustin Pop
                , serializeDiskTemplates dts
137 e8fa4ff6 Iustin Pop
                , show vcpu_ratio
138 b37f4a76 Iustin Pop
                ]
139 b37f4a76 Iustin Pop
  in intercalate "|" strings
140 b37f4a76 Iustin Pop
141 b37f4a76 Iustin Pop
-- | Generates the entire ipolicy section from the cluster and group
142 b37f4a76 Iustin Pop
-- objects.
143 b37f4a76 Iustin Pop
serializeAllIPolicies :: IPolicy -> Group.List -> String
144 b37f4a76 Iustin Pop
serializeAllIPolicies cpol gl =
145 b37f4a76 Iustin Pop
  let groups = Container.elems gl
146 b37f4a76 Iustin Pop
      allpolicies = [("", cpol)] ++
147 b37f4a76 Iustin Pop
                    map (\g -> (Group.name g, Group.iPolicy g)) groups
148 b37f4a76 Iustin Pop
      strings = map (uncurry serializeIPolicy) allpolicies
149 b37f4a76 Iustin Pop
  in unlines strings
150 b37f4a76 Iustin Pop
151 525bfb36 Iustin Pop
-- | Generate complete cluster data from node and instance lists.
152 c0e31451 Iustin Pop
serializeCluster :: ClusterData -> String
153 b37f4a76 Iustin Pop
serializeCluster (ClusterData gl nl il ctags cpol) =
154 e4d8071d Iustin Pop
  let gdata = serializeGroups gl
155 e4d8071d Iustin Pop
      ndata = serializeNodes gl nl
156 4a273e97 Iustin Pop
      idata = serializeInstances nl il
157 b37f4a76 Iustin Pop
      pdata = serializeAllIPolicies cpol gl
158 716c6be5 Iustin Pop
  -- note: not using 'unlines' as that adds too many newlines
159 b37f4a76 Iustin Pop
  in intercalate "\n" [gdata, ndata, idata, unlines ctags, pdata]
160 4a273e97 Iustin Pop
161 525bfb36 Iustin Pop
-- * Parsing functions
162 525bfb36 Iustin Pop
163 a679e9dc Iustin Pop
-- | Load a group from a field list.
164 525bfb36 Iustin Pop
loadGroup :: (Monad m) => [String]
165 525bfb36 Iustin Pop
          -> m (String, Group.Group) -- ^ The result, a tuple of group
166 525bfb36 Iustin Pop
                                     -- UUID and group object
167 f4c7d37a Iustin Pop
loadGroup [name, gid, apol] = do
168 5f828ce4 Agata Murawska
  xapol <- allocPolicyFromRaw apol
169 6cff91f5 Iustin Pop
  return (gid, Group.create name gid xapol defIPolicy)
170 a679e9dc Iustin Pop
171 a679e9dc Iustin Pop
loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'"
172 a679e9dc Iustin Pop
173 9188aeef Iustin Pop
-- | Load a node from a field list.
174 525bfb36 Iustin Pop
loadNode :: (Monad m) =>
175 525bfb36 Iustin Pop
            NameAssoc             -- ^ Association list with current groups
176 525bfb36 Iustin Pop
         -> [String]              -- ^ Input data as a list of fields
177 525bfb36 Iustin Pop
         -> m (String, Node.Node) -- ^ The result, a tuple o node name
178 525bfb36 Iustin Pop
                                  -- and node object
179 10ef6b4e Iustin Pop
loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] = do
180 10ef6b4e Iustin Pop
  gdx <- lookupGroup ktg name gu
181 040afc35 Iustin Pop
  new_node <-
182 1a82215d Iustin Pop
      if any (== "?") [tm,nm,fm,td,fd,tc] || fo == "Y" then
183 10ef6b4e Iustin Pop
          return $ Node.create name 0 0 0 0 0 0 True gdx
184 040afc35 Iustin Pop
      else do
185 040afc35 Iustin Pop
        vtm <- tryRead name tm
186 040afc35 Iustin Pop
        vnm <- tryRead name nm
187 040afc35 Iustin Pop
        vfm <- tryRead name fm
188 040afc35 Iustin Pop
        vtd <- tryRead name td
189 040afc35 Iustin Pop
        vfd <- tryRead name fd
190 1a82215d Iustin Pop
        vtc <- tryRead name tc
191 10ef6b4e Iustin Pop
        return $ Node.create name vtm vnm vfm vtd vfd vtc False gdx
192 040afc35 Iustin Pop
  return (name, new_node)
193 10ef6b4e Iustin Pop
loadNode _ s = fail $ "Invalid/incomplete node data: '" ++ show s ++ "'"
194 040afc35 Iustin Pop
195 9188aeef Iustin Pop
-- | Load an instance from a field list.
196 6429e8d8 Iustin Pop
loadInst :: NameAssoc -- ^ Association list with the current nodes
197 6429e8d8 Iustin Pop
         -> [String]  -- ^ Input data as a list of fields
198 6429e8d8 Iustin Pop
         -> Result (String, Instance.Instance) -- ^ A tuple of
199 6429e8d8 Iustin Pop
                                               -- instance name and
200 6429e8d8 Iustin Pop
                                               -- the instance object
201 6429e8d8 Iustin Pop
loadInst ktn [ name, mem, dsk, vcpus, status, auto_bal, pnode, snode
202 6429e8d8 Iustin Pop
             , dt, tags ] = do
203 040afc35 Iustin Pop
  pidx <- lookupNode ktn name pnode
204 3603605a Iustin Pop
  sidx <- if null snode
205 3603605a Iustin Pop
            then return Node.noSecondary
206 3603605a Iustin Pop
            else lookupNode ktn name snode
207 040afc35 Iustin Pop
  vmem <- tryRead name mem
208 040afc35 Iustin Pop
  vdsk <- tryRead name dsk
209 d752eb39 Iustin Pop
  vvcpus <- tryRead name vcpus
210 7dd14211 Agata Murawska
  vstatus <- instanceStatusFromRaw status
211 bc782180 Iustin Pop
  auto_balance <- case auto_bal of
212 bc782180 Iustin Pop
                    "Y" -> return True
213 bc782180 Iustin Pop
                    "N" -> return False
214 bc782180 Iustin Pop
                    _ -> fail $ "Invalid auto_balance value '" ++ auto_bal ++
215 bc782180 Iustin Pop
                         "' for instance " ++ name
216 2c9336a4 Iustin Pop
  disk_template <- annotateResult ("Instance " ++ name)
217 5f828ce4 Agata Murawska
                   (diskTemplateFromRaw dt)
218 040afc35 Iustin Pop
  when (sidx == pidx) $ fail $ "Instance " ++ name ++
219 040afc35 Iustin Pop
           " has same primary and secondary node - " ++ pnode
220 b37f4a76 Iustin Pop
  let vtags = commaSplit tags
221 7dd14211 Agata Murawska
      newinst = Instance.create name vmem vdsk vvcpus vstatus vtags
222 6429e8d8 Iustin Pop
                auto_balance pidx sidx disk_template
223 040afc35 Iustin Pop
  return (name, newinst)
224 9f6dcdea Iustin Pop
loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'"
225 040afc35 Iustin Pop
226 b37f4a76 Iustin Pop
-- | Loads a spec from a field list.
227 b37f4a76 Iustin Pop
loadISpec :: String -> [String] -> Result ISpec
228 b37f4a76 Iustin Pop
loadISpec owner [mem_s, cpu_c, dsk_s, dsk_c, nic_c] = do
229 b37f4a76 Iustin Pop
  xmem_s <- tryRead (owner ++ "/memsize") mem_s
230 b37f4a76 Iustin Pop
  xcpu_c <- tryRead (owner ++ "/cpucount") cpu_c
231 b37f4a76 Iustin Pop
  xdsk_s <- tryRead (owner ++ "/disksize") dsk_s
232 b37f4a76 Iustin Pop
  xdsk_c <- tryRead (owner ++ "/diskcount") dsk_c
233 b37f4a76 Iustin Pop
  xnic_c <- tryRead (owner ++ "/niccount") nic_c
234 b37f4a76 Iustin Pop
  return $ ISpec xmem_s xcpu_c xdsk_s xdsk_c xnic_c
235 b37f4a76 Iustin Pop
loadISpec owner s = fail $ "Invalid ispec data for " ++ owner ++ ": " ++ show s
236 b37f4a76 Iustin Pop
237 b37f4a76 Iustin Pop
-- | Loads an ipolicy from a field list.
238 b37f4a76 Iustin Pop
loadIPolicy :: [String] -> Result (String, IPolicy)
239 e8fa4ff6 Iustin Pop
loadIPolicy [owner, stdspec, minspec, maxspec, dtemplates, vcpu_ratio] = do
240 b37f4a76 Iustin Pop
  xstdspec <- loadISpec (owner ++ "/stdspec") (commaSplit stdspec)
241 b37f4a76 Iustin Pop
  xminspec <- loadISpec (owner ++ "/minspec") (commaSplit minspec)
242 b37f4a76 Iustin Pop
  xmaxspec <- loadISpec (owner ++ "/maxspec") (commaSplit maxspec)
243 b37f4a76 Iustin Pop
  xdts <- mapM diskTemplateFromRaw $ commaSplit dtemplates
244 e8fa4ff6 Iustin Pop
  xvcpu_ratio <- tryRead (owner ++ "/vcpu_ratio") vcpu_ratio
245 e8fa4ff6 Iustin Pop
  return $ (owner, IPolicy xstdspec xminspec xmaxspec xdts xvcpu_ratio)
246 b37f4a76 Iustin Pop
loadIPolicy s = fail $ "Invalid ipolicy data: '" ++ show s ++ "'"
247 b37f4a76 Iustin Pop
248 b37f4a76 Iustin Pop
loadOnePolicy :: (IPolicy, Group.List) -> String
249 b37f4a76 Iustin Pop
              -> Result (IPolicy, Group.List)
250 b37f4a76 Iustin Pop
loadOnePolicy (cpol, gl) line = do
251 b37f4a76 Iustin Pop
  (owner, ipol) <- loadIPolicy (sepSplit '|' line)
252 b37f4a76 Iustin Pop
  case owner of
253 b37f4a76 Iustin Pop
    "" -> return (ipol, gl) -- this is a cluster policy (no owner)
254 b37f4a76 Iustin Pop
    _ -> do
255 b37f4a76 Iustin Pop
      grp <- Container.findByName gl owner
256 b37f4a76 Iustin Pop
      let grp' = grp { Group.iPolicy = ipol }
257 b37f4a76 Iustin Pop
          gl' = Container.add (Group.idx grp') grp' gl
258 b37f4a76 Iustin Pop
      return (cpol, gl')
259 b37f4a76 Iustin Pop
260 b37f4a76 Iustin Pop
-- | Loads all policies from the policy section
261 b37f4a76 Iustin Pop
loadAllIPolicies :: Group.List -> [String] -> Result (IPolicy, Group.List)
262 b37f4a76 Iustin Pop
loadAllIPolicies gl =
263 b37f4a76 Iustin Pop
  foldM loadOnePolicy (defIPolicy, gl)
264 b37f4a76 Iustin Pop
265 9188aeef Iustin Pop
-- | Convert newline and delimiter-separated text.
266 9188aeef Iustin Pop
--
267 9188aeef Iustin Pop
-- This function converts a text in tabular format as generated by
268 9188aeef Iustin Pop
-- @gnt-instance list@ and @gnt-node list@ to a list of objects using
269 9188aeef Iustin Pop
-- a supplied conversion function.
270 497e30a1 Iustin Pop
loadTabular :: (Monad m, Element a) =>
271 525bfb36 Iustin Pop
               [String] -- ^ Input data, as a list of lines
272 525bfb36 Iustin Pop
            -> ([String] -> m (String, a)) -- ^ Conversion function
273 525bfb36 Iustin Pop
            -> m ( NameAssoc
274 525bfb36 Iustin Pop
                 , Container.Container a ) -- ^ A tuple of an
275 525bfb36 Iustin Pop
                                           -- association list (name
276 525bfb36 Iustin Pop
                                           -- to object) and a set as
277 525bfb36 Iustin Pop
                                           -- used in
278 525bfb36 Iustin Pop
                                           -- "Ganeti.HTools.Container"
279 525bfb36 Iustin Pop
280 f5197d89 Iustin Pop
loadTabular lines_data convert_fn = do
281 f5197d89 Iustin Pop
  let rows = map (sepSplit '|') lines_data
282 040afc35 Iustin Pop
  kerows <- mapM convert_fn rows
283 497e30a1 Iustin Pop
  return $ assignIndices kerows
284 040afc35 Iustin Pop
285 dadfc261 Iustin Pop
-- | Load the cluser data from disk.
286 525bfb36 Iustin Pop
--
287 525bfb36 Iustin Pop
-- This is an alias to 'readFile' just for consistency with the other
288 525bfb36 Iustin Pop
-- modules.
289 525bfb36 Iustin Pop
readData :: String    -- ^ Path to the text file
290 525bfb36 Iustin Pop
         -> IO String -- ^ Contents of the file
291 dadfc261 Iustin Pop
readData = readFile
292 dadfc261 Iustin Pop
293 16c2369c Iustin Pop
-- | Builds the cluster data from text input.
294 dadfc261 Iustin Pop
parseData :: String -- ^ Text data
295 f4f6eb0b Iustin Pop
          -> Result ClusterData
296 dadfc261 Iustin Pop
parseData fdata = do
297 16c2369c Iustin Pop
  let flines = lines fdata
298 b37f4a76 Iustin Pop
  (glines, nlines, ilines, ctags, pollines) <-
299 a604456d Iustin Pop
      case sepSplit "" flines of
300 b37f4a76 Iustin Pop
        [a, b, c, d, e] -> Ok (a, b, c, d, e)
301 b37f4a76 Iustin Pop
        [a, b, c, d] -> Ok (a, b, c, d, [])
302 a604456d Iustin Pop
        xs -> Bad $ printf "Invalid format of the input file: %d sections\
303 b37f4a76 Iustin Pop
                           \ instead of 4 or 5" (length xs)
304 a679e9dc Iustin Pop
  {- group file: name uuid -}
305 10ef6b4e Iustin Pop
  (ktg, gl) <- loadTabular glines loadGroup
306 dadfc261 Iustin Pop
  {- node file: name t_mem n_mem f_mem t_disk f_disk -}
307 a604456d Iustin Pop
  (ktn, nl) <- loadTabular nlines (loadNode ktg)
308 dadfc261 Iustin Pop
  {- instance file: name mem disk status pnode snode -}
309 a604456d Iustin Pop
  (_, il) <- loadTabular ilines (loadInst ktn)
310 afcd5a0b Iustin Pop
  {- the tags are simply line-based, no processing needed -}
311 b37f4a76 Iustin Pop
  {- process policies -}
312 b37f4a76 Iustin Pop
  (cpol, gl') <- loadAllIPolicies gl pollines
313 b37f4a76 Iustin Pop
  return (ClusterData gl' nl il ctags cpol)
314 dadfc261 Iustin Pop
315 525bfb36 Iustin Pop
-- | Top level function for data loading.
316 dadfc261 Iustin Pop
loadData :: String -- ^ Path to the text file
317 f4f6eb0b Iustin Pop
         -> IO (Result ClusterData)
318 2a8e2dc9 Iustin Pop
loadData = fmap parseData . readData