Commit 10028866 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

htools: Make opcode naming consistent with Ganeti codebase



This patch just cleans up the htools codebase to make it more consistent
with the naming of the Ganeti codebase.
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent af7b6689
......@@ -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 ]
......
......@@ -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")
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment