commit 3d7e87b8830e0b16762827ffd57ad175a6aaef36
Author: Iustin Pop <iustin@google.com>
Date:   Mon Nov 26 16:44:56 2012 +0100

    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: Iustin Pop <iustin@google.com>
    Reviewed-by: Guido Trotter <ultrotter@google.com>

diff --git a/htest/Test/Ganeti/OpCodes.hs b/htest/Test/Ganeti/OpCodes.hs
index 11ab09f..3b17abe 100644
--- a/htest/Test/Ganeti/OpCodes.hs
+++ b/htest/Test/Ganeti/OpCodes.hs
@@ -110,15 +110,16 @@ instance Arbitrary OpCodes.OpCode where
         OpCodes.OpTestDelay <$> arbitrary <*> arbitrary <*>
           genNodeNamesNE <*> arbitrary
       "OP_INSTANCE_REPLACE_DISKS" ->
-        OpCodes.OpInstanceReplaceDisks <$> genFQDN <*>
-          genMaybe genNodeNameNE <*> arbitrary <*> genDiskIndices <*>
-          genMaybe genNameNE
+        OpCodes.OpInstanceReplaceDisks <$> genFQDN <*> arbitrary <*>
+          arbitrary <*> arbitrary <*> genDiskIndices <*>
+          genMaybe genNodeNameNE <*> genMaybe genNameNE
       "OP_INSTANCE_FAILOVER" ->
-        OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*>
-          genMaybe genNodeNameNE
+        OpCodes.OpInstanceFailover <$> genFQDN <*> arbitrary <*> arbitrary <*>
+          genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNameNE
       "OP_INSTANCE_MIGRATE" ->
-        OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*>
-          arbitrary <*> arbitrary <*> genMaybe genNodeNameNE
+        OpCodes.OpInstanceMigrate <$> genFQDN <*> arbitrary <*> arbitrary <*>
+          genMaybe genNodeNameNE <*> arbitrary <*>
+          arbitrary <*> arbitrary <*> genMaybe genNameNE <*> arbitrary
       "OP_TAGS_GET" ->
         OpCodes.OpTagsGet <$> arbitrary <*> arbitrary
       "OP_TAGS_SEARCH" ->
diff --git a/htools/Ganeti/HTools/Cluster.hs b/htools/Ganeti/HTools/Cluster.hs
index 1f15ae9..0cf8a92 100644
--- a/htools/Ganeti/HTools/Cluster.hs
+++ b/htools/Ganeti/HTools/Cluster.hs
@@ -1453,11 +1453,26 @@ iMoveToJob nl il idx move =
                       Bad msg -> error $ "Empty node name for idx " ++
                                  show n ++ ": " ++ msg ++ "??"
                       Ok ne -> Just ne
-      live = Just True
-      opF = OpCodes.OpInstanceMigrate iname live False True Nothing
-      opFA n = OpCodes.OpInstanceMigrate iname live False True (lookNode n)
-      opR n = OpCodes.OpInstanceReplaceDisks iname (lookNode n)
-              OpCodes.ReplaceNewSecondary [] Nothing
+      opF = OpCodes.OpInstanceMigrate
+              { OpCodes.opInstanceName        = iname
+              , OpCodes.opMigrationMode       = Nothing -- default
+              , OpCodes.opOldLiveMode         = Nothing -- default as well
+              , 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
        Failover -> [ opF ]
        FailoverToAny np -> [ opFA np ]
diff --git a/htools/Ganeti/OpCodes.hs b/htools/Ganeti/OpCodes.hs
index 3a77497..e9fd95e 100644
--- a/htools/Ganeti/OpCodes.hs
+++ b/htools/Ganeti/OpCodes.hs
@@ -59,22 +59,31 @@ $(genOpCode "OpCode"
      ])
   , ("OpInstanceReplaceDisks",
      [ pInstanceName
-     , pRemoteNode
+     , pEarlyRelease
+     , pIgnoreIpolicy
      , pReplaceDisksMode
      , pReplaceDisksList
+     , pRemoteNode
      , pIallocator
      ])
   , ("OpInstanceFailover",
      [ pInstanceName
+     , pShutdownTimeout
      , pIgnoreConsistency
      , pMigrationTargetNode
+     , pIgnoreIpolicy
+     , pIallocator
      ])
   , ("OpInstanceMigrate",
      [ pInstanceName
+     , pMigrationMode
      , pMigrationLive
+     , pMigrationTargetNode
+     , pAllowRuntimeChgs
+     , pIgnoreIpolicy
      , pMigrationCleanup
+     , pIallocator
      , pAllowFailover
-     , pMigrationTargetNode
      ])
   , ("OpTagsGet",
      [ pTagsObject
