Revision 9188aeef Ganeti/HTools/Instance.hs
b/Ganeti/HTools/Instance.hs | ||
---|---|---|
9 | 9 |
import qualified Ganeti.HTools.Types as T |
10 | 10 |
import qualified Ganeti.HTools.Container as Container |
11 | 11 |
|
12 |
data Instance = Instance { name :: String -- ^ the instance name |
|
13 |
, mem :: Int -- ^ memory of the instance |
|
14 |
, dsk :: Int -- ^ disk size of instance |
|
15 |
, running :: Bool -- ^ whether the instance |
|
12 |
-- * Type declarations |
|
13 |
|
|
14 |
-- | The instance type |
|
15 |
data Instance = Instance { name :: String -- ^ The instance name |
|
16 |
, mem :: Int -- ^ Memory of the instance |
|
17 |
, dsk :: Int -- ^ Disk size of instance |
|
18 |
, running :: Bool -- ^ Whether the instance |
|
16 | 19 |
-- is running |
17 |
, run_st :: String -- ^ original (text) run status
|
|
18 |
, pnode :: T.Ndx -- ^ original primary node
|
|
19 |
, snode :: T.Ndx -- ^ original secondary node
|
|
20 |
, idx :: T.Idx -- ^ internal index for
|
|
20 |
, run_st :: String -- ^ Original (text) run status
|
|
21 |
, pnode :: T.Ndx -- ^ Original primary node
|
|
22 |
, snode :: T.Ndx -- ^ Original secondary node
|
|
23 |
, idx :: T.Idx -- ^ Internal index for
|
|
21 | 24 |
-- book-keeping |
22 | 25 |
} deriving (Show) |
23 | 26 |
|
... | ... | |
27 | 30 |
setName = setName |
28 | 31 |
setIdx = setIdx |
29 | 32 |
|
30 |
-- | A simple name for the int, instance association list |
|
33 |
-- | A simple name for the int, instance association list.
|
|
31 | 34 |
type AssocList = [(T.Idx, Instance)] |
32 | 35 |
|
33 |
-- | A simple name for an instance map |
|
36 |
-- | A simple name for an instance map.
|
|
34 | 37 |
type List = Container.Container Instance |
35 | 38 |
|
39 |
-- * Initialization |
|
40 |
|
|
41 |
-- | Create an instance. |
|
42 |
-- |
|
43 |
-- Some parameters are not initialized by function, and must be set |
|
44 |
-- later (via 'setIdx' for example). |
|
36 | 45 |
create :: String -> Int -> Int -> String -> T.Ndx -> T.Ndx -> Instance |
37 | 46 |
create name_init mem_init dsk_init run_init pn sn = |
38 | 47 |
Instance { |
... | ... | |
49 | 58 |
idx = -1 |
50 | 59 |
} |
51 | 60 |
|
61 |
-- | Changes the index. |
|
62 |
-- |
|
63 |
-- This is used only during the building of the data structures. |
|
64 |
setIdx :: Instance -- ^ the original instance |
|
65 |
-> T.Idx -- ^ new index |
|
66 |
-> Instance -- ^ the modified instance |
|
67 |
setIdx t i = t { idx = i } |
|
68 |
|
|
69 |
-- | Changes the name. |
|
70 |
-- |
|
71 |
-- This is used only during the building of the data structures. |
|
72 |
setName :: Instance -- ^ The original instance |
|
73 |
-> String -- ^ New name |
|
74 |
-> Instance |
|
75 |
setName t s = t { name = s } |
|
76 |
|
|
77 |
-- * Update functions |
|
78 |
|
|
52 | 79 |
-- | Changes the primary node of the instance. |
53 | 80 |
setPri :: Instance -- ^ the original instance |
54 | 81 |
-> T.Ndx -- ^ the new primary node |
... | ... | |
67 | 94 |
-> T.Ndx -- ^ new secondary node index |
68 | 95 |
-> Instance -- ^ the modified instance |
69 | 96 |
setBoth t p s = t { pnode = p, snode = s } |
70 |
|
|
71 |
-- | Changes the index. |
|
72 |
-- This is used only during the building of the data structures. |
|
73 |
setIdx :: Instance -- ^ the original instance |
|
74 |
-> T.Idx -- ^ new index |
|
75 |
-> Instance -- ^ the modified instance |
|
76 |
setIdx t i = t { idx = i } |
|
77 |
|
|
78 |
-- | Changes the name |
|
79 |
-- This is used only during the building of the data structures. |
|
80 |
setName t s = t { name = s } |
Also available in: Unified diff