Fix a few style issue in hcheck
[ganeti-local] / htools / Ganeti / HTools / Text.hs
index fc943e9..3b4bece 100644 (file)
@@ -102,12 +102,12 @@ serializeInstance nl inst =
       snode = (if sidx == Node.noSecondary
                  then ""
                  else Container.nameOf nl sidx)
-  in printf "%s|%d|%d|%d|%s|%s|%s|%s|%s|%s"
+  in printf "%s|%d|%d|%d|%s|%s|%s|%s|%s|%s|%d"
        iname (Instance.mem inst) (Instance.dsk inst)
        (Instance.vcpus inst) (instanceStatusToRaw (Instance.runSt inst))
        (if Instance.autoBalance inst then "Y" else "N")
        pnode snode (diskTemplateToRaw (Instance.diskTemplate inst))
-       (intercalate "," (Instance.tags inst))
+       (intercalate "," (Instance.tags inst)) (Instance.spindleUse inst)
 
 -- | Generate instance file data from instance objects.
 serializeInstances :: Node.List -> Instance.List -> String
@@ -118,8 +118,9 @@ serializeInstances nl =
 serializeISpec :: ISpec -> String
 serializeISpec ispec =
   -- this needs to be kept in sync with the object definition
-  let ISpec mem_s cpu_c disk_s disk_c nic_c = ispec
-      strings = [show mem_s, show cpu_c, show disk_s, show disk_c, show nic_c]
+  let ISpec mem_s cpu_c disk_s disk_c nic_c su = ispec
+      strings = [show mem_s, show cpu_c, show disk_s, show disk_c, show nic_c,
+                 show su]
   in intercalate "," strings
 
 -- | Generate disk template data.
@@ -206,7 +207,7 @@ loadInst :: NameAssoc -- ^ Association list with the current nodes
                                                -- instance name and
                                                -- the instance object
 loadInst ktn [ name, mem, dsk, vcpus, status, auto_bal, pnode, snode
-             , dt, tags ] = do
+             , dt, tags, su ] = do
   pidx <- lookupNode ktn name pnode
   sidx <- if null snode
             then return Node.noSecondary
@@ -222,23 +223,30 @@ loadInst ktn [ name, mem, dsk, vcpus, status, auto_bal, pnode, snode
                          "' for instance " ++ name
   disk_template <- annotateResult ("Instance " ++ name)
                    (diskTemplateFromRaw dt)
+  spindle_use <- tryRead name su
   when (sidx == pidx) $ fail $ "Instance " ++ name ++
            " has same primary and secondary node - " ++ pnode
   let vtags = commaSplit tags
       newinst = Instance.create name vmem vdsk vvcpus vstatus vtags
-                auto_balance pidx sidx disk_template 1
+                auto_balance pidx sidx disk_template spindle_use
   return (name, newinst)
+
+loadInst ktn [ name, mem, dsk, vcpus, status, auto_bal, pnode, snode
+             , dt, tags ] = loadInst ktn [ name, mem, dsk, vcpus, status,
+                                           auto_bal, pnode, snode, dt, tags,
+                                           "1" ]
 loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'"
 
 -- | Loads a spec from a field list.
 loadISpec :: String -> [String] -> Result ISpec
-loadISpec owner [mem_s, cpu_c, dsk_s, dsk_c, nic_c] = do
+loadISpec owner [mem_s, cpu_c, dsk_s, dsk_c, nic_c, su] = do
   xmem_s <- tryRead (owner ++ "/memsize") mem_s
   xcpu_c <- tryRead (owner ++ "/cpucount") cpu_c
   xdsk_s <- tryRead (owner ++ "/disksize") dsk_s
   xdsk_c <- tryRead (owner ++ "/diskcount") dsk_c
   xnic_c <- tryRead (owner ++ "/niccount") nic_c
-  return $ ISpec xmem_s xcpu_c xdsk_s xdsk_c xnic_c
+  xsu    <- tryRead (owner ++ "/spindleuse") su
+  return $ ISpec xmem_s xcpu_c xdsk_s xdsk_c xnic_c xsu
 loadISpec owner s = fail $ "Invalid ispec data for " ++ owner ++ ": " ++ show s
 
 -- | Loads an ipolicy from a field list.