Revision 6cff91f5
b/htools/Ganeti/HTools/Group.hs | ||
---|---|---|
45 | 45 |
, uuid :: T.GroupID -- ^ The UUID of the group |
46 | 46 |
, idx :: T.Gdx -- ^ Internal index for book-keeping |
47 | 47 |
, allocPolicy :: T.AllocPolicy -- ^ The allocation policy for this group |
48 |
, iPolicy :: T.IPolicy -- ^ The instance policy for this group |
|
48 | 49 |
} deriving (Show, Read, Eq) |
49 | 50 |
|
50 | 51 |
-- Note: we use the name as the alias, and the UUID as the official |
... | ... | |
65 | 66 |
-- * Initialization functions |
66 | 67 |
|
67 | 68 |
-- | Create a new group. |
68 |
create :: String -> T.GroupID -> T.AllocPolicy -> Group |
|
69 |
create name_init id_init apol_init = |
|
69 |
create :: String -> T.GroupID -> T.AllocPolicy -> T.IPolicy -> Group
|
|
70 |
create name_init id_init apol_init ipol_init =
|
|
70 | 71 |
Group { name = name_init |
71 | 72 |
, uuid = id_init |
72 | 73 |
, allocPolicy = apol_init |
74 |
, iPolicy = ipol_init |
|
73 | 75 |
, idx = -1 |
74 | 76 |
} |
75 | 77 |
|
b/htools/Ganeti/HTools/IAlloc.hs | ||
---|---|---|
125 | 125 |
let extract x = tryFromObj ("invalid data for group '" ++ u ++ "'") a x |
126 | 126 |
name <- extract "name" |
127 | 127 |
apol <- extract "alloc_policy" |
128 |
return (u, Group.create name u apol) |
|
128 |
ipol <- extract "ipolicy" |
|
129 |
return (u, Group.create name u apol ipol) |
|
129 | 130 |
|
130 | 131 |
-- | Top-level parser. |
131 | 132 |
-- |
b/htools/Ganeti/HTools/Luxi.hs | ||
---|---|---|
115 | 115 |
-- | The input data for node group query. |
116 | 116 |
queryGroupsMsg :: L.LuxiOp |
117 | 117 |
queryGroupsMsg = |
118 |
L.Query L.QRGroup ["uuid", "name", "alloc_policy"] () |
|
118 |
L.Query L.QRGroup ["uuid", "name", "alloc_policy", "ipolicy"] ()
|
|
119 | 119 |
|
120 | 120 |
-- | Wraper over 'callMethod' doing node query. |
121 | 121 |
queryNodes :: L.Client -> IO (Result JSValue) |
... | ... | |
215 | 215 |
|
216 | 216 |
-- | Parses a given group information. |
217 | 217 |
parseGroup :: [(JSValue, JSValue)] -> Result (String, Group.Group) |
218 |
parseGroup [uuid, name, apol] = do |
|
218 |
parseGroup [uuid, name, apol, ipol] = do
|
|
219 | 219 |
xname <- annotateResult "Parsing new group" (fromJValWithStatus name) |
220 | 220 |
let convert a = genericConvert "Group" xname a |
221 | 221 |
xuuid <- convert "uuid" uuid |
222 | 222 |
xapol <- convert "alloc_policy" apol |
223 |
return (xuuid, Group.create xname xuuid xapol) |
|
223 |
xipol <- convert "ipolicy" ipol |
|
224 |
return (xuuid, Group.create xname xuuid xapol xipol) |
|
224 | 225 |
|
225 | 226 |
parseGroup v = fail ("Invalid group query result: " ++ show v) |
226 | 227 |
|
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
90 | 90 |
maxCpu :: Int |
91 | 91 |
maxCpu = 1024 |
92 | 92 |
|
93 |
-- | Null iPolicy, and by null we mean very liberal. |
|
94 |
nullIPolicy = Types.IPolicy |
|
95 |
{ Types.iPolicyMinSpec = Types.ISpec { Types.iSpecMemorySize = 0 |
|
96 |
, Types.iSpecCpuCount = 0 |
|
97 |
, Types.iSpecDiskSize = 0 |
|
98 |
, Types.iSpecDiskCount = 0 |
|
99 |
, Types.iSpecNicCount = 0 |
|
100 |
} |
|
101 |
, Types.iPolicyMaxSpec = Types.ISpec { Types.iSpecMemorySize = maxBound |
|
102 |
, Types.iSpecCpuCount = maxBound |
|
103 |
, Types.iSpecDiskSize = maxBound |
|
104 |
, Types.iSpecDiskCount = C.maxDisks |
|
105 |
, Types.iSpecNicCount = C.maxNics |
|
106 |
} |
|
107 |
, Types.iPolicyStdSpec = Types.ISpec { Types.iSpecMemorySize = Types.unitMem |
|
108 |
, Types.iSpecCpuCount = Types.unitCpu |
|
109 |
, Types.iSpecDiskSize = Types.unitDsk |
|
110 |
, Types.iSpecDiskCount = 1 |
|
111 |
, Types.iSpecNicCount = 1 |
|
112 |
} |
|
113 |
, Types.iPolicyDiskTemplates = [Types.DTDrbd8, Types.DTPlain] |
|
114 |
} |
|
115 |
|
|
116 |
|
|
93 | 117 |
defGroup :: Group.Group |
94 | 118 |
defGroup = flip Group.setIdx 0 $ |
95 | 119 |
Group.create "default" Types.defaultGroupID Types.AllocPreferred |
120 |
nullIPolicy |
|
96 | 121 |
|
97 | 122 |
defGroupList :: Group.List |
98 | 123 |
defGroupList = Container.fromList [(Group.idx defGroup, defGroup)] |
... | ... | |
934 | 959 |
i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu |
935 | 960 |
in case allocnodes >>= \allocnodes' -> |
936 | 961 |
Cluster.iterateAlloc nl' il (Just 5) i_templ allocnodes' [] [] of |
937 |
Types.Bad _ -> False |
|
962 |
Types.Bad _ -> printTestCase "Failed to allocate" False |
|
963 |
Types.Ok (_, _, _, [], _) -> printTestCase "Failed to allocate" False |
|
938 | 964 |
Types.Ok (_, xnl, il', _, _) -> |
939 | 965 |
let ynl = Container.add (Node.idx hnode) hnode xnl |
940 | 966 |
cv = Cluster.compCV ynl |
941 | 967 |
tbl = Cluster.Table ynl il' cv [] |
942 |
in canBalance tbl True True False |
|
968 |
in printTestCase "Failed to rebalance" $ |
|
969 |
canBalance tbl True True False |
|
943 | 970 |
|
944 | 971 |
-- | Checks consistency. |
945 | 972 |
prop_ClusterCheckConsistency node inst = |
b/htools/Ganeti/HTools/Rapi.hs | ||
---|---|---|
159 | 159 |
let extract s = tryFromObj ("Group '" ++ name ++ "'") a s |
160 | 160 |
uuid <- extract "uuid" |
161 | 161 |
apol <- extract "alloc_policy" |
162 |
return (uuid, Group.create name uuid apol) |
|
162 |
ipol <- extract "ipolicy" |
|
163 |
return (uuid, Group.create name uuid apol ipol) |
|
163 | 164 |
|
164 | 165 |
-- | Parse cluster data from the info resource. |
165 | 166 |
parseCluster :: JSObject JSValue -> Result ([String], IPolicy) |
b/htools/Ganeti/HTools/Simu.hs | ||
---|---|---|
77 | 77 |
(fromIntegral cpu) False grpIndex |
78 | 78 |
) [1..ncount] |
79 | 79 |
grp = Group.create (printf "group-%02d" grpIndex) |
80 |
(printf "fake-uuid-%02d" grpIndex) apol |
|
80 |
(printf "fake-uuid-%02d" grpIndex) apol defIPolicy
|
|
81 | 81 |
return (Group.setIdx grp grpIndex, nodes) |
82 | 82 |
|
83 | 83 |
-- | Builds the cluster data from node\/instance files. |
b/htools/Ganeti/HTools/Text.hs | ||
---|---|---|
119 | 119 |
-- UUID and group object |
120 | 120 |
loadGroup [name, gid, apol] = do |
121 | 121 |
xapol <- allocPolicyFromRaw apol |
122 |
return (gid, Group.create name gid xapol) |
|
122 |
return (gid, Group.create name gid xapol defIPolicy)
|
|
123 | 123 |
|
124 | 124 |
loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'" |
125 | 125 |
|
Also available in: Unified diff