Node.create (read tm) (read nm)
(read fm) (read td) (read fd)))
Node.setIdx
- {- instance file: name mem disk pnode snode -}
+ {- instance file: name mem disk status pnode snode -}
(kti, il) = loadTabular idata
- (\ (name:mem:dsk:pnode:snode:[]) ->
+ (\ (name:mem:dsk:status:pnode:snode:[]) ->
(name,
Instance.create (read mem) (read dsk)
+ status
(fromJust $ lookup pnode ktn)
(fromJust $ lookup snode ktn)))
Instance.setIdx
-}
module Ganeti.HTools.Instance where
-data Instance = Instance { mem :: Int -- ^ memory of the instance
- , dsk :: Int -- ^ disk size of instance
- , pnode :: Int -- ^ original primary node
- , snode :: Int -- ^ original secondary node
- , idx :: Int -- ^ internal index for book-keeping
+data Instance = Instance { mem :: Int -- ^ memory of the instance
+ , dsk :: Int -- ^ disk size of instance
+ , running :: Bool -- ^ whether the instance
+ -- is running
+ , run_st :: String -- ^ original (text) run status
+ , pnode :: Int -- ^ original primary node
+ , snode :: Int -- ^ original secondary node
+ , idx :: Int -- ^ internal index for
+ -- book-keeping
} deriving (Show)
-create :: Int -> Int -> Int -> Int -> Instance
-create mem_init dsk_init pn sn =
+create :: Int -> Int -> String -> Int -> Int -> Instance
+create mem_init dsk_init run_init pn sn =
Instance {
mem = mem_init,
dsk = dsk_init,
+ running = case run_init of
+ "running" -> True
+ "ERROR_up" -> True
+ _ -> False,
+ run_st = run_init,
pnode = pn,
snode = sn,
idx = -1
mem = case bep of
Left _ -> getIntElement "admin_ram" a
Right o -> getIntElement "memory" o
+ running = getStringElement "status" a
in
concatElems name $
concatElems (show `apply1` mem) $
concatElems (show `apply1` disk) $
+ concatElems running $
concatElems pnode snode
parseNode :: JSObject JSValue -> Either String String
pnode = fromJust $ lookup (Instance.pnode inst) etn
snode = fromJust $ lookup (Instance.snode inst) etn
in
- printf "%s|%d|%d|%s|%s"
+ printf "%s|%d|%d|%s|%s|%s"
iname (Instance.mem inst) (Instance.dsk inst)
+ (Instance.run_st inst)
pnode snode
)
instances