Revision 34af39e8

b/lib/build/sphinx_ext.py
164 164
    if include is not None and name not in include:
165 165
      continue
166 166

  
167
    has_default = default is not ht.NoDefault
168
    has_test = not (test is None or test is ht.NoType)
167
    has_default = default is not None or default is not ht.NoDefault
168
    has_test = test is not None or test is not ht.NoType
169 169

  
170 170
    buf = StringIO()
171 171
    buf.write("``%s``" % (rapi_name,))
b/lib/cmdlib/instance_operation.py
184 184

  
185 185
    """
186 186
    env = BuildInstanceHookEnvByObject(self, self.instance)
187
    env["TIMEOUT"] = self.op.timeout
187
    env["SHUTDOWN_TIMEOUT"] = self.op.shutdown_timeout
188 188
    return env
189 189

  
190 190
  def BuildHooksNodes(self):
......
230 230
      assert self.op.ignore_offline_nodes
231 231
      self.LogInfo("Primary node offline, marked instance as stopped")
232 232
    else:
233
      result = self.rpc.call_instance_shutdown(self.instance.primary_node,
234
                                               self.instance,
235
                                               self.op.timeout, self.op.reason)
233
      result = self.rpc.call_instance_shutdown(
234
        self.instance.primary_node,
235
        self.instance,
236
        self.op.shutdown_timeout, self.op.reason)
236 237
      msg = result.fail_msg
237 238
      if msg:
238 239
        self.LogWarning("Could not shutdown instance: %s", msg)
b/src/Ganeti/Luxi.hs
144 144
    )
145 145
  , (luxiReqQueryClusterInfo, [])
146 146
  , (luxiReqQueryTags,
147
     [ pTagsObject ])
147
     [ pTagsObject 
148
     , simpleField "name" [t| String |]
149
     ])
148 150
  , (luxiReqSubmitJob,
149 151
     [ simpleField "job" [t| [MetaOpCode] |] ]
150 152
    )
......
399 401
              return $ QueryConfigValues fields
400 402
    ReqQueryTags -> do
401 403
              (kind, name) <- fromJVal args
402
              item <- tagObjectFrom kind name
403
              return $ QueryTags item
404
              return $ QueryTags kind name
404 405
    ReqCancelJob -> do
405 406
              [jid] <- fromJVal args
406 407
              return $ CancelJob jid
b/src/Ganeti/OpCodes.hs
1
{-# LANGUAGE TemplateHaskell #-}
1
{-# LANGUAGE ExistentialQuantification, TemplateHaskell #-}
2
{-# OPTIONS_GHC -fno-warn-orphans #-}
2 3

  
3 4
{-| Implementation of the opcodes.
4 5

  
......
26 27
-}
27 28

  
28 29
module Ganeti.OpCodes
29
  ( OpCode(..)
30
  ( pyClasses
31
  , OpCode(..)
30 32
  , TagObject(..)
31 33
  , tagObjectFrom
32 34
  , encodeTagObject
......
47 49
  , setOpPriority
48 50
  ) where
49 51

  
50
import Data.Maybe (fromMaybe)
51
import Text.JSON (readJSON, JSON, JSValue, makeObj)
52
import Text.JSON (readJSON, JSObject, JSON, JSValue(..), makeObj, fromJSObject)
52 53
import qualified Text.JSON
53 54

  
54 55
import Ganeti.THH
55 56

  
57
import qualified Ganeti.Hs2Py.OpDoc as OpDoc
56 58
import Ganeti.OpParams
57
import Ganeti.Types (OpSubmitPriority(..), fromNonEmpty)
59
import Ganeti.Types
58 60
import Ganeti.Query.Language (queryTypeOpToRaw)
59 61

  
62
import Data.List (intercalate)
63
import Data.Map (Map)
64
import qualified Data.Map as Map
65
import Data.Set (Set)
66
import qualified Data.Set as Set
67

  
68
import qualified Ganeti.Constants as C
69

  
70
instance PyValue Bool
71
instance PyValue Int
72
instance PyValue Double
73
instance PyValue Char
74

  
75
instance (PyValue a, PyValue b) => PyValue (a, b) where
76
  showValue (x, y) = show (showValue x, showValue y)
77

  
78
instance PyValue a => PyValue [a] where
79
  showValue xs = show (map showValue xs)
80

  
81
instance PyValue a => PyValue (Set a) where
82
  showValue s = showValue (Set.toList s)
83

  
84
instance (PyValue k, PyValue a) => PyValue (Map k a) where
85
  showValue mp =
86
    "{" ++ intercalate ", " (map showPair (Map.assocs mp)) ++ "}"
87
    where showPair (k, x) = show k ++ ":" ++ show x
88

  
89
instance PyValue DiskIndex where
90
  showValue = showValue . unDiskIndex
91

  
92
instance PyValue IDiskParams where
93
  showValue _ = error "OpCodes.showValue(IDiskParams): unhandled case"
94

  
95
instance PyValue RecreateDisksInfo where
96
  showValue RecreateDisksAll = "[]"
97
  showValue (RecreateDisksIndices is) = showValue is
98
  showValue (RecreateDisksParams is) = showValue is
99

  
100
instance PyValue a => PyValue (SetParamsMods a) where
101
  showValue SetParamsEmpty = "[]"
102
  showValue _ = error "OpCodes.showValue(SetParamsMods): unhandled case"
103

  
104
instance PyValue a => PyValue (NonNegative a) where
105
  showValue = showValue . fromNonNegative
106
  
107
instance PyValue a => PyValue (NonEmpty a) where
108
  showValue = showValue . fromNonEmpty
109
  
110
-- FIXME: should use the 'toRaw' function instead of being harcoded or
111
-- perhaps use something similar to the NonNegative type instead of
112
-- using the declareSADT
113
instance PyValue ExportMode where
114
  showValue ExportModeLocal = show C.exportModeLocal
115
  showValue ExportModeRemove = show C.exportModeLocal
116

  
117
instance PyValue CVErrorCode where
118
  showValue = cVErrorCodeToRaw
119
  
120
instance PyValue VerifyOptionalChecks where
121
  showValue = verifyOptionalChecksToRaw
122

  
123
instance PyValue INicParams where
124
  showValue = error "instance PyValue INicParams: not implemented"
125

  
126
instance PyValue a => PyValue (JSObject a) where
127
  showValue obj =
128
    "{" ++ intercalate ", " (map showPair (fromJSObject obj)) ++ "}"
129
    where showPair (k, v) = show k ++ ":" ++ showValue v
130

  
131
instance PyValue JSValue where
132
  showValue (JSObject obj) = showValue obj
133
  showValue x = show x
134

  
135
type JobIdListOnly = [(Bool, Either String JobId)]
136

  
137
type InstanceMultiAllocResponse =
138
  ([(Bool, Either String JobId)], NonEmptyString)
139

  
140
type QueryFieldDef =
141
  (NonEmptyString, NonEmptyString, TagKind, NonEmptyString)
142

  
143
type QueryResponse =
144
  ([QueryFieldDef], [[(QueryResultCode, JSValue)]])
145

  
146
type QueryFieldsResponse = [QueryFieldDef]
147

  
60 148
-- | OpCode representation.
61 149
--
62 150
-- We only implement a subset of Ganeti opcodes: those which are actually used
63 151
-- in the htools codebase.
64 152
$(genOpCode "OpCode"
65
  [ ("OpTestDelay",
66
     [ pDelayDuration
67
     , pDelayOnMaster
68
     , pDelayOnNodes
69
     , pDelayOnNodeUuids
70
     , pDelayRepeat
71
     ])
72
  , ("OpInstanceReplaceDisks",
73
     [ pInstanceName
74
     , pInstanceUuid
75
     , pEarlyRelease
76
     , pIgnoreIpolicy
77
     , pReplaceDisksMode
78
     , pReplaceDisksList
79
     , pRemoteNode
80
     , pRemoteNodeUuid
81
     , pIallocator
82
     ])
83
  , ("OpInstanceFailover",
84
     [ pInstanceName
85
     , pInstanceUuid
86
     , pShutdownTimeout
87
     , pIgnoreConsistency
88
     , pMigrationTargetNode
89
     , pMigrationTargetNodeUuid
90
     , pIgnoreIpolicy
91
     , pIallocator
92
     ])
93
  , ("OpInstanceMigrate",
94
     [ pInstanceName
95
     , pInstanceUuid
96
     , pMigrationMode
97
     , pMigrationLive
98
     , pMigrationTargetNode
99
     , pMigrationTargetNodeUuid
100
     , pAllowRuntimeChgs
101
     , pIgnoreIpolicy
102
     , pMigrationCleanup
103
     , pIallocator
104
     , pAllowFailover
105
     ])
106
  , ("OpTagsGet",
107
     [ pTagsObject
108
     , pUseLocking
109
     ])
110
  , ("OpTagsSearch",
111
     [ pTagSearchPattern ])
112
  , ("OpTagsSet",
113
     [ pTagsObject
114
     , pTagsList
115
     ])
116
  , ("OpTagsDel",
117
     [ pTagsObject
118
     , pTagsList
119
     ])
120
  , ("OpClusterPostInit", [])
121
  , ("OpClusterDestroy", [])
122
  , ("OpClusterQuery", [])
153
  [ ("OpClusterPostInit",
154
     [t| Bool |],
155
     OpDoc.opClusterPostInit,
156
     [],
157
     [])
158
  , ("OpClusterDestroy",
159
     [t| NonEmptyString |],
160
     OpDoc.opClusterDestroy,
161
     [],
162
     [])
163
  , ("OpClusterQuery",
164
     [t| JSObject JSValue |],
165
     OpDoc.opClusterQuery,
166
     [],
167
     [])
123 168
  , ("OpClusterVerify",
169
     [t| JobIdListOnly |],
170
     OpDoc.opClusterVerify,
124 171
     [ pDebugSimulateErrors
125 172
     , pErrorCodes
126 173
     , pSkipChecks
127 174
     , pIgnoreErrors
128 175
     , pVerbose
129 176
     , pOptGroupName
130
     ])
177
     ],
178
     [])
131 179
  , ("OpClusterVerifyConfig",
180
     [t| Bool |],
181
     OpDoc.opClusterVerifyConfig,
132 182
     [ pDebugSimulateErrors
133 183
     , pErrorCodes
134 184
     , pIgnoreErrors
135 185
     , pVerbose
136
     ])
186
     ],
187
     [])
137 188
  , ("OpClusterVerifyGroup",
189
     [t| Bool |],
190
     OpDoc.opClusterVerifyGroup,
138 191
     [ pGroupName
139 192
     , pDebugSimulateErrors
140 193
     , pErrorCodes
141 194
     , pSkipChecks
142 195
     , pIgnoreErrors
143 196
     , pVerbose
144
     ])
145
  , ("OpClusterVerifyDisks", [])
197
     ],
198
     "group_name")
199
  , ("OpClusterVerifyDisks",
200
     [t| JobIdListOnly |],
201
     OpDoc.opClusterVerifyDisks,
202
     [],
203
     [])
146 204
  , ("OpGroupVerifyDisks",
205
     [t| (Map String String, [String], Map String [[String]]) |],
206
     OpDoc.opGroupVerifyDisks,
147 207
     [ pGroupName
148
     ])
208
     ],
209
     "group_name")
149 210
  , ("OpClusterRepairDiskSizes",
211
     [t| [(NonEmptyString, NonNegative Int, NonEmptyString, NonNegative Int)]|],
212
     OpDoc.opClusterRepairDiskSizes,
150 213
     [ pInstances
151
     ])
214
     ],
215
     [])
152 216
  , ("OpClusterConfigQuery",
217
     [t| [JSValue] |],
218
     OpDoc.opClusterConfigQuery,
153 219
     [ pOutputFields
154
     ])
220
     ],
221
     [])
155 222
  , ("OpClusterRename",
223
      [t| NonEmptyString |],
224
      OpDoc.opClusterRename,
156 225
     [ pName
157
     ])
226
     ],
227
     "name")
158 228
  , ("OpClusterSetParams",
229
     [t| () |],
230
     OpDoc.opClusterSetParams,
159 231
     [ pForce
160 232
     , pHvState
161 233
     , pDiskState
......
173 245
     , pMaintainNodeHealth
174 246
     , pPreallocWipeDisks
175 247
     , pNicParams
176
     , pNdParams
177
     , pIpolicy
248
     , withDoc "Cluster-wide node parameter defaults" pNdParams
249
     , withDoc "Cluster-wide ipolicy specs" pIpolicy
178 250
     , pDrbdHelper
179 251
     , pDefaultIAllocator
180 252
     , pMasterNetdev
......
186 258
     , pEnabledDiskTemplates
187 259
     , pModifyEtcHosts
188 260
     , pGlobalFileStorageDir
189
     ])
190
  , ("OpClusterRedistConf", [])
191
  , ("OpClusterActivateMasterIp", [])
192
  , ("OpClusterDeactivateMasterIp", [])
261
     ],
262
     [])
263
  , ("OpClusterRedistConf",
264
     [t| () |],
265
     OpDoc.opClusterRedistConf,
266
     [],
267
     [])
268
  , ("OpClusterActivateMasterIp",
269
     [t| () |],
270
     OpDoc.opClusterActivateMasterIp,
271
     [],
272
     [])
273
  , ("OpClusterDeactivateMasterIp",
274
     [t| () |],
275
     OpDoc.opClusterDeactivateMasterIp,
276
     [],
277
     [])
193 278
  , ("OpQuery",
279
     [t| QueryResponse |],
280
     OpDoc.opQuery,
194 281
     [ pQueryWhat
195 282
     , pUseLocking
196 283
     , pQueryFields
197 284
     , pQueryFilter
198
     ])
285
     ],
286
     "what")
199 287
  , ("OpQueryFields",
288
     [t| QueryFieldsResponse |],
289
     OpDoc.opQueryFields,
200 290
     [ pQueryWhat
201
     , pQueryFields
202
     ])
291
     , pQueryFieldsFields
292
     ],
293
     "what")
203 294
  , ("OpOobCommand",
295
     [t| [[(QueryResultCode, JSValue)]] |],
296
     OpDoc.opOobCommand,
204 297
     [ pNodeNames
205
     , pNodeUuids
298
     , withDoc "List of node UUIDs to run the OOB command against" pNodeUuids
206 299
     , pOobCommand
207 300
     , pOobTimeout
208 301
     , pIgnoreStatus
209 302
     , pPowerDelay
210
     ])
303
     ],
304
     [])
305
  , ("OpRestrictedCommand",
306
     [t| [(Bool, String)] |],
307
     OpDoc.opRestrictedCommand,
308
     [ pUseLocking
309
     , withDoc
310
       "Nodes on which the command should be run (at least one)"
311
       pRequiredNodes
312
     , withDoc
313
       "Node UUIDs on which the command should be run (at least one)"
314
       pRequiredNodeUuids
315
     , pRestrictedCommand
316
     ],
317
     [])
211 318
  , ("OpNodeRemove",
319
     [t| () |],
320
      OpDoc.opNodeRemove,
212 321
     [ pNodeName
213 322
     , pNodeUuid
214
     ])
323
     ],
324
     "node_name")
215 325
  , ("OpNodeAdd",
326
     [t| () |],
327
      OpDoc.opNodeAdd,
216 328
     [ pNodeName
217 329
     , pHvState
218 330
     , pDiskState
......
223 335
     , pMasterCapable
224 336
     , pVmCapable
225 337
     , pNdParams
226
    ])
227
  , ("OpNodeQuery", dOldQuery)
338
     ],
339
     "node_name")
340
  , ("OpNodeQuery",
341
     [t| [[JSValue]] |],
342
     OpDoc.opNodeQuery,
343
     [ pOutputFields
344
     , withDoc "Empty list to query all nodes, node names otherwise" pNames
345
     , pUseLocking
346
     ],
347
     [])
228 348
  , ("OpNodeQueryvols",
349
     [t| [JSValue] |],
350
     OpDoc.opNodeQueryvols,
229 351
     [ pOutputFields
230
     , pNodes
231
     ])
352
     , withDoc "Empty list to query all nodes, node names otherwise" pNodes
353
     ],
354
     [])
232 355
  , ("OpNodeQueryStorage",
356
     [t| [[JSValue]] |],
357
     OpDoc.opNodeQueryStorage,
233 358
     [ pOutputFields
234 359
     , pStorageType
235
     , pNodes
360
     , withDoc
361
       "Empty list to query all, list of names to query otherwise"
362
       pNodes
236 363
     , pStorageName
237
     ])
364
     ],
365
     [])
238 366
  , ("OpNodeModifyStorage",
367
     [t| () |],
368
     OpDoc.opNodeModifyStorage,
239 369
     [ pNodeName
240 370
     , pNodeUuid
241 371
     , pStorageType
242 372
     , pStorageName
243 373
     , pStorageChanges
244
     ])
374
     ],
375
     "node_name")
245 376
  , ("OpRepairNodeStorage",
377
      [t| () |],
378
      OpDoc.opRepairNodeStorage,
246 379
     [ pNodeName
247 380
     , pNodeUuid
248 381
     , pStorageType
249 382
     , pStorageName
250 383
     , pIgnoreConsistency
251
     ])
384
     ],
385
     "node_name")
252 386
  , ("OpNodeSetParams",
387
     [t| [(NonEmptyString, JSValue)] |],
388
     OpDoc.opNodeSetParams,
253 389
     [ pNodeName
254 390
     , pNodeUuid
255 391
     , pForce
256 392
     , pHvState
257 393
     , pDiskState
258 394
     , pMasterCandidate
259
     , pOffline
395
     , withDoc "Whether to mark the node offline" pOffline
260 396
     , pDrained
261 397
     , pAutoPromote
262 398
     , pMasterCapable
......
264 400
     , pSecondaryIp
265 401
     , pNdParams
266 402
     , pPowered
267
     ])
403
     ],
404
     "node_name")
268 405
  , ("OpNodePowercycle",
406
     [t| Maybe NonEmptyString |],
407
     OpDoc.opNodePowercycle,
269 408
     [ pNodeName
270 409
     , pNodeUuid
271 410
     , pForce
272
     ])
411
     ],
412
     "node_name")
273 413
  , ("OpNodeMigrate",
414
     [t| JobIdListOnly |],
415
     OpDoc.opNodeMigrate,
274 416
     [ pNodeName
275 417
     , pNodeUuid
276 418
     , pMigrationMode
......
280 422
     , pAllowRuntimeChgs
281 423
     , pIgnoreIpolicy
282 424
     , pIallocator
283
     ])
425
     ],
426
     "node_name")
284 427
  , ("OpNodeEvacuate",
428
     [t| JobIdListOnly |],
429
     OpDoc.opNodeEvacuate,
285 430
     [ pEarlyRelease
286 431
     , pNodeName
287 432
     , pNodeUuid
......
289 434
     , pRemoteNodeUuid
290 435
     , pIallocator
291 436
     , pEvacMode
292
     ])
437
     ],
438
     "node_name")
293 439
  , ("OpInstanceCreate",
440
     [t| [NonEmptyString] |],
441
     OpDoc.opInstanceCreate,
294 442
     [ pInstanceName
295 443
     , pForceVariant
296 444
     , pWaitForSync
297 445
     , pNameCheck
298 446
     , pIgnoreIpolicy
447
     , pOpportunisticLocking
299 448
     , pInstBeParams
300 449
     , pInstDisks
301 450
     , pDiskTemplate
......
324 473
     , pSrcNodeUuid
325 474
     , pSrcPath
326 475
     , pStartInstance
327
     , pOpportunisticLocking
328 476
     , pInstTags
329
     ])
477
     ],
478
     "instance_name")
330 479
  , ("OpInstanceMultiAlloc",
331
     [ pIallocator
480
     [t| InstanceMultiAllocResponse |],
481
     OpDoc.opInstanceMultiAlloc,
482
     [ pOpportunisticLocking
483
     , pIallocator
332 484
     , pMultiAllocInstances
333
     , pOpportunisticLocking
334
     ])
485
     ],
486
     [])
335 487
  , ("OpInstanceReinstall",
488
     [t| () |],
489
     OpDoc.opInstanceReinstall,
336 490
     [ pInstanceName
337 491
     , pInstanceUuid
338 492
     , pForceVariant
339 493
     , pInstOs
340 494
     , pTempOsParams
341
     ])
495
     ],
496
     "instance_name")
342 497
  , ("OpInstanceRemove",
498
     [t| () |],
499
     OpDoc.opInstanceRemove,
343 500
     [ pInstanceName
344 501
     , pInstanceUuid
345 502
     , pShutdownTimeout
346 503
     , pIgnoreFailures
347
     ])
504
     ],
505
     "instance_name")
348 506
  , ("OpInstanceRename",
507
     [t| NonEmptyString |],
508
     OpDoc.opInstanceRename,
349 509
     [ pInstanceName
350 510
     , pInstanceUuid
351
     , pNewName
511
     , withDoc "New instance name" pNewName
352 512
     , pNameCheck
353 513
     , pIpCheck
354
     ])
514
     ],
515
     [])
355 516
  , ("OpInstanceStartup",
517
     [t| () |],
518
     OpDoc.opInstanceStartup,
356 519
     [ pInstanceName
357 520
     , pInstanceUuid
358 521
     , pForce
......
361 524
     , pTempBeParams
362 525
     , pNoRemember
363 526
     , pStartupPaused
364
     ])
527
     ],
528
     "instance_name")
365 529
  , ("OpInstanceShutdown",
530
     [t| () |],
531
     OpDoc.opInstanceShutdown,
366 532
     [ pInstanceName
367 533
     , pInstanceUuid
368 534
     , pForce
369 535
     , pIgnoreOfflineNodes
370
     , pShutdownTimeout'
536
     , pShutdownTimeout
371 537
     , pNoRemember
372
     ])
538
     ],
539
     "instance_name")
373 540
  , ("OpInstanceReboot",
541
     [t| () |],
542
     OpDoc.opInstanceReboot,
374 543
     [ pInstanceName
375 544
     , pInstanceUuid
376 545
     , pShutdownTimeout
377 546
     , pIgnoreSecondaries
378 547
     , pRebootType
379
     ])
548
     ],
549
     "instance_name")
550
  , ("OpInstanceReplaceDisks",
551
     [t| () |],
552
     OpDoc.opInstanceReplaceDisks,
553
     [ pInstanceName
554
     , pInstanceUuid
555
     , pEarlyRelease
556
     , pIgnoreIpolicy
557
     , pReplaceDisksMode
558
     , pReplaceDisksList
559
     , pRemoteNode
560
     , pRemoteNodeUuid
561
     , pIallocator
562
     ],
563
     "instance_name")
564
  , ("OpInstanceFailover",
565
     [t| () |],
566
     OpDoc.opInstanceFailover,
567
     [ pInstanceName
568
     , pInstanceUuid
569
     , pShutdownTimeout
570
     , pIgnoreConsistency
571
     , pMigrationTargetNode
572
     , pMigrationTargetNodeUuid
573
     , pIgnoreIpolicy
574
     , pIallocator
575
     ],
576
     "instance_name")
577
  , ("OpInstanceMigrate",
578
     [t| () |],
579
     OpDoc.opInstanceMigrate,
580
     [ pInstanceName
581
     , pInstanceUuid
582
     , pMigrationMode
583
     , pMigrationLive
584
     , pMigrationTargetNode
585
     , pMigrationTargetNodeUuid
586
     , pAllowRuntimeChgs
587
     , pIgnoreIpolicy
588
     , pMigrationCleanup
589
     , pIallocator
590
     , pAllowFailover
591
     ],
592
     "instance_name")
380 593
  , ("OpInstanceMove",
594
     [t| () |],
595
     OpDoc.opInstanceMove,
381 596
     [ pInstanceName
382 597
     , pInstanceUuid
383 598
     , pShutdownTimeout
......
385 600
     , pMoveTargetNode
386 601
     , pMoveTargetNodeUuid
387 602
     , pIgnoreConsistency
388
     ])
603
     ],
604
     "instance_name")
389 605
  , ("OpInstanceConsole",
606
     [t| JSObject JSValue |],
607
     OpDoc.opInstanceConsole,
390 608
     [ pInstanceName
391 609
     , pInstanceUuid
392
     ])
610
     ],
611
     "instance_name")
393 612
  , ("OpInstanceActivateDisks",
613
     [t| [(NonEmptyString, NonEmptyString, NonEmptyString)] |],
614
     OpDoc.opInstanceActivateDisks,
394 615
     [ pInstanceName
395 616
     , pInstanceUuid
396 617
     , pIgnoreDiskSize
397 618
     , pWaitForSyncFalse
398
     ])
619
     ],
620
     "instance_name")
399 621
  , ("OpInstanceDeactivateDisks",
622
     [t| () |],
623
     OpDoc.opInstanceDeactivateDisks,
400 624
     [ pInstanceName
401 625
     , pInstanceUuid
402 626
     , pForce
403
     ])
627
     ],
628
     "instance_name")
404 629
  , ("OpInstanceRecreateDisks",
630
     [t| () |],
631
     OpDoc.opInstanceRecreateDisks,
405 632
     [ pInstanceName
406 633
     , pInstanceUuid
407 634
     , pRecreateDisksInfo
408
     , pNodes
409
     , pNodeUuids
635
     , withDoc "New instance nodes, if relocation is desired" pNodes
636
     , withDoc "New instance node UUIDs, if relocation is desired" pNodeUuids
410 637
     , pIallocator
411
     ])
412
  , ("OpInstanceQuery", dOldQuery)
638
     ],
639
     "instance_name")
640
  , ("OpInstanceQuery",
641
     [t| [[JSValue]] |],
642
     OpDoc.opInstanceQuery,
643
     [ pOutputFields
644
     , pUseLocking
645
     , withDoc
646
       "Empty list to query all instances, instance names otherwise"
647
       pNames
648
     ],
649
     [])
413 650
  , ("OpInstanceQueryData",
651
     [t| JSObject (JSObject JSValue) |],
652
     OpDoc.opInstanceQueryData,
414 653
     [ pUseLocking
415 654
     , pInstances
416 655
     , pStatic
417
     ])
656
     ],
657
     [])
418 658
  , ("OpInstanceSetParams",
659
      [t| [(NonEmptyString, JSValue)] |],
660
      OpDoc.opInstanceSetParams,
419 661
     [ pInstanceName
420 662
     , pInstanceUuid
421 663
     , pForce
......
429 671
     , pOptDiskTemplate
430 672
     , pPrimaryNode
431 673
     , pPrimaryNodeUuid
432
     , pRemoteNode
433
     , pRemoteNodeUuid
674
     , withDoc "Secondary node (used when changing disk template)" pRemoteNode
675
     , withDoc
676
       "Secondary node UUID (used when changing disk template)"
677
       pRemoteNodeUuid
434 678
     , pOsNameChange
435 679
     , pInstOsParams
436 680
     , pWaitForSync
437
     , pOffline
681
     , withDoc "Whether to mark the instance as offline" pOffline
438 682
     , pIpConflictsCheck
439
     ])
683
     ],
684
     "instance_name")
440 685
  , ("OpInstanceGrowDisk",
686
     [t| () |],
687
     OpDoc.opInstanceGrowDisk,
441 688
     [ pInstanceName
442 689
     , pInstanceUuid
443 690
     , pWaitForSync
444 691
     , pDiskIndex
445 692
     , pDiskChgAmount
446 693
     , pDiskChgAbsolute
447
     ])
694
     ],
695
     "instance_name")
448 696
  , ("OpInstanceChangeGroup",
697
     [t| JobIdListOnly |],
698
     OpDoc.opInstanceChangeGroup,
449 699
     [ pInstanceName
450 700
     , pInstanceUuid
451 701
     , pEarlyRelease
452 702
     , pIallocator
453 703
     , pTargetGroups
454
     ])
704
     ],
705
     "instance_name")
455 706
  , ("OpGroupAdd",
707
     [t| () |],
708
     OpDoc.opGroupAdd,
456 709
     [ pGroupName
457 710
     , pNodeGroupAllocPolicy
458 711
     , pGroupNodeParams
459 712
     , pDiskParams
460 713
     , pHvState
461 714
     , pDiskState
462
     , pIpolicy
463
     ])
715
     , withDoc "Group-wide ipolicy specs" pIpolicy
716
     ],
717
     "group_name")
464 718
  , ("OpGroupAssignNodes",
719
     [t| () |],
720
     OpDoc.opGroupAssignNodes,
465 721
     [ pGroupName
466 722
     , pForce
467
     , pRequiredNodes
468
     , pRequiredNodeUuids
469
     ])
470
  , ("OpGroupQuery", dOldQueryNoLocking)
723
     , withDoc "List of nodes to assign" pRequiredNodes
724
     , withDoc "List of node UUIDs to assign" pRequiredNodeUuids
725
     ],
726
     "group_name")
727
  , ("OpGroupQuery",
728
     [t| [[JSValue]] |],
729
     OpDoc.opGroupQuery,
730
     [ pOutputFields
731
     , withDoc "Empty list to query all groups, group names otherwise" pNames
732
     ],
733
     [])
471 734
  , ("OpGroupSetParams",
735
     [t| [(NonEmptyString, JSValue)] |],
736
     OpDoc.opGroupSetParams,
472 737
     [ pGroupName
473 738
     , pNodeGroupAllocPolicy
474 739
     , pGroupNodeParams
475 740
     , pDiskParams
476 741
     , pHvState
477 742
     , pDiskState
478
     , pIpolicy
479
     ])
743
     , withDoc "Group-wide ipolicy specs" pIpolicy
744
     ],
745
     "group_name")
480 746
  , ("OpGroupRemove",
481
     [ pGroupName ])
747
     [t| () |],
748
     OpDoc.opGroupRemove,
749
     [ pGroupName
750
     ],
751
     "group_name")
482 752
  , ("OpGroupRename",
753
     [t| NonEmptyString |],
754
     OpDoc.opGroupRename,
483 755
     [ pGroupName
484
     , pNewName
485
     ])
756
     , withDoc "New group name" pNewName
757
     ],
758
     [])
486 759
  , ("OpGroupEvacuate",
760
     [t| JobIdListOnly |],
761
     OpDoc.opGroupEvacuate,
487 762
     [ pGroupName
488 763
     , pEarlyRelease
489 764
     , pIallocator
490 765
     , pTargetGroups
491
     ])
766
     ],
767
     "group_name")
492 768
  , ("OpOsDiagnose",
769
     [t| [[JSValue]] |],
770
     OpDoc.opOsDiagnose,
493 771
     [ pOutputFields
494
     , pNames ])
772
     , withDoc "Which operating systems to diagnose" pNames
773
     ],
774
     [])
495 775
  , ("OpExtStorageDiagnose",
776
     [t| [[JSValue]] |],
777
     OpDoc.opExtStorageDiagnose,
496 778
     [ pOutputFields
497
     , pNames ])
779
     , withDoc "Which ExtStorage Provider to diagnose" pNames
780
     ],
781
     [])
498 782
  , ("OpBackupQuery",
783
     [t| JSObject (Either Bool [NonEmptyString]) |],
784
     OpDoc.opBackupQuery,
499 785
     [ pUseLocking
500
     , pNodes
501
     ])
786
     , withDoc "Empty list to query all nodes, node names otherwise" pNodes
787
     ],
788
     [])
502 789
  , ("OpBackupPrepare",
790
     [t| Maybe (JSObject JSValue) |],
791
     OpDoc.opBackupPrepare,
503 792
     [ pInstanceName
504 793
     , pInstanceUuid
505 794
     , pExportMode
506
     ])
795
     ],
796
     "instance_name")
507 797
  , ("OpBackupExport",
798
     [t| (Bool, [Bool]) |],
799
     OpDoc.opBackupExport,
508 800
     [ pInstanceName
509 801
     , pInstanceUuid
510 802
     , pShutdownTimeout
......
513 805
     , pShutdownInstance
514 806
     , pRemoveInstance
515 807
     , pIgnoreRemoveFailures
516
     , pExportMode
808
     , defaultField [| ExportModeLocal |] pExportMode
517 809
     , pX509KeyName
518 810
     , pX509DestCA
519
     ])
811
     ],
812
     "instance_name")
520 813
  , ("OpBackupRemove",
814
     [t| () |],
815
     OpDoc.opBackupRemove,
521 816
     [ pInstanceName
522 817
     , pInstanceUuid
523
     ])
818
     ],
819
     "instance_name")
820
  , ("OpTagsGet",
821
     [t| [NonEmptyString] |],
822
     OpDoc.opTagsGet,
823
     [ pTagsObject
824
     , pUseLocking
825
     , withDoc "Name of object to retrieve tags from" pTagsName
826
     ],
827
     "name")
828
  , ("OpTagsSearch",
829
     [t| [(NonEmptyString, NonEmptyString)] |],
830
     OpDoc.opTagsSearch,
831
     [ pTagSearchPattern
832
     ],
833
     "pattern")
834
  , ("OpTagsSet",
835
     [t| () |],
836
     OpDoc.opTagsSet,
837
     [ pTagsObject
838
     , pTagsList
839
     , withDoc "Name of object where tag(s) should be added" pTagsName
840
     ],
841
     [])
842
  , ("OpTagsDel",
843
     [t| () |],
844
     OpDoc.opTagsDel,
845
     [ pTagsObject
846
     , pTagsList
847
     , withDoc "Name of object where tag(s) should be deleted" pTagsName
848
     ],
849
     [])
850
  , ("OpTestDelay",
851
     [t| () |],
852
     OpDoc.opTestDelay,
853
     [ pDelayDuration
854
     , pDelayOnMaster
855
     , pDelayOnNodes
856
     , pDelayOnNodeUuids
857
     , pDelayRepeat
858
     ],
859
     "duration")
524 860
  , ("OpTestAllocator",
861
     [t| () |],
862
     OpDoc.opTestAllocator,
525 863
     [ pIAllocatorDirection
526 864
     , pIAllocatorMode
527 865
     , pIAllocatorReqName
......
539 877
     , pTargetGroups
540 878
     , pIAllocatorSpindleUse
541 879
     , pIAllocatorCount
542
     ])
880
     ],
881
     "iallocator")
543 882
  , ("OpTestJqueue",
883
     [t| () |],
884
     OpDoc.opTestJqueue,
544 885
     [ pJQueueNotifyWaitLock
545 886
     , pJQueueNotifyExec
546 887
     , pJQueueLogMessages
547 888
     , pJQueueFail
548
     ])
889
     ],
890
     [])
549 891
  , ("OpTestDummy",
892
     [t| () |],
893
     OpDoc.opTestDummy,
550 894
     [ pTestDummyResult
551 895
     , pTestDummyMessages
552 896
     , pTestDummyFail
553 897
     , pTestDummySubmitJobs
554
     ])
898
     ],
899
     [])
555 900
  , ("OpNetworkAdd",
901
     [t| () |],
902
     OpDoc.opNetworkAdd,
556 903
     [ pNetworkName
557 904
     , pNetworkAddress4
558 905
     , pNetworkGateway4
......
561 908
     , pNetworkMacPrefix
562 909
     , pNetworkAddRsvdIps
563 910
     , pIpConflictsCheck
564
     , pInstTags
565
     ])
911
     , withDoc "Network tags" pInstTags
912
     ],
913
     "network_name")
566 914
  , ("OpNetworkRemove",
915
     [t| () |],
916
     OpDoc.opNetworkRemove,
567 917
     [ pNetworkName
568 918
     , pForce
569
     ])
919
     ],
920
     "network_name")
570 921
  , ("OpNetworkSetParams",
922
     [t| () |],
923
     OpDoc.opNetworkSetParams,
571 924
     [ pNetworkName
572 925
     , pNetworkGateway4
573 926
     , pNetworkAddress6
574 927
     , pNetworkGateway6
575 928
     , pNetworkMacPrefix
576
     , pNetworkAddRsvdIps
929
     , withDoc "Which external IP addresses to reserve" pNetworkAddRsvdIps
577 930
     , pNetworkRemoveRsvdIps
578
     ])
931
     ],
932
     "network_name")
579 933
  , ("OpNetworkConnect",
934
     [t| () |],
935
     OpDoc.opNetworkConnect,
580 936
     [ pGroupName
581 937
     , pNetworkName
582 938
     , pNetworkMode
583 939
     , pNetworkLink
584 940
     , pIpConflictsCheck
585
     ])
941
     ],
942
     "network_name")
586 943
  , ("OpNetworkDisconnect",
944
     [t| () |],
945
     OpDoc.opNetworkDisconnect,
587 946
     [ pGroupName
588 947
     , pNetworkName
589
     ])
590
  , ("OpNetworkQuery", dOldQuery)
591
  , ("OpRestrictedCommand",
592
     [ pUseLocking
593
     , pRequiredNodes
594
     , pRequiredNodeUuids
595
     , pRestrictedCommand
596
     ])
948
     ],
949
     "network_name")
950
  , ("OpNetworkQuery",
951
     [t| [[JSValue]] |],
952
     OpDoc.opNetworkQuery,
953
     [ pOutputFields
954
     , pUseLocking
955
     , withDoc "Empty list to query all groups, group names otherwise" pNames
956
     ],
957
     [])
597 958
  ])
598 959

  
599 960
-- | Returns the OP_ID for a given opcode value.
......
648 1009
opSummaryVal OpBackupPrepare { opInstanceName = s } = Just s
649 1010
opSummaryVal OpBackupExport { opInstanceName = s } = Just s
650 1011
opSummaryVal OpBackupRemove { opInstanceName = s } = Just s
651
opSummaryVal OpTagsGet { opKind = k } =
652
  Just . fromMaybe "None" $ tagNameOf k
1012
opSummaryVal OpTagsGet { opKind = s } = Just (show s)
653 1013
opSummaryVal OpTagsSearch { opTagSearchPattern = s } = Just (fromNonEmpty s)
654 1014
opSummaryVal OpTestDelay { opDelayDuration = d } = Just (show d)
655 1015
opSummaryVal OpTestAllocator { opIallocator = s } =
b/src/Ganeti/OpParams.hs
55 55
  , pName
56 56
  , pTagsList
57 57
  , pTagsObject
58
  , pTagsName
58 59
  , pOutputFields
59 60
  , pShutdownTimeout
60
  , pShutdownTimeout'
61 61
  , pShutdownInstance
62 62
  , pForce
63 63
  , pIgnoreOfflineNodes
......
138 138
  , pUseExternalMipScript
139 139
  , pQueryFields
140 140
  , pQueryFilter
141
  , pQueryFieldsFields
141 142
  , pOobCommand
142 143
  , pOobTimeout
143 144
  , pIgnoreStatus
......
252 253
  , pComment
253 254
  , pReason
254 255
  , pEnabledDiskTemplates
255
  , dOldQuery
256
  , dOldQueryNoLocking
257 256
  ) where
258 257

  
259 258
import Control.Monad (liftM)
259
import Data.Set (Set)
260 260
import qualified Data.Set as Set
261
import Text.JSON (readJSON, showJSON, JSON, JSValue(..), fromJSString,
262
                  JSObject, toJSObject)
261
import Text.JSON (JSON, JSValue(..), JSObject (..), readJSON, showJSON,
262
                  fromJSString, toJSObject)
263 263
import qualified Text.JSON
264 264
import Text.JSON.Pretty (pp_value)
265 265

  
......
270 270
import Ganeti.Types
271 271
import qualified Ganeti.Query.Language as Qlang
272 272

  
273
-- * Helper functions and types
274 273

  
275
-- * Type aliases
274
-- * Helper functions and types
276 275

  
277 276
-- | Build a boolean field.
278 277
booleanField :: String -> Field
......
298 297
optionalNEStringField :: String -> Field
299 298
optionalNEStringField = optionalField . flip simpleField [t| NonEmptyString |]
300 299

  
301
-- | Unchecked value, should be replaced by a better definition.
302
type UncheckedValue = JSValue
303

  
304
-- | Unchecked dict, should be replaced by a better definition.
305
type UncheckedDict = JSObject JSValue
306

  
307
-- | Unchecked list, shoild be replaced by a better definition.
308
type UncheckedList = [JSValue]
309

  
310 300
-- | Function to force a non-negative value, without returning via a
311 301
-- monad. This is needed for, and should be used /only/ in the case of
312 302
-- forcing constants. In case the constant is wrong (< 0), this will
......
413 403

  
414 404
-- | NIC modification definition.
415 405
$(buildObject "INicParams" "inic"
416
  [ optionalField $ simpleField C.inicMac  [t| NonEmptyString |]
417
  , optionalField $ simpleField C.inicIp   [t| String         |]
418
  , optionalField $ simpleField C.inicMode [t| NonEmptyString |]
419
  , optionalField $ simpleField C.inicLink [t| NonEmptyString |]
420
  , optionalField $ simpleField C.inicName [t| NonEmptyString |]
421
  , optionalField $ simpleField C.inicVlan [t| NonEmptyString |]
406
  [ optionalField $ simpleField C.inicMac    [t| NonEmptyString |]
407
  , optionalField $ simpleField C.inicIp     [t| String         |]
408
  , optionalField $ simpleField C.inicMode   [t| NonEmptyString |]
409
  , optionalField $ simpleField C.inicLink   [t| NonEmptyString |]
410
  , optionalField $ simpleField C.inicName   [t| NonEmptyString |]
411
  , optionalField $ simpleField C.inicVlan   [t| NonEmptyString |]
412
  , optionalField $ simpleField C.inicBridge [t| NonEmptyString |]
422 413
  ])
423 414

  
424 415
-- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT.
......
500 491
  readJSON = readSetParams
501 492

  
502 493
-- | Custom type for target_node parameter of OpBackupExport, which
503
-- varies depending on mode. FIXME: this uses an UncheckedList since
494
-- varies depending on mode. FIXME: this uses an [JSValue] since
504 495
-- we don't care about individual rows (just like the Python code
505 496
-- tests). But the proper type could be parsed if we wanted.
506 497
data ExportTarget = ExportTargetLocal NonEmptyString
507
                  | ExportTargetRemote UncheckedList
498
                  | ExportTargetRemote [JSValue]
508 499
                    deriving (Eq, Show)
509 500

  
510 501
-- | Custom reader for 'ExportTarget'.
......
520 511
  showJSON (ExportTargetRemote l) = showJSON l
521 512
  readJSON = readExportTarget
522 513

  
523
-- * Parameters
524

  
525
-- | A required instance name (for single-instance LUs).
526
pInstanceName :: Field
527
pInstanceName = simpleField "instance_name" [t| String |]
528

  
529
-- | An instance UUID (for single-instance LUs).
530
pInstanceUuid :: Field
531
pInstanceUuid = optionalField $ simpleField "instance_uuid" [t| String |]
532

  
533
-- | A list of instances.
534
pInstances :: Field
535
pInstances = defaultField [| [] |] $
536
             simpleField "instances" [t| [NonEmptyString] |]
537

  
538
-- | A generic name.
539
pName :: Field
540
pName = simpleField "name" [t| NonEmptyString |]
541

  
542
-- | Tags list.
543
pTagsList :: Field
544
pTagsList = simpleField "tags" [t| [String] |]
545

  
546
-- | Tags object.
547
pTagsObject :: Field
548
pTagsObject =
549
  customField 'decodeTagObject 'encodeTagObject [tagNameField] $
550
  simpleField "kind" [t| TagObject |]
551

  
552
-- | Selected output fields.
553
pOutputFields :: Field
554
pOutputFields = simpleField "output_fields" [t| [NonEmptyString] |]
555

  
556
-- | How long to wait for instance to shut down.
557
pShutdownTimeout :: Field
558
pShutdownTimeout = defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
559
                   simpleField "shutdown_timeout" [t| NonNegative Int |]
560

  
561
-- | Another name for the shutdown timeout, because we like to be
562
-- inconsistent.
563
pShutdownTimeout' :: Field
564
pShutdownTimeout' =
565
  renameField "InstShutdownTimeout" .
566
  defaultField [| forceNonNeg C.defaultShutdownTimeout |] $
567
  simpleField "timeout" [t| NonNegative Int |]
568

  
569
-- | Whether to shutdown the instance in backup-export.
570
pShutdownInstance :: Field
571
pShutdownInstance = defaultTrue "shutdown"
572

  
573
-- | Whether to force the operation.
574
pForce :: Field
575
pForce = defaultFalse "force"
576

  
577
-- | Whether to ignore offline nodes.
578
pIgnoreOfflineNodes :: Field
579
pIgnoreOfflineNodes = defaultFalse "ignore_offline_nodes"
580

  
581
-- | A required node name (for single-node LUs).
582
pNodeName :: Field
583
pNodeName = simpleField "node_name" [t| NonEmptyString |]
584

  
585
-- | A node UUID (for single-node LUs).
586
pNodeUuid :: Field
587
pNodeUuid = optionalField $ simpleField "node_uuid" [t| NonEmptyString |]
588

  
589
-- | List of nodes.
590
pNodeNames :: Field
591
pNodeNames =
592
  defaultField [| [] |] $ simpleField "node_names" [t| [NonEmptyString] |]
593

  
594
-- | List of node UUIDs.
595
pNodeUuids :: Field
596
pNodeUuids =
597
  optionalField $ simpleField "node_uuids" [t| [NonEmptyString] |]
598

  
599
-- | A required node group name (for single-group LUs).
600
pGroupName :: Field
601
pGroupName = simpleField "group_name" [t| NonEmptyString |]
602

  
603
-- | Migration type (live\/non-live).
604
pMigrationMode :: Field
605
pMigrationMode =
606
  renameField "MigrationMode" .
607
  optionalField $
608
  simpleField "mode" [t| MigrationMode |]
609

  
610
-- | Obsolete \'live\' migration mode (boolean).
611
pMigrationLive :: Field
612
pMigrationLive =
613
  renameField "OldLiveMode" . optionalField $ booleanField "live"
614

  
615
-- | Migration cleanup parameter.
616
pMigrationCleanup :: Field
617
pMigrationCleanup = renameField "MigrationCleanup" $ defaultFalse "cleanup"
618

  
619
-- | Whether to force an unknown OS variant.
620
pForceVariant :: Field
621
pForceVariant = defaultFalse "force_variant"
622

  
623
-- | Whether to wait for the disk to synchronize.
624
pWaitForSync :: Field
625
pWaitForSync = defaultTrue "wait_for_sync"
626

  
627
-- | Whether to wait for the disk to synchronize (defaults to false).
628
pWaitForSyncFalse :: Field
629
pWaitForSyncFalse = defaultField [| False |] pWaitForSync
630

  
631
-- | Whether to ignore disk consistency
632
pIgnoreConsistency :: Field
633
pIgnoreConsistency = defaultFalse "ignore_consistency"
634

  
635
-- | Storage name.
636
pStorageName :: Field
637
pStorageName =
638
  renameField "StorageName" $ simpleField "name" [t| NonEmptyString |]
639

  
640
-- | Whether to use synchronization.
641
pUseLocking :: Field
642
pUseLocking = defaultFalse "use_locking"
643

  
644
-- | Whether to employ opportunistic locking for nodes, meaning nodes already
645
-- locked by another opcode won't be considered for instance allocation (only
646
-- when an iallocator is used).
647
pOpportunisticLocking :: Field
648
pOpportunisticLocking = defaultFalse "opportunistic_locking"
649

  
650
-- | Whether to check name.
651
pNameCheck :: Field
652
pNameCheck = defaultTrue "name_check"
653

  
654
-- | Instance allocation policy.
655
pNodeGroupAllocPolicy :: Field
656
pNodeGroupAllocPolicy = optionalField $
657
                        simpleField "alloc_policy" [t| AllocPolicy |]
658

  
659
-- | Default node parameters for group.
660
pGroupNodeParams :: Field
661
pGroupNodeParams = optionalField $ simpleField "ndparams" [t| UncheckedDict |]
662 514

  
663
-- | Resource(s) to query for.
664
pQueryWhat :: Field
665
pQueryWhat = simpleField "what" [t| Qlang.QueryTypeOp |]
666

  
667
-- | Whether to release locks as soon as possible.
668
pEarlyRelease :: Field
669
pEarlyRelease = defaultFalse "early_release"
670

  
671
-- | Whether to ensure instance's IP address is inactive.
672
pIpCheck :: Field
673
pIpCheck = defaultTrue "ip_check"
674

  
675
-- | Check for conflicting IPs.
676
pIpConflictsCheck :: Field
677
pIpConflictsCheck = defaultTrue "conflicts_check"
515
-- * Common opcode parameters
678 516

  
679
-- | Do not remember instance state changes.
680
pNoRemember :: Field
681
pNoRemember = defaultFalse "no_remember"
517
pDryRun :: Field
518
pDryRun =
519
  withDoc "Run checks only, don't execute" .
520
  optionalField $ booleanField "dry_run"
682 521

  
683
-- | Target node for instance migration/failover.
684
pMigrationTargetNode :: Field
685
pMigrationTargetNode = optionalNEStringField "target_node"
522
pDebugLevel :: Field
523
pDebugLevel =
524
  withDoc "Debug level" .
525
  optionalField $ simpleField "debug_level" [t| NonNegative Int |]
686 526

  
687
-- | Target node UUID for instance migration/failover.
688
pMigrationTargetNodeUuid :: Field
689
pMigrationTargetNodeUuid = optionalNEStringField "target_node_uuid"
527
pOpPriority :: Field
528
pOpPriority =
529
  withDoc "Opcode priority. Note: python uses a separate constant,\
530
          \ we're using the actual value we know it's the default" .
531
  defaultField [| OpPrioNormal |] $
532
  simpleField "priority" [t| OpSubmitPriority |]
690 533

  
691
-- | Target node for instance move (required).
692
pMoveTargetNode :: Field
693
pMoveTargetNode =
694
  renameField "MoveTargetNode" $
695
  simpleField "target_node" [t| NonEmptyString |]
534
pDependencies :: Field
535
pDependencies =
536
  withDoc "Job dependencies" .
537
  optionalNullSerField $ simpleField "depends" [t| [JobDependency] |]
696 538

  
697
-- | Target node UUID for instance move.
698
pMoveTargetNodeUuid :: Field
699
pMoveTargetNodeUuid =
700
  renameField "MoveTargetNodeUuid" . optionalField $
701
  simpleField "target_node_uuid" [t| NonEmptyString |]
539
pComment :: Field
540
pComment =
541
  withDoc "Comment field" .
542
  optionalNullSerField $ stringField "comment"
702 543

  
703
-- | Pause instance at startup.
704
pStartupPaused :: Field
705
pStartupPaused = defaultFalse "startup_paused"
544
pReason :: Field
545
pReason =
546
  withDoc "Reason trail field" $
547
  simpleField C.opcodeReason [t| ReasonTrail |]
706 548

  
707
-- | Verbose mode.
708
pVerbose :: Field
709
pVerbose = defaultFalse "verbose"
710 549

  
711
-- ** Parameters for cluster verification
550
-- * Parameters
712 551

  
713
-- | Whether to simulate errors (useful for debugging).
714 552
pDebugSimulateErrors :: Field
715
pDebugSimulateErrors = defaultFalse "debug_simulate_errors"
553
pDebugSimulateErrors =
554
  withDoc "Whether to simulate errors (useful for debugging)" $
555
  defaultFalse "debug_simulate_errors"
716 556

  
717
-- | Error codes.
718 557
pErrorCodes :: Field
719
pErrorCodes = defaultFalse "error_codes"
558
pErrorCodes = 
559
  withDoc "Error codes" $
560
  defaultFalse "error_codes"
720 561

  
721
-- | Which checks to skip.
722 562
pSkipChecks :: Field
723
pSkipChecks = defaultField [| Set.empty |] $
724
              simpleField "skip_checks" [t| Set.Set VerifyOptionalChecks |]
563
pSkipChecks = 
564
  withDoc "Which checks to skip" .
565
  defaultField [| Set.empty |] $
566
  simpleField "skip_checks" [t| Set VerifyOptionalChecks |]
725 567

  
726
-- | List of error codes that should be treated as warnings.
727 568
pIgnoreErrors :: Field
728
pIgnoreErrors = defaultField [| Set.empty |] $
729
                simpleField "ignore_errors" [t| Set.Set CVErrorCode |]
730

  
731
-- | Optional group name.
732
pOptGroupName :: Field
733
pOptGroupName = renameField "OptGroupName" .
734
                optionalField $ simpleField "group_name" [t| NonEmptyString |]
735

  
736
-- | Disk templates' parameter defaults.
737
pDiskParams :: Field
738
pDiskParams = optionalField $
739
              simpleField "diskparams" [t| GenericContainer DiskTemplate
740
                                           UncheckedDict |]
741

  
742
-- * Parameters for node resource model
569
pIgnoreErrors =
570
  withDoc "List of error codes that should be treated as warnings" .
571
  defaultField [| Set.empty |] $
572
  simpleField "ignore_errors" [t| Set CVErrorCode |]
743 573

  
744
-- | Set hypervisor states.
745
pHvState :: Field
746
pHvState = optionalField $ simpleField "hv_state" [t| UncheckedDict |]
747

  
748
-- | Set disk states.
749
pDiskState :: Field
750
pDiskState = optionalField $ simpleField "disk_state" [t| UncheckedDict |]
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff