Convert Cluster.loadData to Result return
[ganeti-local] / Ganeti / HTools / Cluster.hs
index e3753cc..73060a1 100644 (file)
@@ -203,7 +203,7 @@ those nodes.
 computeBadItems :: NodeList -> InstanceList ->
                    ([Node.Node], [Instance.Instance])
 computeBadItems nl il =
-  let bad_nodes = verifyN1 $ Container.elems nl
+  let bad_nodes = verifyN1 $ filter (not . Node.offline) $ Container.elems nl
       bad_instances = map (\idx -> Container.find idx il) $
                       sort $ nub $ concat $
                       map (\ n -> (Node.slist n) ++ (Node.plist n)) bad_nodes
@@ -746,9 +746,9 @@ stripSuffix suffix lst =
     and massages it into the correct format. -}
 loadData :: String -- ^ Node data in text format
          -> String -- ^ Instance data in text format
-         -> (Container.Container Node.Node,
-             Container.Container Instance.Instance,
-             String, NameList, NameList)
+         -> Result (Container.Container Node.Node,
+                    Container.Container Instance.Instance,
+                    String, NameList, NameList)
 loadData ndata idata =
     let
     {- node file: name t_mem n_mem f_mem t_disk f_disk -}
@@ -781,7 +781,7 @@ loadData ndata idata =
         stn = stripSuffix common_suffix xtn
         sti = stripSuffix common_suffix xti
     in
-      (nl3, il3, common_suffix, stn, sti)
+      Ok (nl3, il3, common_suffix, stn, sti)
 
 -- | Compute the amount of memory used by primary instances on a node.
 nodeImem :: Node.Node -> InstanceList -> Int