-}
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 { name :: String -- ^ the instance name
+ , 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 =
+-- | A simple name for the int, instance association list
+type AssocList = [(Int, Instance)]
+
+create :: String -> Int -> Int -> String -> Int -> Int -> Instance
+create name_init mem_init dsk_init run_init pn sn =
Instance {
+ name = name_init,
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
-> Int -- ^ new index
-> Instance -- ^ the modified instance
setIdx t i = t { idx = i }
+
+-- | Changes the name
+-- This is used only during the building of the data structures.
+setName t s = t {name = s}