root / Ganeti / HTools / Instance.hs @ 669d7e3d
History | View | Annotate | Download (1.9 kB)
1 |
{-| Module describing an instance. |
---|---|
2 |
|
3 |
The instance data type holds very few fields, the algorithm |
4 |
intelligence is in the "Node" and "Cluster" modules. |
5 |
|
6 |
-} |
7 |
module Ganeti.HTools.Instance where |
8 |
|
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 |
14 |
} deriving (Show) |
15 |
|
16 |
create :: String -> String -> Int -> Int -> Instance |
17 |
create mem_init dsk_init pn sn = Instance { |
18 |
mem = read mem_init, |
19 |
dsk = read dsk_init, |
20 |
pnode = pn, |
21 |
snode = sn, |
22 |
idx = -1 |
23 |
} |
24 |
|
25 |
-- | Changes the primary node of the instance. |
26 |
setPri :: Instance -- ^ the original instance |
27 |
-> Int -- ^ the new primary node |
28 |
-> Instance -- ^ the modified instance |
29 |
setPri t p = t { pnode = p } |
30 |
|
31 |
-- | Changes the secondary node of the instance. |
32 |
setSec :: Instance -- ^ the original instance |
33 |
-> Int -- ^ the new secondary node |
34 |
-> Instance -- ^ the modified instance |
35 |
setSec t s = t { snode = s } |
36 |
|
37 |
-- | Changes both nodes of the instance. |
38 |
setBoth :: Instance -- ^ the original instance |
39 |
-> Int -- ^ new primary node index |
40 |
-> Int -- ^ new secondary node index |
41 |
-> Instance -- ^ the modified instance |
42 |
setBoth t p s = t { pnode = p, snode = s } |
43 |
|
44 |
-- | Changes the index. |
45 |
-- This is used only during the building of the data structures. |
46 |
setIdx :: Instance -- ^ the original instance |
47 |
-> Int -- ^ new index |
48 |
-> Instance -- ^ the modified instance |
49 |
setIdx t i = t { idx = i } |