On Wed, Apr 15, 2015 at 08:55:01AM +0200, 'Klaus Aehlig' via ganeti-devel wrote:
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 <[email protected]>
---
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)
--
2.2.0.rc0.207.ga3a616c
LGTM