[Pkg-ganeti-devel] [ganeti] 23/165: Add function deciding if a request is an allocation request
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 dde4795f19490ff2b6433ef4d81d985be614603b
Author: Klaus Aehlig <aehlig at google.com>
Date: Thu Jan 22 17:50:50 2015 +0100
Add function deciding if a request is an allocation request
...and in that case also returning the desired group for allocation,
if any.
Signed-off-by: Klaus Aehlig <aehlig at google.com>
Reviewed-by: Petr Pudlak <pudlak at google.com>
---
src/Ganeti/HTools/Loader.hs | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/Ganeti/HTools/Loader.hs b/src/Ganeti/HTools/Loader.hs
index 10df2c5..4cc3544 100644
--- a/src/Ganeti/HTools/Loader.hs
+++ b/src/Ganeti/HTools/Loader.hs
@@ -51,6 +51,7 @@ module Ganeti.HTools.Loader
, RqType(..)
, Request(..)
, ClusterData(..)
+ , isAllocationRequest
, emptyCluster
) where
@@ -96,6 +97,21 @@ data RqType
data Request = Request RqType ClusterData
deriving (Show)
+-- | Decide whether a request asks to allocate new instances; if so, also
+-- return the desired node group, if a unique node group is specified.
+-- That is, return `Nothing` if the request is not an allocation request,
+-- `Just Nothing`, if it is an Allocation request, but there is no unique
+-- group specified, and return `Just (Just g)` if it is an allocation request
+-- uniquely requesting Group `g`.
+isAllocationRequest :: RqType -> Maybe (Maybe String)
+isAllocationRequest (Allocate _ (Cluster.AllocDetails _ grp)) = Just grp
+isAllocationRequest (MultiAllocate reqs) = Just $
+ case ordNub . catMaybes
+ $ map (\(_, Cluster.AllocDetails _ grp) -> grp) reqs of
+ [grp] -> Just grp
+ _ -> Nothing
+isAllocationRequest _ = Nothing
+
-- | The cluster state.
data ClusterData = ClusterData
{ cdGroups :: Group.List -- ^ The node group list
--
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