Commit f82f1f39 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a new instance field denoting run status

This patch modifies Rapi, the Cluster.loadData and hscan serialization to load
and save the instance run status. At instance level, we add both a boolean
field denoting the true/false run status, and a string field which holds the
original value (since we don't have a 1-to-1 mapping) for use in hscan
serialization.

The run status is not yet used.
parent a1c6212e
......@@ -760,11 +760,12 @@ loadData ndata idata =
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
......
......@@ -8,16 +8,25 @@ module Ganeti.HTools.Instance where
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
, 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
......
......@@ -151,10 +151,12 @@ parseInstance a =
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
......
......@@ -99,8 +99,9 @@ serializeInstances il csf ktn kti =
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment