395 |
395 |
new_inst, old_sdx, old_pdx)
|
396 |
396 |
in new_nl
|
397 |
397 |
|
|
398 |
-- Failover to any (fa)
|
|
399 |
applyMove nl inst (FailoverToAny new_pdx) = do
|
|
400 |
let (old_pdx, old_sdx, old_pnode, _) = instanceNodes nl inst
|
|
401 |
new_pnode = Container.find new_pdx nl
|
|
402 |
force_failover = Node.offline old_pnode
|
|
403 |
new_pnode' <- Node.addPriEx force_failover new_pnode inst
|
|
404 |
let old_pnode' = Node.removePri old_pnode inst
|
|
405 |
inst' = Instance.setPri inst new_pdx
|
|
406 |
nl' = Container.addTwo old_pdx old_pnode' new_pdx new_pnode' nl
|
|
407 |
return (nl', inst', new_pdx, old_sdx)
|
|
408 |
|
398 |
409 |
-- Replace the primary (f:, r:np, f)
|
399 |
410 |
applyMove nl inst (ReplacePrimary new_pdx) =
|
400 |
411 |
let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
|
... | ... | |
520 |
531 |
|
521 |
532 |
possibleMoves MirrorNone _ _ _ = []
|
522 |
533 |
|
523 |
|
possibleMoves MirrorExternal _ _ _ = []
|
|
534 |
possibleMoves MirrorExternal _ False _ = []
|
|
535 |
|
|
536 |
possibleMoves MirrorExternal _ True tdx =
|
|
537 |
[ FailoverToAny tdx ]
|
524 |
538 |
|
525 |
539 |
possibleMoves MirrorInternal _ False tdx =
|
526 |
540 |
[ ReplaceSecondary tdx ]
|
... | ... | |
1215 |
1229 |
computeMoves i inam mv c d =
|
1216 |
1230 |
case mv of
|
1217 |
1231 |
Failover -> ("f", [mig])
|
|
1232 |
FailoverToAny _ -> (printf "fa:%s" c, [mig_any])
|
1218 |
1233 |
FailoverAndReplace _ -> (printf "f r:%s" d, [mig, rep d])
|
1219 |
1234 |
ReplaceSecondary _ -> (printf "r:%s" d, [rep d])
|
1220 |
1235 |
ReplaceAndFailover _ -> (printf "r:%s f" c, [rep c, mig])
|
1221 |
1236 |
ReplacePrimary _ -> (printf "f r:%s f" c, [mig, rep c, mig])
|
1222 |
1237 |
where morf = if Instance.isRunning i then "migrate" else "failover"
|
1223 |
1238 |
mig = printf "%s -f %s" morf inam::String
|
|
1239 |
mig_any = printf "%s -f -n %s %s" morf c inam
|
1224 |
1240 |
rep n = printf "replace-disks -n %s %s" n inam
|
1225 |
1241 |
|
1226 |
1242 |
-- | Converts a placement to string format.
|
... | ... | |
1374 |
1390 |
iname = Instance.name inst
|
1375 |
1391 |
lookNode = Just . Container.nameOf nl
|
1376 |
1392 |
opF = OpCodes.OpInstanceMigrate iname True False True Nothing
|
|
1393 |
opFA n = OpCodes.OpInstanceMigrate iname True False True (lookNode n)
|
1377 |
1394 |
opR n = OpCodes.OpInstanceReplaceDisks iname (lookNode n)
|
1378 |
1395 |
OpCodes.ReplaceNewSecondary [] Nothing
|
1379 |
1396 |
in case move of
|
1380 |
1397 |
Failover -> [ opF ]
|
|
1398 |
FailoverToAny np -> [ opFA np ]
|
1381 |
1399 |
ReplacePrimary np -> [ opF, opR np, opF ]
|
1382 |
1400 |
ReplaceSecondary ns -> [ opR ns ]
|
1383 |
1401 |
ReplaceAndFailover np -> [ opR np, opF ]
|