diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 17f9085a1926b2fe8efac3c54eb7cbc4c48d5c94..4ad82af23914d8bb8143e6515ef5d6c5bb1b0529 100644 --- a/htools/Ganeti/HTools/Cluster.hs +++ b/htools/Ganeti/HTools/Cluster.hs @@ -1042,8 +1042,8 @@ iMoveToJob nl il idx move = let inst = Container.find idx il iname = Instance.name inst lookNode = Just . Container.nameOf nl - opF = OpCodes.OpMigrateInstance iname True False True - opR n = OpCodes.OpReplaceDisks iname (lookNode n) + opF = OpCodes.OpInstanceMigrate iname True False True + opR n = OpCodes.OpInstanceReplaceDisks iname (lookNode n) OpCodes.ReplaceNewSecondary [] Nothing in case move of Failover -> [ opF ] diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index 7111a5d151d6bac91a3973a47f2ee09a805addd7..6f84967fe00384e62b919527891bca7706845c2e 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -222,12 +222,12 @@ instance Arbitrary OpCodes.OpCode where "OP_TEST_DELAY" -> liftM3 OpCodes.OpTestDelay arbitrary arbitrary arbitrary "OP_INSTANCE_REPLACE_DISKS" -> - liftM5 OpCodes.OpReplaceDisks arbitrary arbitrary + liftM5 OpCodes.OpInstanceReplaceDisks arbitrary arbitrary arbitrary arbitrary arbitrary "OP_INSTANCE_FAILOVER" -> - liftM2 OpCodes.OpFailoverInstance arbitrary arbitrary + liftM2 OpCodes.OpInstanceFailover arbitrary arbitrary "OP_INSTANCE_MIGRATE" -> - liftM4 OpCodes.OpMigrateInstance arbitrary arbitrary arbitrary + liftM4 OpCodes.OpInstanceMigrate arbitrary arbitrary arbitrary arbitrary _ -> fail "Wrong opcode") diff --git a/htools/Ganeti/OpCodes.hs b/htools/Ganeti/OpCodes.hs index f16c23014dcaadad70ba8313526186ac6c33f5c5..491ecda78bc900a47af7f25b8fa1b624590a98ae 100644 --- a/htools/Ganeti/OpCodes.hs +++ b/htools/Ganeti/OpCodes.hs @@ -56,18 +56,18 @@ instance JSON ReplaceDisksMode where _ -> J.Error "Can't parse a valid ReplaceDisksMode" data OpCode = OpTestDelay Double Bool [String] - | OpReplaceDisks String (Maybe String) ReplaceDisksMode + | OpInstanceReplaceDisks String (Maybe String) ReplaceDisksMode [Int] (Maybe String) - | OpFailoverInstance String Bool - | OpMigrateInstance String Bool Bool Bool + | OpInstanceFailover String Bool + | OpInstanceMigrate String Bool Bool Bool deriving (Show, Read, Eq) opID :: OpCode -> String opID (OpTestDelay _ _ _) = "OP_TEST_DELAY" -opID (OpReplaceDisks _ _ _ _ _) = "OP_INSTANCE_REPLACE_DISKS" -opID (OpFailoverInstance _ _) = "OP_INSTANCE_FAILOVER" -opID (OpMigrateInstance _ _ _ _) = "OP_INSTANCE_MIGRATE" +opID (OpInstanceReplaceDisks _ _ _ _ _) = "OP_INSTANCE_REPLACE_DISKS" +opID (OpInstanceFailover _ _) = "OP_INSTANCE_FAILOVER" +opID (OpInstanceMigrate _ _ _ _) = "OP_INSTANCE_MIGRATE" loadOpCode :: JSValue -> J.Result OpCode loadOpCode v = do @@ -86,17 +86,17 @@ loadOpCode v = do mode <- extract "mode" disks <- extract "disks" ialloc <- maybeFromObj o "iallocator" - return $ OpReplaceDisks inst node mode disks ialloc + return $ OpInstanceReplaceDisks inst node mode disks ialloc "OP_INSTANCE_FAILOVER" -> do inst <- extract "instance_name" consist <- extract "ignore_consistency" - return $ OpFailoverInstance inst consist + return $ OpInstanceFailover inst consist "OP_INSTANCE_MIGRATE" -> do inst <- extract "instance_name" live <- extract "live" cleanup <- extract "cleanup" allow_failover <- fromObjWithDefault o "allow_failover" False - return $ OpMigrateInstance inst live cleanup allow_failover + return $ OpInstanceMigrate inst live cleanup allow_failover _ -> J.Error $ "Unknown opcode " ++ op_id saveOpCode :: OpCode -> JSValue @@ -107,7 +107,7 @@ saveOpCode op@(OpTestDelay duration on_master on_nodes) = , ("on_nodes", showJSON on_nodes) ] in makeObj ol -saveOpCode op@(OpReplaceDisks inst node mode disks iallocator) = +saveOpCode op@(OpInstanceReplaceDisks inst node mode disks iallocator) = let ol = [ ("OP_ID", showJSON $ opID op) , ("instance_name", showJSON inst) , ("mode", showJSON mode) @@ -120,13 +120,13 @@ saveOpCode op@(OpReplaceDisks inst node mode disks iallocator) = Nothing -> ol2 in makeObj ol3 -saveOpCode op@(OpFailoverInstance inst consist) = +saveOpCode op@(OpInstanceFailover inst consist) = let ol = [ ("OP_ID", showJSON $ opID op) , ("instance_name", showJSON inst) , ("ignore_consistency", showJSON consist) ] in makeObj ol -saveOpCode op@(OpMigrateInstance inst live cleanup allow_failover) = +saveOpCode op@(OpInstanceMigrate inst live cleanup allow_failover) = let ol = [ ("OP_ID", showJSON $ opID op) , ("instance_name", showJSON inst) , ("live", showJSON live)