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 { mem :: Int -- ^ memory of the instance
10 , dsk :: Int -- ^ disk size of instance
11 , running :: Bool -- ^ whether the instance
13 , run_st :: String -- ^ original (text) run status
14 , pnode :: Int -- ^ original primary node
15 , snode :: Int -- ^ original secondary node
16 , idx :: Int -- ^ internal index for
20 create :: Int -> Int -> String -> Int -> Int -> Instance
21 create mem_init dsk_init run_init pn sn =
25 running = case run_init of
35 -- | Changes the primary node of the instance.
36 setPri :: Instance -- ^ the original instance
37 -> Int -- ^ the new primary node
38 -> Instance -- ^ the modified instance
39 setPri t p = t { pnode = p }
41 -- | Changes the secondary node of the instance.
42 setSec :: Instance -- ^ the original instance
43 -> Int -- ^ the new secondary node
44 -> Instance -- ^ the modified instance
45 setSec t s = t { snode = s }
47 -- | Changes both nodes of the instance.
48 setBoth :: Instance -- ^ the original instance
49 -> Int -- ^ new primary node index
50 -> Int -- ^ new secondary node index
51 -> Instance -- ^ the modified instance
52 setBoth t p s = t { pnode = p, snode = s }
54 -- | Changes the index.
55 -- This is used only during the building of the data structures.
56 setIdx :: Instance -- ^ the original instance
58 -> Instance -- ^ the modified instance
59 setIdx t i = t { idx = i }