Revision e8fa4ff6
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
122 | 122 |
, Types.iSpecNicCount = 1 |
123 | 123 |
} |
124 | 124 |
, Types.iPolicyDiskTemplates = [Types.DTDrbd8, Types.DTPlain] |
125 |
, Types.iPolicyVcpuRatio = 1024 -- somewhat random value, high |
|
126 |
-- enough to not impact us |
|
125 | 127 |
} |
126 | 128 |
|
127 | 129 |
|
... | ... | |
439 | 441 |
imax <- genBiggerISpec istd |
440 | 442 |
num_tmpl <- choose (0, length allDiskTemplates) |
441 | 443 |
dts <- genUniquesList num_tmpl |
444 |
vcpu_ratio <- arbitrary |
|
442 | 445 |
return Types.IPolicy { Types.iPolicyMinSpec = imin |
443 | 446 |
, Types.iPolicyStdSpec = istd |
444 | 447 |
, Types.iPolicyMaxSpec = imax |
445 | 448 |
, Types.iPolicyDiskTemplates = dts |
449 |
, Types.iPolicyVcpuRatio = vcpu_ratio |
|
446 | 450 |
} |
447 | 451 |
|
448 | 452 |
-- * Actual tests |
b/htools/Ganeti/HTools/Text.hs | ||
---|---|---|
128 | 128 |
-- | Generate policy data from a given policy object. |
129 | 129 |
serializeIPolicy :: String -> IPolicy -> String |
130 | 130 |
serializeIPolicy owner ipol = |
131 |
let IPolicy stdspec minspec maxspec dts = ipol |
|
131 |
let IPolicy stdspec minspec maxspec dts vcpu_ratio = ipol
|
|
132 | 132 |
strings = [ owner |
133 | 133 |
, serializeISpec stdspec |
134 | 134 |
, serializeISpec minspec |
135 | 135 |
, serializeISpec maxspec |
136 | 136 |
, serializeDiskTemplates dts |
137 |
, show vcpu_ratio |
|
137 | 138 |
] |
138 | 139 |
in intercalate "|" strings |
139 | 140 |
|
... | ... | |
235 | 236 |
|
236 | 237 |
-- | Loads an ipolicy from a field list. |
237 | 238 |
loadIPolicy :: [String] -> Result (String, IPolicy) |
238 |
loadIPolicy [owner, stdspec, minspec, maxspec, dtemplates] = do |
|
239 |
loadIPolicy [owner, stdspec, minspec, maxspec, dtemplates, vcpu_ratio] = do
|
|
239 | 240 |
xstdspec <- loadISpec (owner ++ "/stdspec") (commaSplit stdspec) |
240 | 241 |
xminspec <- loadISpec (owner ++ "/minspec") (commaSplit minspec) |
241 | 242 |
xmaxspec <- loadISpec (owner ++ "/maxspec") (commaSplit maxspec) |
242 | 243 |
xdts <- mapM diskTemplateFromRaw $ commaSplit dtemplates |
243 |
return $ (owner, IPolicy xstdspec xminspec xmaxspec xdts) |
|
244 |
xvcpu_ratio <- tryRead (owner ++ "/vcpu_ratio") vcpu_ratio |
|
245 |
return $ (owner, IPolicy xstdspec xminspec xmaxspec xdts xvcpu_ratio) |
|
244 | 246 |
loadIPolicy s = fail $ "Invalid ipolicy data: '" ++ show s ++ "'" |
245 | 247 |
|
246 | 248 |
loadOnePolicy :: (IPolicy, Group.List) -> String |
b/htools/Ganeti/HTools/Types.hs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
{- |
8 | 8 |
|
9 |
Copyright (C) 2009, 2010, 2011 Google Inc. |
|
9 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
|
|
10 | 10 |
|
11 | 11 |
This program is free software; you can redistribute it and/or modify |
12 | 12 |
it under the terms of the GNU General Public License as published by |
... | ... | |
199 | 199 |
, THH.renameField "MaxSpec" $ THH.simpleField "max" [t| ISpec |] |
200 | 200 |
, THH.renameField "DiskTemplates" $ |
201 | 201 |
THH.simpleField "disk_templates" [t| [DiskTemplate] |] |
202 |
, THH.renameField "VcpuRatio" $ |
|
203 |
THH.simpleField "vcpu_ratio" [t| Double |] |
|
202 | 204 |
]) |
203 | 205 |
|
204 | 206 |
-- | Converts an ISpec type to a RSpec one. |
... | ... | |
217 | 219 |
-- string values, not the actual type; and in |
218 | 220 |
-- htools, we are mostly looking at DRBD |
219 | 221 |
, iPolicyDiskTemplates = [DTDrbd8, DTPlain] |
222 |
, iPolicyVcpuRatio = C.ipolicyDefaultsVcpuRatio |
|
220 | 223 |
} |
221 | 224 |
|
222 | 225 |
-- | The dynamic resource specs of a machine (i.e. load or load |
Also available in: Unified diff