[Pkg-ganeti-devel] [ganeti] 25/165: Add a function computing the test instances
Apollon Oikonomopoulos
apoikos at moszumanska.debian.org
Tue Aug 11 13:53:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
apoikos pushed a commit to branch master
in repository ganeti.
commit 7f10b139109dc5bf5037997f0ce624c8fae21197
Author: Klaus Aehlig <aehlig at google.com>
Date: Fri Jan 23 15:42:35 2015 +0100
Add a function computing the test instances
The allocation vector (and hence the lost-allocations metrics build
on top of it) is based on counting how many instances of a certain
size can be placed on a node. Add a function computing those test
instances from the policy, i.e., add a returning an instance matching
the lower bounds of each policy interval, in decreasing order.
Signed-off-by: Klaus Aehlig <aehlig at google.com>
Reviewed-by: Petr Pudlak <pudlak at google.com>
---
src/Ganeti/HTools/Dedicated.hs | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/Ganeti/HTools/Dedicated.hs b/src/Ganeti/HTools/Dedicated.hs
index a718db7..1ce6b32 100644
--- a/src/Ganeti/HTools/Dedicated.hs
+++ b/src/Ganeti/HTools/Dedicated.hs
@@ -34,14 +34,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Ganeti.HTools.Dedicated
( isDedicated
+ , testInstances
) where
import Control.Applicative (liftA2)
import qualified Data.Foldable as F
+import Data.Function (on)
import qualified Data.IntMap as IntMap
import qualified Data.IntSet as IntSet
+import Data.List (sortBy)
import qualified Ganeti.HTools.Group as Group
+import qualified Ganeti.HTools.Instance as Instance
import qualified Ganeti.HTools.Loader as Loader
import qualified Ganeti.HTools.Node as Node
import qualified Ganeti.HTools.Types as T
@@ -59,3 +63,27 @@ isDedicated cdata maybeGroup =
in F.all (liftA2 (||) Node.exclStorage
$ not . (`IntSet.member` groups) . Node.group)
$ Loader.cdNodes cdata
+
+-- | Given a specification interval, create an instance minimally fitting
+-- into that interval. In other words create an instance from the lower bounds
+-- of the specified interval.
+minimallyCompliantInstance :: T.ISpec -> Instance.Instance
+minimallyCompliantInstance spec =
+ Instance.create "minimalspecinstance"
+ (T.iSpecMemorySize spec)
+ (T.iSpecDiskSize spec)
+ []
+ (T.iSpecCpuCount spec)
+ T.Running [] False Node.noSecondary Node.noSecondary T.DTPlain
+ (T.iSpecSpindleUse spec)
+ [] False
+
+-- | From an instance policy get the list of test instances, in correct order,
+-- for which the allocation count has to be determined for the lost allocations
+-- metrics.
+testInstances :: T.IPolicy -> [Instance.Instance]
+testInstances =
+ map minimallyCompliantInstance
+ . sortBy (flip compare `on` T.iSpecDiskSize)
+ . map T.minMaxISpecsMinSpec
+ . T.iPolicyMinMaxISpecs
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git
More information about the Pkg-ganeti-devel
mailing list