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 = ...@@ -760,11 +760,12 @@ loadData ndata idata =
Node.create (read tm) (read nm) Node.create (read tm) (read nm)
(read fm) (read td) (read fd))) (read fm) (read td) (read fd)))
Node.setIdx Node.setIdx
{- instance file: name mem disk pnode snode -} {- instance file: name mem disk status pnode snode -}
(kti, il) = loadTabular idata (kti, il) = loadTabular idata
(\ (name:mem:dsk:pnode:snode:[]) -> (\ (name:mem:dsk:status:pnode:snode:[]) ->
(name, (name,
Instance.create (read mem) (read dsk) Instance.create (read mem) (read dsk)
status
(fromJust $ lookup pnode ktn) (fromJust $ lookup pnode ktn)
(fromJust $ lookup snode ktn))) (fromJust $ lookup snode ktn)))
Instance.setIdx Instance.setIdx
......
...@@ -6,18 +6,27 @@ intelligence is in the "Node" and "Cluster" modules. ...@@ -6,18 +6,27 @@ intelligence is in the "Node" and "Cluster" modules.
-} -}
module Ganeti.HTools.Instance where module Ganeti.HTools.Instance where
data Instance = Instance { mem :: Int -- ^ memory of the instance data Instance = Instance { mem :: Int -- ^ memory of the instance
, dsk :: Int -- ^ disk size of instance , dsk :: Int -- ^ disk size of instance
, pnode :: Int -- ^ original primary node , running :: Bool -- ^ whether the instance
, snode :: Int -- ^ original secondary node -- is running
, idx :: Int -- ^ internal index for book-keeping , 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) } deriving (Show)
create :: Int -> Int -> Int -> Int -> Instance create :: Int -> Int -> String -> Int -> Int -> Instance
create mem_init dsk_init pn sn = create mem_init dsk_init run_init pn sn =
Instance { Instance {
mem = mem_init, mem = mem_init,
dsk = dsk_init, dsk = dsk_init,
running = case run_init of
"running" -> True
"ERROR_up" -> True
_ -> False,
run_st = run_init,
pnode = pn, pnode = pn,
snode = sn, snode = sn,
idx = -1 idx = -1
......
...@@ -151,10 +151,12 @@ parseInstance a = ...@@ -151,10 +151,12 @@ parseInstance a =
mem = case bep of mem = case bep of
Left _ -> getIntElement "admin_ram" a Left _ -> getIntElement "admin_ram" a
Right o -> getIntElement "memory" o Right o -> getIntElement "memory" o
running = getStringElement "status" a
in in
concatElems name $ concatElems name $
concatElems (show `apply1` mem) $ concatElems (show `apply1` mem) $
concatElems (show `apply1` disk) $ concatElems (show `apply1` disk) $
concatElems running $
concatElems pnode snode concatElems pnode snode
parseNode :: JSObject JSValue -> Either String String parseNode :: JSObject JSValue -> Either String String
......
...@@ -99,8 +99,9 @@ serializeInstances il csf ktn kti = ...@@ -99,8 +99,9 @@ serializeInstances il csf ktn kti =
pnode = fromJust $ lookup (Instance.pnode inst) etn pnode = fromJust $ lookup (Instance.pnode inst) etn
snode = fromJust $ lookup (Instance.snode inst) etn snode = fromJust $ lookup (Instance.snode inst) etn
in in
printf "%s|%d|%d|%s|%s" printf "%s|%d|%d|%s|%s|%s"
iname (Instance.mem inst) (Instance.dsk inst) iname (Instance.mem inst) (Instance.dsk inst)
(Instance.run_st inst)
pnode snode pnode snode
) )
instances 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