maxCpu :: Int
maxCpu = 1024
+-- | Max vcpu ratio (random value).
+maxVcpuRatio :: Double
+maxVcpuRatio = 1024.0
+
+-- | Max spindle ratio (random value).
+maxSpindleRatio :: Double
+maxSpindleRatio = 1024.0
+
-- | All disk templates (used later)
allDiskTemplates :: [Types.DiskTemplate]
allDiskTemplates = [minBound..maxBound]
, Types.iSpecNicCount = 1
}
, Types.iPolicyDiskTemplates = [Types.DTDrbd8, Types.DTPlain]
- , Types.iPolicyVcpuRatio = 1024 -- somewhat random value, high
- -- enough to not impact us
+ , Types.iPolicyVcpuRatio = maxVcpuRatio -- somewhat random value, high
+ -- enough to not impact us
+ , Types.iPolicySpindleRatio = maxSpindleRatio
}
imax <- genBiggerISpec istd
num_tmpl <- choose (0, length allDiskTemplates)
dts <- genUniquesList num_tmpl
- vcpu_ratio <- arbitrary
+ vcpu_ratio <- choose (1.0, maxVcpuRatio)
+ spindle_ratio <- choose (1.0, maxSpindleRatio)
return Types.IPolicy { Types.iPolicyMinSpec = imin
, Types.iPolicyStdSpec = istd
, Types.iPolicyMaxSpec = imax
, Types.iPolicyDiskTemplates = dts
, Types.iPolicyVcpuRatio = vcpu_ratio
+ , Types.iPolicySpindleRatio = spindle_ratio
}
-- * Actual tests
-- | Generate policy data from a given policy object.
serializeIPolicy :: String -> IPolicy -> String
serializeIPolicy owner ipol =
- let IPolicy stdspec minspec maxspec dts vcpu_ratio = ipol
+ let IPolicy stdspec minspec maxspec dts vcpu_ratio spindle_ratio = ipol
strings = [ owner
, serializeISpec stdspec
, serializeISpec minspec
, serializeISpec maxspec
, serializeDiskTemplates dts
, show vcpu_ratio
+ , show spindle_ratio
]
in intercalate "|" strings
-- | Loads an ipolicy from a field list.
loadIPolicy :: [String] -> Result (String, IPolicy)
-loadIPolicy [owner, stdspec, minspec, maxspec, dtemplates, vcpu_ratio] = do
+loadIPolicy [owner, stdspec, minspec, maxspec, dtemplates,
+ vcpu_ratio, spindle_ratio] = do
xstdspec <- loadISpec (owner ++ "/stdspec") (commaSplit stdspec)
xminspec <- loadISpec (owner ++ "/minspec") (commaSplit minspec)
xmaxspec <- loadISpec (owner ++ "/maxspec") (commaSplit maxspec)
xdts <- mapM diskTemplateFromRaw $ commaSplit dtemplates
xvcpu_ratio <- tryRead (owner ++ "/vcpu_ratio") vcpu_ratio
- return $ (owner, IPolicy xstdspec xminspec xmaxspec xdts xvcpu_ratio)
+ xspindle_ratio <- tryRead (owner ++ "/spindle_ratio") spindle_ratio
+ return $ (owner, IPolicy xstdspec xminspec xmaxspec xdts
+ xvcpu_ratio xspindle_ratio)
loadIPolicy s = fail $ "Invalid ipolicy data: '" ++ show s ++ "'"
loadOnePolicy :: (IPolicy, Group.List) -> String
THH.simpleField C.ipolicyDts [t| [DiskTemplate] |]
, THH.renameField "VcpuRatio" $
THH.simpleField C.ipolicyVcpuRatio [t| Double |]
+ , THH.renameField "SpindleRatio" $
+ THH.simpleField C.ipolicySpindleRatio [t| Double |]
])
-- | Converts an ISpec type to a RSpec one.
-- htools, we are mostly looking at DRBD
, iPolicyDiskTemplates = [DTDrbd8, DTPlain]
, iPolicyVcpuRatio = C.ipolicyDefaultsVcpuRatio
+ , iPolicySpindleRatio = C.ipolicyDefaultsSpindleRatio
}
-- | The dynamic resource specs of a machine (i.e. load or load