1 {-| Module describing an instance.
3 The instance data type holds very few fields, the algorithm
4 intelligence is in the "Node" and "Cluster" modules.
7 module Ganeti.HTools.Instance where
9 data Instance = Instance { name :: String -- ^ the instance name
10 , mem :: Int -- ^ memory of the instance
11 , dsk :: Int -- ^ disk size of instance
12 , running :: Bool -- ^ whether the instance
14 , run_st :: String -- ^ original (text) run status
15 , pnode :: Int -- ^ original primary node
16 , snode :: Int -- ^ original secondary node
17 , idx :: Int -- ^ internal index for
21 -- | A simple name for the int, instance association list
22 type AssocList = [(Int, Instance)]
24 create :: String -> Int -> Int -> String -> Int -> Int -> Instance
25 create name_init mem_init dsk_init run_init pn sn =
30 running = case run_init of
40 -- | Changes the primary node of the instance.
41 setPri :: Instance -- ^ the original instance
42 -> Int -- ^ the new primary node
43 -> Instance -- ^ the modified instance
44 setPri t p = t { pnode = p }
46 -- | Changes the secondary node of the instance.
47 setSec :: Instance -- ^ the original instance
48 -> Int -- ^ the new secondary node
49 -> Instance -- ^ the modified instance
50 setSec t s = t { snode = s }
52 -- | Changes both nodes of the instance.
53 setBoth :: Instance -- ^ the original instance
54 -> Int -- ^ new primary node index
55 -> Int -- ^ new secondary node index
56 -> Instance -- ^ the modified instance
57 setBoth t p s = t { pnode = p, snode = s }
59 -- | Changes the index.
60 -- This is used only during the building of the data structures.
61 setIdx :: Instance -- ^ the original instance
63 -> Instance -- ^ the modified instance
64 setIdx t i = t { idx = i }
67 -- This is used only during the building of the data structures.
68 setName t s = t {name = s}