Commit 3d7e87b8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Rework/enhance original htools opcodes



The original htools opcodes were minimalistic and not 1:1 equivalent
with the Python ones. Let's add all missing fields and, since we
changed the order, switch to more readable record syntax for building
the opcodes.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3929e782
...@@ -110,15 +110,16 @@ instance Arbitrary OpCodes.OpCode where ...@@ -110,15 +110,16 @@ instance Arbitrary OpCodes.OpCode where
OpCodes.OpTestDelay <$> arbitrary <*> arbitrary <*> OpCodes.OpTestDelay <$> arbitrary <*> arbitrary <*>
genNodeNamesNE <*> arbitrary genNodeNamesNE <*> arbitrary
"OP_INSTANCE_REPLACE_DISKS" -> "OP_INSTANCE_REPLACE_DISKS" ->
OpCodes.OpInstanceReplaceDisks <$> genFQDN <*> OpCodes.OpInstanceReplaceDisks <$> genFQDN <*> arbitrary <*>
genMaybe genNodeNameNE <*> arbitrary <*> genDiskIndices <*> arbitrary <*> arbitrary <*> genDiskIndices <*>
genMaybe genNameNE genMaybe genNodeNameNE <*> genMaybe genNameNE
"OP_INSTANCE_FAILOVER" -> "OP_INSTANCE_FAILOVER" ->
OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*> OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*> arbitrary <*>
genMaybe genNodeNameNE genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNameNE
"OP_INSTANCE_MIGRATE" -> "OP_INSTANCE_MIGRATE" ->
OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*> OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*> arbitrary <*>
arbitrary <*> arbitrary <*> genMaybe genNodeNameNE genMaybe genNodeNameNE <*> arbitrary <*>
arbitrary <*> arbitrary <*> genMaybe genNameNE <*> arbitrary
"OP_TAGS_GET" -> "OP_TAGS_GET" ->
OpCodes.OpTagsGet <$> arbitrary <*> arbitrary OpCodes.OpTagsGet <$> arbitrary <*> arbitrary
"OP_TAGS_SEARCH" -> "OP_TAGS_SEARCH" ->
......
...@@ -1453,11 +1453,26 @@ iMoveToJob nl il idx move = ...@@ -1453,11 +1453,26 @@ iMoveToJob nl il idx move =
Bad msg -> error $ "Empty node name for idx " ++ Bad msg -> error $ "Empty node name for idx " ++
show n ++ ": " ++ msg ++ "??" show n ++ ": " ++ msg ++ "??"
Ok ne -> Just ne Ok ne -> Just ne
live = Just True opF = OpCodes.OpInstanceMigrate
opF = OpCodes.OpInstanceMigrate iname live False True Nothing { OpCodes.opInstanceName = iname
opFA n = OpCodes.OpInstanceMigrate iname live False True (lookNode n) , OpCodes.opMigrationMode = Nothing -- default
opR n = OpCodes.OpInstanceReplaceDisks iname (lookNode n) , OpCodes.opOldLiveMode = Nothing -- default as well
OpCodes.ReplaceNewSecondary [] Nothing , OpCodes.opTargetNode = Nothing -- this is drbd
, OpCodes.opAllowRuntimeChanges = False
, OpCodes.opIgnoreIpolicy = False
, OpCodes.opMigrationCleanup = False
, OpCodes.opIallocator = Nothing
, OpCodes.opAllowFailover = True }
opFA n = opF { OpCodes.opTargetNode = lookNode n } -- not drbd
opR n = OpCodes.OpInstanceReplaceDisks
{ OpCodes.opInstanceName = iname
, OpCodes.opEarlyRelease = False
, OpCodes.opIgnoreIpolicy = False
, OpCodes.opReplaceDisksMode = OpCodes.ReplaceNewSecondary
, OpCodes.opReplaceDisksList = []
, OpCodes.opRemoteNode = lookNode n
, OpCodes.opIallocator = Nothing
}
in case move of in case move of
Failover -> [ opF ] Failover -> [ opF ]
FailoverToAny np -> [ opFA np ] FailoverToAny np -> [ opFA np ]
......
...@@ -59,22 +59,31 @@ $(genOpCode "OpCode" ...@@ -59,22 +59,31 @@ $(genOpCode "OpCode"
]) ])
, ("OpInstanceReplaceDisks", , ("OpInstanceReplaceDisks",
[ pInstanceName [ pInstanceName
, pRemoteNode , pEarlyRelease
, pIgnoreIpolicy
, pReplaceDisksMode , pReplaceDisksMode
, pReplaceDisksList , pReplaceDisksList
, pRemoteNode
, pIallocator , pIallocator
]) ])
, ("OpInstanceFailover", , ("OpInstanceFailover",
[ pInstanceName [ pInstanceName
, pShutdownTimeout
, pIgnoreConsistency , pIgnoreConsistency
, pMigrationTargetNode , pMigrationTargetNode
, pIgnoreIpolicy
, pIallocator
]) ])
, ("OpInstanceMigrate", , ("OpInstanceMigrate",
[ pInstanceName [ pInstanceName
, pMigrationMode
, pMigrationLive , pMigrationLive
, pMigrationTargetNode
, pAllowRuntimeChgs
, pIgnoreIpolicy
, pMigrationCleanup , pMigrationCleanup
, pIallocator
, pAllowFailover , pAllowFailover
, pMigrationTargetNode
]) ])
, ("OpTagsGet", , ("OpTagsGet",
[ pTagsObject [ pTagsObject
......
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