[Pkg-ganeti-devel] [ganeti] 102/165: Add a variant of applyMoveEx suitable for foldM
Apollon Oikonomopoulos
apoikos at moszumanska.debian.org
Tue Aug 11 13:53:17 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 fd3ec7988ee23a55eb7393249397c0b2ab6c7e8d
Author: Klaus Aehlig <aehlig at google.com>
Date: Tue Apr 14 12:07:39 2015 +0200
Add a variant of applyMoveEx suitable for foldM
When simulating scenarios to be done in case of failures, it is
convenient to have a variant of applyMoveEx that ignores soft errors
and can easily be folded. Provide such a function.
Signed-off-by: Klaus Aehlig <aehlig at google.com>
Reviewed-by: Petr Pudlak <pudlak at google.com>
---
src/Ganeti/HTools/Cluster/Moves.hs | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/Ganeti/HTools/Cluster/Moves.hs b/src/Ganeti/HTools/Cluster/Moves.hs
index 67c9f3b..bbaf44f 100644
--- a/src/Ganeti/HTools/Cluster/Moves.hs
+++ b/src/Ganeti/HTools/Cluster/Moves.hs
@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Ganeti.HTools.Cluster.Moves
( applyMoveEx
, setInstanceLocationScore
+ , move
) where
import qualified Data.Set as Set
@@ -175,3 +176,13 @@ applyMoveEx force nl inst (FailoverAndReplace new_sdx) =
Container.addTwo old_sdx new_p old_pdx int_p nl,
new_inst, old_sdx, new_sdx)
in new_nl
+
+-- | Apply a move to an instance, ignoring soft errors. This is a
+-- variant of `applyMoveEx True` suitable for folding.
+move :: (Node.List, Instance.List)
+ -> (Idx, IMove)
+ -> OpResult (Node.List, Instance.List)
+move (nl, il) (idx, mv) = do
+ let inst = Container.find idx il
+ (nl', inst', _, _) <- applyMoveEx True nl inst mv
+ return (nl', Container.add idx inst' il)
--
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