Revision 06c2fb4a src/Ganeti/OpParams.hs
b/src/Ganeti/OpParams.hs | ||
---|---|---|
45 | 45 |
, DiskAccess(..) |
46 | 46 |
, INicParams(..) |
47 | 47 |
, IDiskParams(..) |
48 |
, ISnapParams(..) |
|
48 | 49 |
, RecreateDisksInfo(..) |
49 | 50 |
, DdmOldChanges(..) |
50 | 51 |
, SetParamsMods(..) |
52 |
, SetSnapParams(..) |
|
51 | 53 |
, ExportTarget(..) |
52 | 54 |
, pInstanceName |
53 | 55 |
, pInstances |
... | ... | |
98 | 100 |
, pHotplugIfPossible |
99 | 101 |
, pAllowRuntimeChgs |
100 | 102 |
, pInstDisks |
103 |
, pInstSnaps |
|
101 | 104 |
, pDiskTemplate |
102 | 105 |
, pOptDiskTemplate |
103 | 106 |
, pFileDriver |
... | ... | |
425 | 428 |
, optionalField $ simpleField C.idiskName [t| NonEmptyString |] |
426 | 429 |
]) |
427 | 430 |
|
431 |
-- | Disk snapshot definition. |
|
432 |
$(buildObject "ISnapParams" "idisk" |
|
433 |
[ simpleField C.idiskSnapshotName [t| NonEmptyString |]]) |
|
434 |
|
|
428 | 435 |
-- | Disk changes type for OpInstanceRecreateDisks. This is a bit |
429 | 436 |
-- strange, because the type in Python is something like Either |
430 | 437 |
-- [DiskIndex] [DiskChanges], but we can't represent the type of an |
... | ... | |
493 | 500 |
showJSON (SetParamsNew v) = showJSON v |
494 | 501 |
readJSON = readSetParams |
495 | 502 |
|
503 |
-- | Instance snapshot params |
|
504 |
data SetSnapParams a |
|
505 |
= SetSnapParamsEmpty |
|
506 |
| SetSnapParamsValid (NonEmpty (Int, a)) |
|
507 |
deriving (Eq, Show) |
|
508 |
|
|
509 |
readSetSnapParams :: (JSON a) => JSValue -> Text.JSON.Result (SetSnapParams a) |
|
510 |
readSetSnapParams (JSArray []) = return SetSnapParamsEmpty |
|
511 |
readSetSnapParams v = |
|
512 |
case readJSON v::Text.JSON.Result [(Int, JSValue)] of |
|
513 |
Text.JSON.Ok _ -> liftM SetSnapParamsValid $ readJSON v |
|
514 |
_ -> fail "Cannot parse snapshot params." |
|
515 |
|
|
516 |
instance (JSON a) => JSON (SetSnapParams a) where |
|
517 |
showJSON SetSnapParamsEmpty = showJSON () |
|
518 |
showJSON (SetSnapParamsValid v) = showJSON v |
|
519 |
readJSON = readSetSnapParams |
|
520 |
|
|
496 | 521 |
-- | Custom type for target_node parameter of OpBackupExport, which |
497 | 522 |
-- varies depending on mode. FIXME: this uses an UncheckedList since |
498 | 523 |
-- we don't care about individual rows (just like the Python code |
... | ... | |
748 | 773 |
pInstDisks :: Field |
749 | 774 |
pInstDisks = renameField "instDisks" $ simpleField "disks" [t| [IDiskParams] |] |
750 | 775 |
|
776 |
-- | List of instance snaps. |
|
777 |
pInstSnaps :: Field |
|
778 |
pInstSnaps = |
|
779 |
renameField "instSnaps" $ |
|
780 |
simpleField "disks" [t| SetSnapParams ISnapParams |] |
|
781 |
|
|
751 | 782 |
-- | Instance disk template. |
752 | 783 |
pDiskTemplate :: Field |
753 | 784 |
pDiskTemplate = simpleField "disk_template" [t| DiskTemplate |] |
Also available in: Unified diff