+loadNode :: (Monad m) => [String] -> m (String, Node.Node)
+loadNode (name:tm:nm:fm:td:fd:fo:[]) = do
+ let new_node =
+ if any (== "?") [tm,nm,fm,td,fd] || fo == "Y" then
+ Node.create 0 0 0 0 0 True
+ else
+ Node.create (read tm) (read nm) (read fm)
+ (read td) (read fd) False
+ return (name, new_node)
+loadNode s = fail $ "Invalid/incomplete node data: '" ++ (show s) ++ "'"
+
+loadInst :: (Monad m) =>
+ [(String, Int)] -> [String] -> m (String, Instance.Instance)
+loadInst ktn (name:mem:dsk:status:pnode:snode:[]) = do
+ pidx <- lookupNode pnode name ktn
+ sidx <- lookupNode snode name ktn
+ when (sidx == pidx) $ fail $ "Instance " ++ name ++
+ " has same primary and secondary node - " ++ pnode
+ let newinst = Instance.create (read mem) (read dsk) status pidx sidx
+ return (name, newinst)
+loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ (show s) ++ "'"
+