Commit d953a965 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

htools: Add the new ipolicy field



Also add the spindle usage to QC
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 553cb5f7
......@@ -116,18 +116,21 @@ nullIPolicy = Types.IPolicy
, Types.iSpecDiskSize = 0
, Types.iSpecDiskCount = 0
, Types.iSpecNicCount = 0
, Types.iSpecSpindleUse = 0
}
, Types.iPolicyMaxSpec = Types.ISpec { Types.iSpecMemorySize = maxBound
, Types.iSpecCpuCount = maxBound
, Types.iSpecDiskSize = maxBound
, Types.iSpecDiskCount = C.maxDisks
, Types.iSpecNicCount = C.maxNics
, Types.iSpecSpindleUse = maxBound
}
, Types.iPolicyStdSpec = Types.ISpec { Types.iSpecMemorySize = Types.unitMem
, Types.iSpecCpuCount = Types.unitCpu
, Types.iSpecDiskSize = Types.unitDsk
, Types.iSpecDiskCount = 1
, Types.iSpecNicCount = 1
, Types.iSpecSpindleUse = 1
}
, Types.iPolicyDiskTemplates = [Types.DTDrbd8, Types.DTPlain]
, Types.iPolicyVcpuRatio = maxVcpuRatio -- somewhat random value, high
......@@ -432,11 +435,13 @@ instance Arbitrary Types.ISpec where
dsk_s <- arbitrary::Gen (NonNegative Int)
cpu_c <- arbitrary::Gen (NonNegative Int)
nic_c <- arbitrary::Gen (NonNegative Int)
su <- arbitrary::Gen (NonNegative Int)
return Types.ISpec { Types.iSpecMemorySize = fromIntegral mem_s
, Types.iSpecCpuCount = fromIntegral cpu_c
, Types.iSpecDiskSize = fromIntegral dsk_s
, Types.iSpecDiskCount = fromIntegral dsk_c
, Types.iSpecNicCount = fromIntegral nic_c
, Types.iSpecSpindleUse = fromIntegral su
}
-- | Generates an ispec bigger than the given one.
......@@ -447,11 +452,13 @@ genBiggerISpec imin = do
dsk_s <- choose (Types.iSpecDiskSize imin, maxBound)
cpu_c <- choose (Types.iSpecCpuCount imin, maxBound)
nic_c <- choose (Types.iSpecNicCount imin, maxBound)
su <- choose (Types.iSpecSpindleUse imin, maxBound)
return Types.ISpec { Types.iSpecMemorySize = fromIntegral mem_s
, Types.iSpecCpuCount = fromIntegral cpu_c
, Types.iSpecDiskSize = fromIntegral dsk_s
, Types.iSpecDiskCount = fromIntegral dsk_c
, Types.iSpecNicCount = fromIntegral nic_c
, Types.iSpecSpindleUse = fromIntegral su
}
instance Arbitrary Types.IPolicy where
......
......@@ -118,8 +118,9 @@ serializeInstances nl =
serializeISpec :: ISpec -> String
serializeISpec ispec =
-- this needs to be kept in sync with the object definition
let ISpec mem_s cpu_c disk_s disk_c nic_c = ispec
strings = [show mem_s, show cpu_c, show disk_s, show disk_c, show nic_c]
let ISpec mem_s cpu_c disk_s disk_c nic_c su = ispec
strings = [show mem_s, show cpu_c, show disk_s, show disk_c, show nic_c,
show su]
in intercalate "," strings
-- | Generate disk template data.
......@@ -238,13 +239,14 @@ loadInst _ s = fail $ "Invalid/incomplete instance data: '" ++ show s ++ "'"
-- | Loads a spec from a field list.
loadISpec :: String -> [String] -> Result ISpec
loadISpec owner [mem_s, cpu_c, dsk_s, dsk_c, nic_c] = do
loadISpec owner [mem_s, cpu_c, dsk_s, dsk_c, nic_c, su] = do
xmem_s <- tryRead (owner ++ "/memsize") mem_s
xcpu_c <- tryRead (owner ++ "/cpucount") cpu_c
xdsk_s <- tryRead (owner ++ "/disksize") dsk_s
xdsk_c <- tryRead (owner ++ "/diskcount") dsk_c
xnic_c <- tryRead (owner ++ "/niccount") nic_c
return $ ISpec xmem_s xcpu_c xdsk_s xdsk_c xnic_c
xsu <- tryRead (owner ++ "/spindleuse") su
return $ ISpec xmem_s xcpu_c xdsk_s xdsk_c xnic_c xsu
loadISpec owner s = fail $ "Invalid ispec data for " ++ owner ++ ": " ++ show s
-- | Loads an ipolicy from a field list.
......
......@@ -192,11 +192,12 @@ type AllocStats = (AllocInfo, AllocInfo, AllocInfo)
-- | Instance specification type.
$(THH.buildObject "ISpec" "iSpec"
[ THH.renameField "MemorySize" $ THH.simpleField C.ispecMemSize [t| Int |]
, THH.renameField "CpuCount" $ THH.simpleField C.ispecCpuCount [t| Int |]
, THH.renameField "DiskSize" $ THH.simpleField C.ispecDiskSize [t| Int |]
, THH.renameField "DiskCount" $ THH.simpleField C.ispecDiskCount [t| Int |]
, THH.renameField "NicCount" $ THH.simpleField C.ispecNicCount [t| Int |]
[ THH.renameField "MemorySize" $ THH.simpleField C.ispecMemSize [t| Int |]
, THH.renameField "CpuCount" $ THH.simpleField C.ispecCpuCount [t| Int |]
, THH.renameField "DiskSize" $ THH.simpleField C.ispecDiskSize [t| Int |]
, THH.renameField "DiskCount" $ THH.simpleField C.ispecDiskCount [t| Int |]
, THH.renameField "NicCount" $ THH.simpleField C.ispecNicCount [t| Int |]
, THH.renameField "SpindleUse" $ THH.simpleField C.ispecSpindleUse [t| Int |]
])
-- | The default minimum ispec.
......@@ -206,6 +207,7 @@ defMinISpec = ISpec { iSpecMemorySize = C.ipolicyDefaultsMinMemorySize
, iSpecDiskSize = C.ipolicyDefaultsMinDiskSize
, iSpecDiskCount = C.ipolicyDefaultsMinDiskCount
, iSpecNicCount = C.ipolicyDefaultsMinNicCount
, iSpecSpindleUse = C.ipolicyDefaultsMinSpindleUse
}
-- | The default standard ispec.
......@@ -215,6 +217,7 @@ defStdISpec = ISpec { iSpecMemorySize = C.ipolicyDefaultsStdMemorySize
, iSpecDiskSize = C.ipolicyDefaultsStdDiskSize
, iSpecDiskCount = C.ipolicyDefaultsStdDiskCount
, iSpecNicCount = C.ipolicyDefaultsStdNicCount
, iSpecSpindleUse = C.ipolicyDefaultsStdSpindleUse
}
-- | The default max ispec.
......@@ -224,6 +227,7 @@ defMaxISpec = ISpec { iSpecMemorySize = C.ipolicyDefaultsMaxMemorySize
, iSpecDiskSize = C.ipolicyDefaultsMaxDiskSize
, iSpecDiskCount = C.ipolicyDefaultsMaxDiskCount
, iSpecNicCount = C.ipolicyDefaultsMaxNicCount
, iSpecSpindleUse = C.ipolicyDefaultsMaxSpindleUse
}
-- | Instance policy type.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment