Commit 516a0e94 authored by Michele Tartara's avatar Michele Tartara
Browse files

Add reason trail to haskell opcode format



The haskell type definition of opcodes should remain aligned with the python
one.
Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 3ff890a1
......@@ -626,6 +626,7 @@ $(buildObject "CommonOpParams" "op"
, pOpPriority
, pDependencies
, pComment
, pReason
])
-- | Default common parameter values.
......@@ -636,6 +637,7 @@ defOpParams =
, opPriority = OpPrioNormal
, opDepends = Nothing
, opComment = Nothing
, opReason = []
}
-- | The top-level opcode type.
......
......@@ -236,6 +236,7 @@ module Ganeti.OpParams
, pOpPriority
, pDependencies
, pComment
, pReason
, pEnabledDiskTemplates
, dOldQuery
, dOldQueryNoLocking
......@@ -1444,6 +1445,10 @@ pDependencies =
pComment :: Field
pComment = optionalNullSerField $ stringField "comment"
-- | Reason trail field.
pReason :: Field
pReason = simpleField C.opcodeReason [t| ReasonTrail |]
-- * Entire opcode parameter list
-- | Old-style query opcode, with locking.
......
......@@ -342,9 +342,20 @@ instance Arbitrary OpCodes.OpCode where
genNameNE
_ -> fail $ "Undefined arbitrary for opcode " ++ op_id
-- | Generates one element of a reason trail
genReasonElem :: Gen ReasonElem
genReasonElem = (,,) <$> genFQDN <*> genFQDN <*> arbitrary
-- | Generates a reason trail
genReasonTrail :: Gen ReasonTrail
genReasonTrail = do
size <- choose (0, 10)
vectorOf size genReasonElem
instance Arbitrary OpCodes.CommonOpParams where
arbitrary = OpCodes.CommonOpParams <$> arbitrary <*> arbitrary <*>
arbitrary <*> resize 5 arbitrary <*> genMaybe genName
arbitrary <*> resize 5 arbitrary <*> genMaybe genName <*>
genReasonTrail
-- * Helper functions
......
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