{-
-Copyright (C) 2009, 2010, 2011 Google Inc.
+Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
, instanceStatusFromRaw
, instanceStatusToRaw
, RSpec(..)
+ , AllocInfo(..)
+ , AllocStats
, DynUtil(..)
, zeroUtil
, baseUtil
, addUtil
, subUtil
- , defVcpuRatio
, defReservedDiskRatio
, unitMem
, unitCpu
, ("DTPlain", 'C.dtPlain)
, ("DTBlock", 'C.dtBlock)
, ("DTDrbd8", 'C.dtDrbd8)
+ , ("DTRbd", 'C.dtRbd)
])
$(THH.makeJSONInstance ''DiskTemplate)
, rspecDsk :: Int -- ^ Requested disk
} deriving (Show, Read, Eq)
+-- | Allocation stats type. This is used instead of 'RSpec' (which was
+-- used at first), because we need to track more stats. The actual
+-- data can refer either to allocated, or available, etc. values
+-- depending on the context. See also
+-- 'Cluster.computeAllocationDelta'.
+data AllocInfo = AllocInfo
+ { allocInfoVCpus :: Int -- ^ VCPUs
+ , allocInfoNCpus :: Double -- ^ Normalised CPUs
+ , allocInfoMem :: Int -- ^ Memory
+ , allocInfoDisk :: Int -- ^ Disk
+ } deriving (Show, Read, Eq)
+
+-- | Currently used, possibly to allocate, unallocable.
+type AllocStats = (AllocInfo, AllocInfo, AllocInfo)
-- | Instance specification type.
$(THH.buildObject "ISpec" "iSpec"
- [ THH.renameField "MemorySize" $ THH.simpleField "memory-size" [t| Int |]
- , THH.renameField "CpuCount" $ THH.simpleField "cpu-count" [t| Int |]
- , THH.renameField "DiskSize" $ THH.simpleField "disk-size" [t| Int |]
- , THH.renameField "DiskCount" $ THH.simpleField "disk-count" [t| Int |]
- , THH.renameField "NicCount" $ THH.simpleField "nic-count" [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 |]
])
-- | The default minimum ispec.
-- | Instance policy type.
$(THH.buildObject "IPolicy" "iPolicy"
- [ THH.renameField "StdSpec" $ THH.simpleField "std" [t| ISpec |]
- , THH.renameField "MinSpec" $ THH.simpleField "min" [t| ISpec |]
- , THH.renameField "MaxSpec" $ THH.simpleField "max" [t| ISpec |]
+ [ THH.renameField "StdSpec" $ THH.simpleField C.ispecsStd [t| ISpec |]
+ , THH.renameField "MinSpec" $ THH.simpleField C.ispecsMin [t| ISpec |]
+ , THH.renameField "MaxSpec" $ THH.simpleField C.ispecsMax [t| ISpec |]
, THH.renameField "DiskTemplates" $
- THH.simpleField "disk_templates" [t| [DiskTemplate] |]
+ 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.
-- string values, not the actual type; and in
-- 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
queryTimeout :: Int
queryTimeout = 60
--- | Default vcpu-to-pcpu ratio (randomly chosen value).
-defVcpuRatio :: Double
-defVcpuRatio = 64
-
-- | Default max disk usage ratio.
defReservedDiskRatio :: Double
defReservedDiskRatio = 0