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 , pnode :: Int -- ^ original primary node
12 , snode :: Int -- ^ original secondary node
13 , idx :: Int -- ^ internal index for book-keeping
16 create :: Int -> Int -> Int -> Int -> Instance
17 create mem_init dsk_init pn sn =
26 -- | Changes the primary node of the instance.
27 setPri :: Instance -- ^ the original instance
28 -> Int -- ^ the new primary node
29 -> Instance -- ^ the modified instance
30 setPri t p = t { pnode = p }
32 -- | Changes the secondary node of the instance.
33 setSec :: Instance -- ^ the original instance
34 -> Int -- ^ the new secondary node
35 -> Instance -- ^ the modified instance
36 setSec t s = t { snode = s }
38 -- | Changes both nodes of the instance.
39 setBoth :: Instance -- ^ the original instance
40 -> Int -- ^ new primary node index
41 -> Int -- ^ new secondary node index
42 -> Instance -- ^ the modified instance
43 setBoth t p s = t { pnode = p, snode = s }
45 -- | Changes the index.
46 -- This is used only during the building of the data structures.
47 setIdx :: Instance -- ^ the original instance
49 -> Instance -- ^ the modified instance
50 setIdx t i = t { idx = i }