Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / OpParams.hs @ a3f02317

History | View | Annotate | Download (37.3 kB)

1
{-# LANGUAGE TemplateHaskell #-}
2

    
3
{-| Implementation of opcodes parameters.
4

    
5
These are defined in a separate module only due to TemplateHaskell
6
stage restrictions - expressions defined in the current module can't
7
be passed to splices. So we have to either parameters/repeat each
8
parameter definition multiple times, or separate them into this
9
module.
10

    
11
-}
12

    
13
{-
14

    
15
Copyright (C) 2012 Google Inc.
16

    
17
This program is free software; you can redistribute it and/or modify
18
it under the terms of the GNU General Public License as published by
19
the Free Software Foundation; either version 2 of the License, or
20
(at your option) any later version.
21

    
22
This program is distributed in the hope that it will be useful, but
23
WITHOUT ANY WARRANTY; without even the implied warranty of
24
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
General Public License for more details.
26

    
27
You should have received a copy of the GNU General Public License
28
along with this program; if not, write to the Free Software
29
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30
02110-1301, USA.
31

    
32
-}
33

    
34
module Ganeti.OpParams
35
  ( TagType(..)
36
  , TagObject(..)
37
  , tagObjectFrom
38
  , decodeTagObject
39
  , encodeTagObject
40
  , ReplaceDisksMode(..)
41
  , DiskIndex
42
  , mkDiskIndex
43
  , unDiskIndex
44
  , DiskAccess(..)
45
  , INicParams(..)
46
  , IDiskParams(..)
47
  , RecreateDisksInfo(..)
48
  , DdmOldChanges(..)
49
  , SetParamsMods(..)
50
  , ExportTarget(..)
51
  , pInstanceName
52
  , pInstances
53
  , pName
54
  , pTagsList
55
  , pTagsObject
56
  , pOutputFields
57
  , pShutdownTimeout
58
  , pShutdownTimeout'
59
  , pForce
60
  , pIgnoreOfflineNodes
61
  , pNodeName
62
  , pNodeNames
63
  , pGroupName
64
  , pMigrationMode
65
  , pMigrationLive
66
  , pForceVariant
67
  , pWaitForSync
68
  , pWaitForSyncFalse
69
  , pIgnoreConsistency
70
  , pStorageName
71
  , pUseLocking
72
  , pNameCheck
73
  , pNodeGroupAllocPolicy
74
  , pGroupNodeParams
75
  , pQueryWhat
76
  , pEarlyRelease
77
  , pIpCheck
78
  , pIpConflictsCheck
79
  , pNoRemember
80
  , pMigrationTargetNode
81
  , pMoveTargetNode
82
  , pStartupPaused
83
  , pVerbose
84
  , pDebugSimulateErrors
85
  , pErrorCodes
86
  , pSkipChecks
87
  , pIgnoreErrors
88
  , pOptGroupName
89
  , pDiskParams
90
  , pHvState
91
  , pDiskState
92
  , pIgnoreIpolicy
93
  , pAllowRuntimeChgs
94
  , pInstDisks
95
  , pDiskTemplate
96
  , pFileDriver
97
  , pFileStorageDir
98
  , pVgName
99
  , pEnabledHypervisors
100
  , pHypervisor
101
  , pClusterHvParams
102
  , pInstHvParams
103
  , pClusterBeParams
104
  , pInstBeParams
105
  , pResetDefaults
106
  , pOsHvp
107
  , pClusterOsParams
108
  , pInstOsParams
109
  , pCandidatePoolSize
110
  , pUidPool
111
  , pAddUids
112
  , pRemoveUids
113
  , pMaintainNodeHealth
114
  , pPreallocWipeDisks
115
  , pNicParams
116
  , pInstNics
117
  , pNdParams
118
  , pIpolicy
119
  , pDrbdHelper
120
  , pDefaultIAllocator
121
  , pMasterNetdev
122
  , pMasterNetmask
123
  , pReservedLvs
124
  , pHiddenOs
125
  , pBlacklistedOs
126
  , pUseExternalMipScript
127
  , pQueryFields
128
  , pQueryFilter
129
  , pOobCommand
130
  , pOobTimeout
131
  , pIgnoreStatus
132
  , pPowerDelay
133
  , pPrimaryIp
134
  , pSecondaryIp
135
  , pReadd
136
  , pNodeGroup
137
  , pMasterCapable
138
  , pVmCapable
139
  , pNames
140
  , pNodes
141
  , pRequiredNodes
142
  , pStorageType
143
  , pStorageChanges
144
  , pMasterCandidate
145
  , pOffline
146
  , pDrained
147
  , pAutoPromote
148
  , pPowered
149
  , pIallocator
150
  , pRemoteNode
151
  , pEvacMode
152
  , pInstCreateMode
153
  , pNoInstall
154
  , pInstOs
155
  , pPrimaryNode
156
  , pSecondaryNode
157
  , pSourceHandshake
158
  , pSourceInstance
159
  , pSourceShutdownTimeout
160
  , pSourceX509Ca
161
  , pSrcNode
162
  , pSrcPath
163
  , pStartInstance
164
  , pInstTags
165
  , pMultiAllocInstances
166
  , pTempOsParams
167
  , pTempHvParams
168
  , pTempBeParams
169
  , pIgnoreFailures
170
  , pNewName
171
  , pIgnoreSecondaries
172
  , pRebootType
173
  , pIgnoreDiskSize
174
  , pRecreateDisksInfo
175
  , pStatic
176
  , pInstParamsNicChanges
177
  , pInstParamsDiskChanges
178
  , pRuntimeMem
179
  , pOsNameChange
180
  , pDiskIndex
181
  , pDiskChgAmount
182
  , pDiskChgAbsolute
183
  , pTargetGroups
184
  , pExportMode
185
  , pExportTargetNode
186
  , pRemoveInstance
187
  , pIgnoreRemoveFailures
188
  , pX509KeyName
189
  , pX509DestCA
190
  , pTagSearchPattern
191
  , pDelayRepeat
192
  , pIAllocatorDirection
193
  , pIAllocatorMode
194
  , pIAllocatorReqName
195
  , pIAllocatorNics
196
  , pIAllocatorDisks
197
  , pIAllocatorMemory
198
  , pIAllocatorVCpus
199
  , pIAllocatorOs
200
  , pIAllocatorInstances
201
  , pIAllocatorEvacMode
202
  , pIAllocatorSpindleUse
203
  , pIAllocatorCount
204
  , pJQueueNotifyWaitLock
205
  , pJQueueNotifyExec
206
  , pJQueueLogMessages
207
  , pJQueueFail
208
  , pTestDummyResult
209
  , pTestDummyMessages
210
  , pTestDummyFail
211
  , pTestDummySubmitJobs
212
  ) where
213

    
214
import Control.Monad (liftM)
215
import qualified Data.Set as Set
216
import Text.JSON (readJSON, showJSON, JSON, JSValue(..), fromJSString,
217
                  JSObject, toJSObject)
218
import qualified Text.JSON
219
import Text.JSON.Pretty (pp_value)
220

    
221
import Ganeti.BasicTypes
222
import qualified Ganeti.Constants as C
223
import Ganeti.THH
224
import Ganeti.JSON
225
import Ganeti.Types
226
import qualified Ganeti.Query.Language as Qlang
227

    
228
-- * Helper functions and types
229

    
230
-- * Type aliases
231

    
232
-- | Build a boolean field.
233
booleanField :: String -> Field
234
booleanField = flip simpleField [t| Bool |]
235

    
236
-- | Default a field to 'False'.
237
defaultFalse :: String -> Field
238
defaultFalse = defaultField [| False |] . booleanField
239

    
240
-- | Default a field to 'True'.
241
defaultTrue :: String -> Field
242
defaultTrue = defaultField [| True |] . booleanField
243

    
244
-- | An alias for a 'String' field.
245
stringField :: String -> Field
246
stringField = flip simpleField [t| String |]
247

    
248
-- | An alias for an optional string field.
249
optionalStringField :: String -> Field
250
optionalStringField = optionalField . stringField
251

    
252
-- | An alias for an optional non-empty string field.
253
optionalNEStringField :: String -> Field
254
optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |]
255

    
256
-- | Unchecked value, should be replaced by a better definition.
257
type UncheckedValue = JSValue
258

    
259
-- | Unchecked dict, should be replaced by a better definition.
260
type UncheckedDict = JSObject JSValue
261

    
262
-- | Unchecked list, shoild be replaced by a better definition.
263
type UncheckedList = [JSValue]
264

    
265
-- | Function to force a non-negative value, without returning via a
266
-- monad. This is needed for, and should be used /only/ in the case of
267
-- forcing constants. In case the constant is wrong (< 0), this will
268
-- become a runtime error.
269
forceNonNeg :: (Num a, Ord a, Show a) => a -> NonNegative a
270
forceNonNeg i = case mkNonNegative i of
271
                  Ok n -> n
272
                  Bad msg -> error msg
273

    
274
-- ** Tags
275

    
276
-- | Data type representing what items do the tag operations apply to.
277
$(declareSADT "TagType"
278
  [ ("TagTypeInstance", 'C.tagInstance)
279
  , ("TagTypeNode",     'C.tagNode)
280
  , ("TagTypeGroup",    'C.tagNodegroup)
281
  , ("TagTypeCluster",  'C.tagCluster)
282
  ])
283
$(makeJSONInstance ''TagType)
284

    
285
-- | Data type holding a tag object (type and object name).
286
data TagObject = TagInstance String
287
               | TagNode     String
288
               | TagGroup    String
289
               | TagCluster
290
               deriving (Show, Read, Eq)
291

    
292
-- | Tag type for a given tag object.
293
tagTypeOf :: TagObject -> TagType
294
tagTypeOf (TagInstance {}) = TagTypeInstance
295
tagTypeOf (TagNode     {}) = TagTypeNode
296
tagTypeOf (TagGroup    {}) = TagTypeGroup
297
tagTypeOf (TagCluster  {}) = TagTypeCluster
298

    
299
-- | Gets the potential tag object name.
300
tagNameOf :: TagObject -> Maybe String
301
tagNameOf (TagInstance s) = Just s
302
tagNameOf (TagNode     s) = Just s
303
tagNameOf (TagGroup    s) = Just s
304
tagNameOf  TagCluster     = Nothing
305

    
306
-- | Builds a 'TagObject' from a tag type and name.
307
tagObjectFrom :: (Monad m) => TagType -> JSValue -> m TagObject
308
tagObjectFrom TagTypeInstance (JSString s) =
309
  return . TagInstance $ fromJSString s
310
tagObjectFrom TagTypeNode     (JSString s) = return . TagNode $ fromJSString s
311
tagObjectFrom TagTypeGroup    (JSString s) = return . TagGroup $ fromJSString s
312
tagObjectFrom TagTypeCluster   JSNull      = return TagCluster
313
tagObjectFrom t v =
314
  fail $ "Invalid tag type/name combination: " ++ show t ++ "/" ++
315
         show (pp_value v)
316

    
317
-- | Name of the tag \"name\" field.
318
tagNameField :: String
319
tagNameField = "name"
320

    
321
-- | Custom encoder for 'TagObject' as represented in an opcode.
322
encodeTagObject :: TagObject -> (JSValue, [(String, JSValue)])
323
encodeTagObject t = ( showJSON (tagTypeOf t)
324
                    , [(tagNameField, maybe JSNull showJSON (tagNameOf t))] )
325

    
326
-- | Custom decoder for 'TagObject' as represented in an opcode.
327
decodeTagObject :: (Monad m) => [(String, JSValue)] -> JSValue -> m TagObject
328
decodeTagObject obj kind = do
329
  ttype <- fromJVal kind
330
  tname <- fromObj obj tagNameField
331
  tagObjectFrom ttype tname
332

    
333
-- ** Disks
334

    
335
-- | Replace disks type.
336
$(declareSADT "ReplaceDisksMode"
337
  [ ("ReplaceOnPrimary",    'C.replaceDiskPri)
338
  , ("ReplaceOnSecondary",  'C.replaceDiskSec)
339
  , ("ReplaceNewSecondary", 'C.replaceDiskChg)
340
  , ("ReplaceAuto",         'C.replaceDiskAuto)
341
  ])
342
$(makeJSONInstance ''ReplaceDisksMode)
343

    
344
-- | Disk index type (embedding constraints on the index value via a
345
-- smart constructor).
346
newtype DiskIndex = DiskIndex { unDiskIndex :: Int }
347
  deriving (Show, Read, Eq, Ord)
348

    
349
-- | Smart constructor for 'DiskIndex'.
350
mkDiskIndex :: (Monad m) => Int -> m DiskIndex
351
mkDiskIndex i | i >= 0 && i < C.maxDisks = return (DiskIndex i)
352
              | otherwise = fail $ "Invalid value for disk index '" ++
353
                            show i ++ "', required between 0 and " ++
354
                            show C.maxDisks
355

    
356
instance JSON DiskIndex where
357
  readJSON v = readJSON v >>= mkDiskIndex
358
  showJSON = showJSON . unDiskIndex
359

    
360
-- ** I* param types
361

    
362
-- | Type holding disk access modes.
363
$(declareSADT "DiskAccess"
364
  [ ("DiskReadOnly",  'C.diskRdonly)
365
  , ("DiskReadWrite", 'C.diskRdwr)
366
  ])
367
$(makeJSONInstance ''DiskAccess)
368

    
369
-- | NIC modification definition.
370
$(buildObject "INicParams" "inic"
371
  [ optionalField $ simpleField C.inicMac  [t| NonEmptyString |]
372
  , optionalField $ simpleField C.inicIp   [t| String         |]
373
  , optionalField $ simpleField C.inicMode [t| NonEmptyString |]
374
  , optionalField $ simpleField C.inicLink [t| NonEmptyString |]
375
  ])
376

    
377
-- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT.
378
$(buildObject "IDiskParams" "idisk"
379
  [ optionalField $ simpleField C.idiskSize   [t| Int            |]
380
  , optionalField $ simpleField C.idiskMode   [t| DiskAccess     |]
381
  , optionalField $ simpleField C.idiskAdopt  [t| NonEmptyString |]
382
  , optionalField $ simpleField C.idiskVg     [t| NonEmptyString |]
383
  , optionalField $ simpleField C.idiskMetavg [t| NonEmptyString |]
384
  ])
385

    
386
-- | Disk changes type for OpInstanceRecreateDisks. This is a bit
387
-- strange, because the type in Python is something like Either
388
-- [DiskIndex] [DiskChanges], but we can't represent the type of an
389
-- empty list in JSON, so we have to add a custom case for the empty
390
-- list.
391
data RecreateDisksInfo
392
  = RecreateDisksAll
393
  | RecreateDisksIndices (NonEmpty DiskIndex)
394
  | RecreateDisksParams (NonEmpty (DiskIndex, IDiskParams))
395
    deriving (Eq, Read, Show)
396

    
397
readRecreateDisks :: JSValue -> Text.JSON.Result RecreateDisksInfo
398
readRecreateDisks (JSArray []) = return RecreateDisksAll
399
readRecreateDisks v =
400
  case readJSON v::Text.JSON.Result [DiskIndex] of
401
    Text.JSON.Ok indices -> liftM RecreateDisksIndices (mkNonEmpty indices)
402
    _ -> case readJSON v::Text.JSON.Result [(DiskIndex, IDiskParams)] of
403
           Text.JSON.Ok params -> liftM RecreateDisksParams (mkNonEmpty params)
404
           _ -> fail $ "Can't parse disk information as either list of disk"
405
                ++ " indices or list of disk parameters; value recevied:"
406
                ++ show (pp_value v)
407

    
408
instance JSON RecreateDisksInfo where
409
  readJSON = readRecreateDisks
410
  showJSON  RecreateDisksAll            = showJSON ()
411
  showJSON (RecreateDisksIndices idx)   = showJSON idx
412
  showJSON (RecreateDisksParams params) = showJSON params
413

    
414
-- | Simple type for old-style ddm changes.
415
data DdmOldChanges = DdmOldIndex (NonNegative Int)
416
                   | DdmOldMod DdmSimple
417
                     deriving (Eq, Read, Show)
418

    
419
readDdmOldChanges :: JSValue -> Text.JSON.Result DdmOldChanges
420
readDdmOldChanges v =
421
  case readJSON v::Text.JSON.Result (NonNegative Int) of
422
    Text.JSON.Ok nn -> return $ DdmOldIndex nn
423
    _ -> case readJSON v::Text.JSON.Result DdmSimple of
424
           Text.JSON.Ok ddms -> return $ DdmOldMod ddms
425
           _ -> fail $ "Can't parse value '" ++ show (pp_value v) ++ "' as"
426
                ++ " either index or modification"
427

    
428
instance JSON DdmOldChanges where
429
  showJSON (DdmOldIndex i) = showJSON i
430
  showJSON (DdmOldMod m)   = showJSON m
431
  readJSON = readDdmOldChanges
432

    
433
-- | Instance disk or nic modifications.
434
data SetParamsMods a
435
  = SetParamsEmpty
436
  | SetParamsDeprecated (NonEmpty (DdmOldChanges, a))
437
  | SetParamsNew (NonEmpty (DdmFull, Int, a))
438
    deriving (Eq, Read, Show)
439

    
440
-- | Custom deserialiser for 'SetParamsMods'.
441
readSetParams :: (JSON a) => JSValue -> Text.JSON.Result (SetParamsMods a)
442
readSetParams (JSArray []) = return SetParamsEmpty
443
readSetParams v =
444
  case readJSON v::Text.JSON.Result [(DdmOldChanges, JSValue)] of
445
    Text.JSON.Ok _ -> liftM SetParamsDeprecated $ readJSON v
446
    _ -> liftM SetParamsNew $ readJSON v
447

    
448
instance (JSON a) => JSON (SetParamsMods a) where
449
  showJSON SetParamsEmpty = showJSON ()
450
  showJSON (SetParamsDeprecated v) = showJSON v
451
  showJSON (SetParamsNew v) = showJSON v
452
  readJSON = readSetParams
453

    
454
-- | Custom type for target_node parameter of OpBackupExport, which
455
-- varies depending on mode. FIXME: this uses an UncheckedList since
456
-- we don't care about individual rows (just like the Python code
457
-- tests). But the proper type could be parsed if we wanted.
458
data ExportTarget = ExportTargetLocal NonEmptyString
459
                  | ExportTargetRemote UncheckedList
460
                    deriving (Eq, Read, Show)
461

    
462
-- | Custom reader for 'ExportTarget'.
463
readExportTarget :: JSValue -> Text.JSON.Result ExportTarget
464
readExportTarget (JSString s) = liftM ExportTargetLocal $
465
                                mkNonEmpty (fromJSString s)
466
readExportTarget (JSArray arr) = return $ ExportTargetRemote arr
467
readExportTarget v = fail $ "Invalid value received for 'target_node': " ++
468
                     show (pp_value v)
469

    
470
instance JSON ExportTarget where
471
  showJSON (ExportTargetLocal s)  = showJSON s
472
  showJSON (ExportTargetRemote l) = showJSON l
473
  readJSON = readExportTarget
474

    
475
-- * Parameters
476

    
477
-- | A required instance name (for single-instance LUs).
478
pInstanceName :: Field
479
pInstanceName = simpleField "instance_name" [t| String |]
480

    
481
-- | A list of instances.
482
pInstances :: Field
483
pInstances = defaultField [| [] |] $
484
             simpleField "instances" [t| [NonEmptyString] |]
485

    
486
-- | A generic name.
487
pName :: Field
488
pName = simpleField "name" [t| NonEmptyString |]
489

    
490
-- | Tags list.
491
pTagsList :: Field
492
pTagsList = simpleField "tags" [t| [String] |]
493

    
494
-- | Tags object.
495
pTagsObject :: Field
496
pTagsObject = customField 'decodeTagObject 'encodeTagObject $
497
              simpleField "kind" [t| TagObject |]
498

    
499
-- | Selected output fields.
500
pOutputFields :: Field
501
pOutputFields = simpleField "output_fields" [t| [NonEmptyString] |]
502

    
503
-- | How long to wait for instance to shut down.
504
pShutdownTimeout :: Field
505
pShutdownTimeout = defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
506
                   simpleField "shutdown_timeout" [t| NonNegative Int |]
507

    
508
-- | Another name for the shutdown timeout, because we like to be
509
-- inconsistent.
510
pShutdownTimeout' :: Field
511
pShutdownTimeout' =
512
  renameField "InstShutdownTimeout" .
513
  defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
514
  simpleField "timeout" [t| NonNegative Int |]
515

    
516
-- | Whether to force the operation.
517
pForce :: Field
518
pForce = defaultFalse "force"
519

    
520
-- | Whether to ignore offline nodes.
521
pIgnoreOfflineNodes :: Field
522
pIgnoreOfflineNodes = defaultFalse "ignore_offline_nodes"
523

    
524
-- | A required node name (for single-node LUs).
525
pNodeName :: Field
526
pNodeName = simpleField "node_name" [t| NonEmptyString |]
527

    
528
-- | List of nodes.
529
pNodeNames :: Field
530
pNodeNames =
531
  defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |]
532

    
533
-- | A required node group name (for single-group LUs).
534
pGroupName :: Field
535
pGroupName = simpleField "group_name" [t| NonEmptyString |]
536

    
537
-- | Migration type (live\/non-live).
538
pMigrationMode :: Field
539
pMigrationMode =
540
  renameField "MigrationMode" .
541
  optionalField $
542
  simpleField "mode" [t| MigrationMode |]
543

    
544
-- | Obsolete \'live\' migration mode (boolean).
545
pMigrationLive :: Field
546
pMigrationLive =
547
  renameField "OldLiveMode" . optionalField $ booleanField "live"
548

    
549
-- | Whether to force an unknown OS variant.
550
pForceVariant :: Field
551
pForceVariant = defaultFalse "force_variant"
552

    
553
-- | Whether to wait for the disk to synchronize.
554
pWaitForSync :: Field
555
pWaitForSync = defaultTrue "wait_for_sync"
556

    
557
-- | Whether to wait for the disk to synchronize (defaults to false).
558
pWaitForSyncFalse :: Field
559
pWaitForSyncFalse = defaultField [| False |] pWaitForSync
560

    
561
-- | Whether to ignore disk consistency
562
pIgnoreConsistency :: Field
563
pIgnoreConsistency = defaultFalse "ignore_consistency"
564

    
565
-- | Storage name.
566
pStorageName :: Field
567
pStorageName =
568
  renameField "StorageName" $ simpleField "name" [t| NonEmptyString |]
569

    
570
-- | Whether to use synchronization.
571
pUseLocking :: Field
572
pUseLocking = defaultFalse "use_locking"
573

    
574
-- | Whether to check name.
575
pNameCheck :: Field
576
pNameCheck = defaultTrue "name_check"
577

    
578
-- | Instance allocation policy.
579
pNodeGroupAllocPolicy :: Field
580
pNodeGroupAllocPolicy = optionalField $
581
                        simpleField "alloc_policy" [t| AllocPolicy |]
582

    
583
-- | Default node parameters for group.
584
pGroupNodeParams :: Field
585
pGroupNodeParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |]
586

    
587
-- | Resource(s) to query for.
588
pQueryWhat :: Field
589
pQueryWhat = simpleField "what" [t| Qlang.QueryTypeOp |]
590

    
591
-- | Whether to release locks as soon as possible.
592
pEarlyRelease :: Field
593
pEarlyRelease = defaultFalse "early_release"
594

    
595
-- | Whether to ensure instance's IP address is inactive.
596
pIpCheck :: Field
597
pIpCheck = defaultTrue "ip_check"
598

    
599
-- | Check for conflicting IPs.
600
pIpConflictsCheck :: Field
601
pIpConflictsCheck = defaultTrue "conflicts_check"
602

    
603
-- | Do not remember instance state changes.
604
pNoRemember :: Field
605
pNoRemember = defaultFalse "no_remember"
606

    
607
-- | Target node for instance migration/failover.
608
pMigrationTargetNode :: Field
609
pMigrationTargetNode = optionalNEStringField "target_node"
610

    
611
-- | Target node for instance move (required).
612
pMoveTargetNode :: Field
613
pMoveTargetNode =
614
  renameField "MoveTargetNode" $
615
  simpleField "target_node" [t| NonEmptyString |]
616

    
617
-- | Pause instance at startup.
618
pStartupPaused :: Field
619
pStartupPaused = defaultFalse "startup_paused"
620

    
621
-- | Verbose mode.
622
pVerbose :: Field
623
pVerbose = defaultFalse "verbose"
624

    
625
-- ** Parameters for cluster verification
626

    
627
-- | Whether to simulate errors (useful for debugging).
628
pDebugSimulateErrors :: Field
629
pDebugSimulateErrors = defaultFalse "debug_simulate_errors"
630

    
631
-- | Error codes.
632
pErrorCodes :: Field
633
pErrorCodes = defaultFalse "error_codes"
634

    
635
-- | Which checks to skip.
636
pSkipChecks :: Field
637
pSkipChecks = defaultField [| Set.empty |] $
638
              simpleField "skip_checks" [t| Set.Set VerifyOptionalChecks |]
639

    
640
-- | List of error codes that should be treated as warnings.
641
pIgnoreErrors :: Field
642
pIgnoreErrors = defaultField [| Set.empty |] $
643
                simpleField "ignore_errors" [t| Set.Set CVErrorCode |]
644

    
645
-- | Optional group name.
646
pOptGroupName :: Field
647
pOptGroupName = renameField "OptGroupName" .
648
                optionalField $ simpleField "group_name" [t| NonEmptyString |]
649

    
650
-- | Disk templates' parameter defaults.
651
pDiskParams :: Field
652
pDiskParams = optionalField $
653
              simpleField "diskparams" [t| GenericContainer DiskTemplate
654
                                           UncheckedDict |]
655

    
656
-- * Parameters for node resource model
657

    
658
-- | Set hypervisor states.
659
pHvState :: Field
660
pHvState = optionalField $ simpleField "hv_state" [t| UncheckedDict |]
661

    
662
-- | Set disk states.
663
pDiskState :: Field
664
pDiskState = optionalField $ simpleField "disk_state" [t| UncheckedDict |]
665

    
666
-- | Whether to ignore ipolicy violations.
667
pIgnoreIpolicy :: Field
668
pIgnoreIpolicy = defaultFalse "ignore_ipolicy"
669

    
670
-- | Allow runtime changes while migrating.
671
pAllowRuntimeChgs :: Field
672
pAllowRuntimeChgs = defaultTrue "allow_runtime_changes"
673

    
674
-- | Utility type for OpClusterSetParams.
675
type TestClusterOsListItem = (DdmSimple, NonEmptyString)
676

    
677
-- | Utility type of OsList.
678
type TestClusterOsList = [TestClusterOsListItem]
679

    
680
-- Utility type for NIC definitions.
681
--type TestNicDef = INicParams
682

    
683
-- | List of instance disks.
684
pInstDisks :: Field
685
pInstDisks = renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |]
686

    
687
-- | Instance disk template.
688
pDiskTemplate :: Field
689
pDiskTemplate = simpleField "disk_template" [t| DiskTemplate |]
690

    
691
-- | File driver.
692
pFileDriver :: Field
693
pFileDriver = optionalField $ simpleField "file_driver" [t| FileDriver |]
694

    
695
-- | Directory for storing file-backed disks.
696
pFileStorageDir :: Field
697
pFileStorageDir = optionalNEStringField "file_storage_dir"
698

    
699
-- | Volume group name.
700
pVgName :: Field
701
pVgName = optionalStringField "vg_name"
702

    
703
-- | List of enabled hypervisors.
704
pEnabledHypervisors :: Field
705
pEnabledHypervisors =
706
  optionalField $
707
  simpleField "enabled_hypervisors" [t| NonEmpty Hypervisor |]
708

    
709
-- | Selected hypervisor for an instance.
710
pHypervisor :: Field
711
pHypervisor =
712
  optionalField $
713
  simpleField "hypervisor" [t| Hypervisor |]
714

    
715
-- | Cluster-wide hypervisor parameters, hypervisor-dependent.
716
pClusterHvParams :: Field
717
pClusterHvParams =
718
  renameField "ClusterHvParams" .
719
  optionalField $
720
  simpleField "hvparams" [t| Container UncheckedDict |]
721

    
722
-- | Instance hypervisor parameters.
723
pInstHvParams :: Field
724
pInstHvParams =
725
  renameField "InstHvParams" .
726
  defaultField [| toJSObject [] |] $
727
  simpleField "hvparams" [t| UncheckedDict |]
728

    
729
-- | Cluster-wide beparams.
730
pClusterBeParams :: Field
731
pClusterBeParams =
732
  renameField "ClusterBeParams" .
733
  optionalField $ simpleField "beparams" [t| UncheckedDict |]
734

    
735
-- | Instance beparams.
736
pInstBeParams :: Field
737
pInstBeParams =
738
  renameField "InstBeParams" .
739
  defaultField [| toJSObject [] |] $
740
  simpleField "beparams" [t| UncheckedDict |]
741

    
742
-- | Reset instance parameters to default if equal.
743
pResetDefaults :: Field
744
pResetDefaults = defaultFalse "identify_defaults"
745

    
746
-- | Cluster-wide per-OS hypervisor parameter defaults.
747
pOsHvp :: Field
748
pOsHvp = optionalField $ simpleField "os_hvp" [t| Container UncheckedDict |]
749

    
750
-- | Cluster-wide OS parameter defaults.
751
pClusterOsParams :: Field
752
pClusterOsParams =
753
  renameField "ClusterOsParams" .
754
  optionalField $ simpleField "osparams" [t| Container UncheckedDict |]
755

    
756
-- | Instance OS parameters.
757
pInstOsParams :: Field
758
pInstOsParams =
759
  renameField "InstOsParams" . defaultField [| toJSObject [] |] $
760
  simpleField "osparams" [t| UncheckedDict |]
761

    
762
-- | Temporary OS parameters (currently only in reinstall, might be
763
-- added to install as well).
764
pTempOsParams :: Field
765
pTempOsParams =
766
  renameField "TempOsParams" .
767
  optionalField $ simpleField "osparams" [t| UncheckedDict |]
768

    
769
-- | Temporary hypervisor parameters, hypervisor-dependent.
770
pTempHvParams :: Field
771
pTempHvParams =
772
  renameField "TempHvParams" .
773
  defaultField [| toJSObject [] |] $
774
  simpleField "hvparams" [t| UncheckedDict |]
775

    
776
-- | Temporary backend parameters.
777
pTempBeParams :: Field
778
pTempBeParams =
779
  renameField "TempBeParams" .
780
  defaultField [| toJSObject [] |] $
781
  simpleField "beparams" [t| UncheckedDict |]
782

    
783
-- | Candidate pool size.
784
pCandidatePoolSize :: Field
785
pCandidatePoolSize =
786
  optionalField $ simpleField "candidate_pool_size" [t| Positive Int |]
787

    
788
-- | Set UID pool, must be list of lists describing UID ranges (two
789
-- items, start and end inclusive.
790
pUidPool :: Field
791
pUidPool = optionalField $ simpleField "uid_pool" [t| [[(Int, Int)]] |]
792

    
793
-- | Extend UID pool, must be list of lists describing UID ranges (two
794
-- items, start and end inclusive.
795
pAddUids :: Field
796
pAddUids = optionalField $ simpleField "add_uids" [t| [[(Int, Int)]] |]
797

    
798
-- | Shrink UID pool, must be list of lists describing UID ranges (two
799
-- items, start and end inclusive) to be removed.
800
pRemoveUids :: Field
801
pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |]
802

    
803
-- | Whether to automatically maintain node health.
804
pMaintainNodeHealth :: Field
805
pMaintainNodeHealth = optionalField $ booleanField "maintain_node_health"
806

    
807
-- | Whether to wipe disks before allocating them to instances.
808
pPreallocWipeDisks :: Field
809
pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks"
810

    
811
-- | Cluster-wide NIC parameter defaults.
812
pNicParams :: Field
813
pNicParams = optionalField $ simpleField "nicparams" [t| INicParams |]
814

    
815
-- | Instance NIC definitions.
816
pInstNics :: Field
817
pInstNics = simpleField "nics" [t| [INicParams] |]
818

    
819
-- | Cluster-wide node parameter defaults.
820
pNdParams :: Field
821
pNdParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |]
822

    
823
-- | Cluster-wide ipolicy specs.
824
pIpolicy :: Field
825
pIpolicy = optionalField $ simpleField "ipolicy" [t| UncheckedDict |]
826

    
827
-- | DRBD helper program.
828
pDrbdHelper :: Field
829
pDrbdHelper = optionalStringField "drbd_helper"
830

    
831
-- | Default iallocator for cluster.
832
pDefaultIAllocator :: Field
833
pDefaultIAllocator = optionalStringField "default_iallocator"
834

    
835
-- | Master network device.
836
pMasterNetdev :: Field
837
pMasterNetdev = optionalStringField "master_netdev"
838

    
839
-- | Netmask of the master IP.
840
pMasterNetmask :: Field
841
pMasterNetmask = optionalField $ simpleField "master_netmask" [t| Int |]
842

    
843
-- | List of reserved LVs.
844
pReservedLvs :: Field
845
pReservedLvs =
846
  optionalField $ simpleField "reserved_lvs" [t| [NonEmptyString] |]
847

    
848
-- | Modify list of hidden operating systems: each modification must
849
-- have two items, the operation and the OS name; the operation can be
850
-- add or remove.
851
pHiddenOs :: Field
852
pHiddenOs = optionalField $ simpleField "hidden_os" [t| TestClusterOsList |]
853

    
854
-- | Modify list of blacklisted operating systems: each modification
855
-- must have two items, the operation and the OS name; the operation
856
-- can be add or remove.
857
pBlacklistedOs :: Field
858
pBlacklistedOs =
859
  optionalField $ simpleField "blacklisted_os" [t| TestClusterOsList |]
860

    
861
-- | Whether to use an external master IP address setup script.
862
pUseExternalMipScript :: Field
863
pUseExternalMipScript = optionalField $ booleanField "use_external_mip_script"
864

    
865
-- | Requested fields.
866
pQueryFields :: Field
867
pQueryFields = simpleField "fields" [t| [NonEmptyString] |]
868

    
869
-- | Query filter.
870
pQueryFilter :: Field
871
pQueryFilter = simpleField "qfilter" [t| Qlang.Filter String |]
872

    
873
-- | OOB command to run.
874
pOobCommand :: Field
875
pOobCommand = simpleField "command" [t| OobCommand |]
876

    
877
-- | Timeout before the OOB helper will be terminated.
878
pOobTimeout :: Field
879
pOobTimeout =
880
  defaultField [| C.oobTimeout |] $ simpleField "timeout" [t| Int |]
881

    
882
-- | Ignores the node offline status for power off.
883
pIgnoreStatus :: Field
884
pIgnoreStatus = defaultFalse "ignore_status"
885

    
886
-- | Time in seconds to wait between powering on nodes.
887
pPowerDelay :: Field
888
pPowerDelay =
889
  -- FIXME: we can't use the proper type "NonNegative Double", since
890
  -- the default constant is a plain Double, not a non-negative one.
891
  defaultField [| C.oobPowerDelay |] $
892
  simpleField "power_delay" [t| Double |]
893

    
894
-- | Primary IP address.
895
pPrimaryIp :: Field
896
pPrimaryIp = optionalStringField "primary_ip"
897

    
898
-- | Secondary IP address.
899
pSecondaryIp :: Field
900
pSecondaryIp = optionalNEStringField "secondary_ip"
901

    
902
-- | Whether node is re-added to cluster.
903
pReadd :: Field
904
pReadd = defaultFalse "readd"
905

    
906
-- | Initial node group.
907
pNodeGroup :: Field
908
pNodeGroup = optionalNEStringField "group"
909

    
910
-- | Whether node can become master or master candidate.
911
pMasterCapable :: Field
912
pMasterCapable = optionalField $ booleanField "master_capable"
913

    
914
-- | Whether node can host instances.
915
pVmCapable :: Field
916
pVmCapable = optionalField $ booleanField "vm_capable"
917

    
918
-- | List of names.
919
pNames :: Field
920
pNames = defaultField [| [] |] $ simpleField "names" [t| [NonEmptyString] |]
921

    
922
-- | List of node names.
923
pNodes :: Field
924
pNodes = defaultField [| [] |] $ simpleField "nodes" [t| [NonEmptyString] |]
925

    
926
-- | Required list of node names.
927
pRequiredNodes :: Field
928
pRequiredNodes =
929
  renameField "ReqNodes " $ simpleField "nodes" [t| [NonEmptyString] |]
930

    
931
-- | Storage type.
932
pStorageType :: Field
933
pStorageType = simpleField "storage_type" [t| StorageType |]
934

    
935
-- | Storage changes (unchecked).
936
pStorageChanges :: Field
937
pStorageChanges = simpleField "changes" [t| UncheckedDict |]
938

    
939
-- | Whether the node should become a master candidate.
940
pMasterCandidate :: Field
941
pMasterCandidate = optionalField $ booleanField "master_candidate"
942

    
943
-- | Whether the node should be marked as offline.
944
pOffline :: Field
945
pOffline = optionalField $ booleanField "offline"
946

    
947
-- | Whether the node should be marked as drained.
948
pDrained ::Field
949
pDrained = optionalField $ booleanField "drained"
950

    
951
-- | Whether node(s) should be promoted to master candidate if necessary.
952
pAutoPromote :: Field
953
pAutoPromote = defaultFalse "auto_promote"
954

    
955
-- | Whether the node should be marked as powered
956
pPowered :: Field
957
pPowered = optionalField $ booleanField "powered"
958

    
959
-- | Iallocator for deciding the target node for shared-storage
960
-- instances during migrate and failover.
961
pIallocator :: Field
962
pIallocator = optionalNEStringField "iallocator"
963

    
964
-- | New secondary node.
965
pRemoteNode :: Field
966
pRemoteNode = optionalNEStringField "remote_node"
967

    
968
-- | Node evacuation mode.
969
pEvacMode :: Field
970
pEvacMode = renameField "EvacMode" $ simpleField "mode" [t| NodeEvacMode |]
971

    
972
-- | Instance creation mode.
973
pInstCreateMode :: Field
974
pInstCreateMode =
975
  renameField "InstCreateMode" $ simpleField "mode" [t| InstCreateMode |]
976

    
977
-- | Do not install the OS (will disable automatic start).
978
pNoInstall :: Field
979
pNoInstall = optionalField $ booleanField "no_install"
980

    
981
-- | OS type for instance installation.
982
pInstOs :: Field
983
pInstOs = optionalNEStringField "os_type"
984

    
985
-- | Primary node for an instance.
986
pPrimaryNode :: Field
987
pPrimaryNode = optionalNEStringField "pnode"
988

    
989
-- | Secondary node for an instance.
990
pSecondaryNode :: Field
991
pSecondaryNode = optionalNEStringField "snode"
992

    
993
-- | Signed handshake from source (remote import only).
994
pSourceHandshake :: Field
995
pSourceHandshake =
996
  optionalField $ simpleField "source_handshake" [t| UncheckedList |]
997

    
998
-- | Source instance name (remote import only).
999
pSourceInstance :: Field
1000
pSourceInstance = optionalNEStringField "source_instance_name"
1001

    
1002
-- | How long source instance was given to shut down (remote import only).
1003
-- FIXME: non-negative int, whereas the constant is a plain int.
1004
pSourceShutdownTimeout :: Field
1005
pSourceShutdownTimeout =
1006
  defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
1007
  simpleField "source_shutdown_timeout" [t| NonNegative Int |]
1008

    
1009
-- | Source X509 CA in PEM format (remote import only).
1010
pSourceX509Ca :: Field
1011
pSourceX509Ca = optionalNEStringField "source_x509_ca"
1012

    
1013
-- | Source node for import.
1014
pSrcNode :: Field
1015
pSrcNode = optionalNEStringField "src_node"
1016

    
1017
-- | Source directory for import.
1018
pSrcPath :: Field
1019
pSrcPath = optionalNEStringField "src_path"
1020

    
1021
-- | Whether to start instance after creation.
1022
pStartInstance :: Field
1023
pStartInstance = defaultTrue "start"
1024

    
1025
-- | Instance tags. FIXME: unify/simplify with pTags, once that
1026
-- migrates to NonEmpty String.
1027
pInstTags :: Field
1028
pInstTags =
1029
  renameField "InstTags" .
1030
  defaultField [| [] |] $
1031
  simpleField "tags" [t| [NonEmptyString] |]
1032

    
1033
-- | Unchecked list of OpInstanceCreate, used in OpInstanceMultiAlloc.
1034
pMultiAllocInstances :: Field
1035
pMultiAllocInstances =
1036
  renameField "InstMultiAlloc" .
1037
  defaultField [| [] |] $
1038
  simpleField "instances"[t| UncheckedList |]
1039

    
1040
-- | Ignore failures parameter.
1041
pIgnoreFailures :: Field
1042
pIgnoreFailures = defaultFalse "ignore_failures"
1043

    
1044
-- | New instance or cluster name.
1045
pNewName :: Field
1046
pNewName = simpleField "new_name" [t| NonEmptyString |]
1047

    
1048
-- | Whether to start the instance even if secondary disks are failing.
1049
pIgnoreSecondaries :: Field
1050
pIgnoreSecondaries = defaultFalse "ignore_secondaries"
1051

    
1052
-- | How to reboot the instance.
1053
pRebootType :: Field
1054
pRebootType = simpleField "reboot_type" [t| RebootType |]
1055

    
1056
-- | Whether to ignore recorded disk size.
1057
pIgnoreDiskSize :: Field
1058
pIgnoreDiskSize = defaultFalse "ignore_size"
1059

    
1060
-- | Disk list for recreate disks.
1061
pRecreateDisksInfo :: Field
1062
pRecreateDisksInfo =
1063
  renameField "RecreateDisksInfo" .
1064
  defaultField [| RecreateDisksAll |] $
1065
  simpleField "disks" [t| RecreateDisksInfo |]
1066

    
1067
-- | Whether to only return configuration data without querying nodes.
1068
pStatic :: Field
1069
pStatic = defaultFalse "static"
1070

    
1071
-- | InstanceSetParams NIC changes.
1072
pInstParamsNicChanges :: Field
1073
pInstParamsNicChanges =
1074
  renameField "InstNicChanges" .
1075
  defaultField [| SetParamsEmpty |] $
1076
  simpleField "nics" [t| SetParamsMods INicParams |]
1077

    
1078
-- | InstanceSetParams Disk changes.
1079
pInstParamsDiskChanges :: Field
1080
pInstParamsDiskChanges =
1081
  renameField "InstDiskChanges" .
1082
  defaultField [| SetParamsEmpty |] $
1083
  simpleField "disks" [t| SetParamsMods IDiskParams |]
1084

    
1085
-- | New runtime memory.
1086
pRuntimeMem :: Field
1087
pRuntimeMem = optionalField $ simpleField "runtime_mem" [t| Positive Int |]
1088

    
1089
-- | Change the instance's OS without reinstalling the instance
1090
pOsNameChange :: Field
1091
pOsNameChange = optionalNEStringField "os_name"
1092

    
1093
-- | Disk index for e.g. grow disk.
1094
pDiskIndex :: Field
1095
pDiskIndex = renameField "DiskIndex " $ simpleField "disk" [t| DiskIndex |]
1096

    
1097
-- | Disk amount to add or grow to.
1098
pDiskChgAmount :: Field
1099
pDiskChgAmount =
1100
  renameField "DiskChgAmount" $ simpleField "amount" [t| NonNegative Int |]
1101

    
1102
-- | Whether the amount parameter is an absolute target or a relative one.
1103
pDiskChgAbsolute :: Field
1104
pDiskChgAbsolute = renameField "DiskChkAbsolute" $ defaultFalse "absolute"
1105

    
1106
-- | Destination group names or UUIDs (defaults to \"all but current group\".
1107
pTargetGroups :: Field
1108
pTargetGroups =
1109
  optionalField $ simpleField "target_groups" [t| [NonEmptyString] |]
1110

    
1111
-- | Export mode field.
1112
pExportMode :: Field
1113
pExportMode =
1114
  renameField "ExportMode" $ simpleField "mode" [t| ExportMode |]
1115

    
1116
-- | Export target_node field, depends on mode.
1117
pExportTargetNode :: Field
1118
pExportTargetNode =
1119
  renameField "ExportTarget" $
1120
  simpleField "target_node" [t| ExportTarget |]
1121

    
1122
-- | Whether to remove instance after export.
1123
pRemoveInstance :: Field
1124
pRemoveInstance = defaultFalse "remove_instance"
1125

    
1126
-- | Whether to ignore failures while removing instances.
1127
pIgnoreRemoveFailures :: Field
1128
pIgnoreRemoveFailures = defaultFalse "ignore_remove_failures"
1129

    
1130
-- | Name of X509 key (remote export only).
1131
pX509KeyName :: Field
1132
pX509KeyName = optionalField $ simpleField "x509_key_name" [t| UncheckedList |]
1133

    
1134
-- | Destination X509 CA (remote export only).
1135
pX509DestCA :: Field
1136
pX509DestCA = optionalNEStringField "destination_x509_ca"
1137

    
1138
-- | Search pattern (regular expression). FIXME: this should be
1139
-- compiled at load time?
1140
pTagSearchPattern :: Field
1141
pTagSearchPattern =
1142
  renameField "TagSearchPattern" $ simpleField "pattern" [t| NonEmptyString |]
1143

    
1144
-- * Test opcode parameters
1145

    
1146
-- | Repeat parameter for OpTestDelay.
1147
pDelayRepeat :: Field
1148
pDelayRepeat =
1149
  renameField "DelayRepeat" .
1150
  defaultField [| forceNonNeg (0::Int) |] $
1151
  simpleField "repeat" [t| NonNegative Int |]
1152

    
1153
-- | IAllocator test direction.
1154
pIAllocatorDirection :: Field
1155
pIAllocatorDirection =
1156
  renameField "IAllocatorDirection" $
1157
  simpleField "direction" [t| IAllocatorTestDir |]
1158

    
1159
-- | IAllocator test mode.
1160
pIAllocatorMode :: Field
1161
pIAllocatorMode =
1162
  renameField "IAllocatorMode" $
1163
  simpleField "mode" [t| IAllocatorMode |]
1164

    
1165
-- | IAllocator target name (new instance, node to evac, etc.).
1166
pIAllocatorReqName :: Field
1167
pIAllocatorReqName =
1168
  renameField "IAllocatorReqName" $ simpleField "name" [t| NonEmptyString |]
1169

    
1170
-- | Custom OpTestIAllocator nics.
1171
pIAllocatorNics :: Field
1172
pIAllocatorNics =
1173
  renameField "IAllocatorNics" $ simpleField "nics" [t| [UncheckedDict] |]
1174

    
1175
-- | Custom OpTestAllocator disks.
1176
pIAllocatorDisks :: Field
1177
pIAllocatorDisks =
1178
  renameField "IAllocatorDisks" $ simpleField "disks" [t| UncheckedList |]
1179

    
1180
-- | IAllocator memory field.
1181
pIAllocatorMemory :: Field
1182
pIAllocatorMemory =
1183
  renameField "IAllocatorMem" .
1184
  optionalField $
1185
  simpleField "memory" [t| NonNegative Int |]
1186

    
1187
-- | IAllocator vcpus field.
1188
pIAllocatorVCpus :: Field
1189
pIAllocatorVCpus =
1190
  renameField "IAllocatorVCpus" .
1191
  optionalField $
1192
  simpleField "vcpus" [t| NonNegative Int |]
1193

    
1194
-- | IAllocator os field.
1195
pIAllocatorOs :: Field
1196
pIAllocatorOs = renameField "IAllocatorOs" $ optionalNEStringField "os"
1197

    
1198
-- | IAllocator instances field.
1199
pIAllocatorInstances :: Field
1200
pIAllocatorInstances =
1201
  renameField "IAllocatorInstances " .
1202
  optionalField $
1203
  simpleField "instances" [t| [NonEmptyString] |]
1204

    
1205
-- | IAllocator evac mode.
1206
pIAllocatorEvacMode :: Field
1207
pIAllocatorEvacMode =
1208
  renameField "IAllocatorEvacMode" .
1209
  optionalField $
1210
  simpleField "evac_mode" [t| NodeEvacMode |]
1211

    
1212
-- | IAllocator spindle use.
1213
pIAllocatorSpindleUse :: Field
1214
pIAllocatorSpindleUse =
1215
  renameField "IAllocatorSpindleUse" .
1216
  defaultField [| forceNonNeg (1::Int) |] $
1217
  simpleField "spindle_use" [t| NonNegative Int |]
1218

    
1219
-- | IAllocator count field.
1220
pIAllocatorCount :: Field
1221
pIAllocatorCount =
1222
  renameField "IAllocatorCount" .
1223
  defaultField [| forceNonNeg (1::Int) |] $
1224
  simpleField "count" [t| NonNegative Int |]
1225

    
1226
-- | 'OpTestJqueue' notify_waitlock.
1227
pJQueueNotifyWaitLock :: Field
1228
pJQueueNotifyWaitLock = defaultFalse "notify_waitlock"
1229

    
1230
-- | 'OpTestJQueue' notify_exec.
1231
pJQueueNotifyExec :: Field
1232
pJQueueNotifyExec = defaultFalse "notify_exec"
1233

    
1234
-- | 'OpTestJQueue' log_messages.
1235
pJQueueLogMessages :: Field
1236
pJQueueLogMessages =
1237
  defaultField [| [] |] $ simpleField "log_messages" [t| [String] |]
1238

    
1239
-- | 'OpTestJQueue' fail attribute.
1240
pJQueueFail :: Field
1241
pJQueueFail =
1242
  renameField "JQueueFail" $ defaultFalse "fail"
1243

    
1244
-- | 'OpTestDummy' result field.
1245
pTestDummyResult :: Field
1246
pTestDummyResult =
1247
  renameField "TestDummyResult" $ simpleField "result" [t| UncheckedValue |]
1248

    
1249
-- | 'OpTestDummy' messages field.
1250
pTestDummyMessages :: Field
1251
pTestDummyMessages =
1252
  renameField "TestDummyMessages" $
1253
  simpleField "messages" [t| UncheckedValue |]
1254

    
1255
-- | 'OpTestDummy' fail field.
1256
pTestDummyFail :: Field
1257
pTestDummyFail =
1258
  renameField "TestDummyFail" $ simpleField "fail" [t| UncheckedValue |]
1259

    
1260
-- | 'OpTestDummy' submit_jobs field.
1261
pTestDummySubmitJobs :: Field
1262
pTestDummySubmitJobs =
1263
  renameField "TestDummySubmitJobs" $
1264
  simpleField "submit_jobs" [t| UncheckedValue |]