From 10028866d2824702902a9f94176ca5e680be0828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Thu, 7 Apr 2011 12:42:09 +0200 Subject: [PATCH] htools: Make opcode naming consistent with Ganeti codebase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch just cleans up the htools codebase to make it more consistent with the naming of the Ganeti codebase. Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- htools/Ganeti/HTools/Cluster.hs | 4 ++-- htools/Ganeti/HTools/QC.hs | 6 +++--- htools/Ganeti/OpCodes.hs | 24 ++++++++++++------------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs index 17f9085a1..4ad82af23 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 7111a5d15..6f84967fe 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 f16c23014..491ecda78 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) -- GitLab