Revision b09cce64 htools/Ganeti/Objects.hs
b/htools/Ganeti/Objects.hs | ||
---|---|---|
29 | 29 |
-} |
30 | 30 |
|
31 | 31 |
module Ganeti.Objects |
32 |
( NICMode(..) |
|
33 |
, PartialNICParams(..) |
|
34 |
, FilledNICParams(..) |
|
35 |
, fillNICParams |
|
36 |
, PartialNIC(..) |
|
32 |
( HvParams |
|
33 |
, OsParams |
|
34 |
, NICMode(..) |
|
35 |
, PartialNicParams(..) |
|
36 |
, FilledNicParams(..) |
|
37 |
, fillNicParams |
|
38 |
, PartialNic(..) |
|
37 | 39 |
, DiskMode(..) |
38 | 40 |
, DiskType(..) |
39 | 41 |
, DiskLogicalId(..) |
40 | 42 |
, Disk(..) |
41 | 43 |
, DiskTemplate(..) |
42 |
, PartialBEParams(..)
|
|
43 |
, FilledBEParams(..)
|
|
44 |
, fillBEParams
|
|
44 |
, PartialBeParams(..)
|
|
45 |
, FilledBeParams(..)
|
|
46 |
, fillBeParams
|
|
45 | 47 |
, Hypervisor(..) |
46 | 48 |
, AdminState(..) |
47 | 49 |
, adminStateFromRaw |
... | ... | |
58 | 60 |
, FilledIPolicy(..) |
59 | 61 |
, PartialIPolicy(..) |
60 | 62 |
, fillIPolicy |
63 |
, DiskParams |
|
61 | 64 |
, NodeGroup(..) |
62 | 65 |
, IpFamily(..) |
63 | 66 |
, ipFamilyToVersion |
64 | 67 |
, fillDict |
68 |
, ClusterHvParams |
|
69 |
, OsHvParams |
|
70 |
, ClusterBeParams |
|
71 |
, ClusterOsParams |
|
72 |
, ClusterNicParams |
|
65 | 73 |
, Cluster(..) |
66 | 74 |
, ConfigData(..) |
67 | 75 |
) where |
... | ... | |
86 | 94 |
let updated = Map.union custom defaults |
87 | 95 |
in foldl' (flip Map.delete) updated skip_keys |
88 | 96 |
|
97 |
-- | The hypervisor parameter type. This is currently a simple map, |
|
98 |
-- without type checking on key/value pairs. |
|
99 |
type HvParams = Container JSValue |
|
100 |
|
|
101 |
-- | The OS parameters type. This is, and will remain, a string |
|
102 |
-- container, since the keys are dynamically declared by the OSes, and |
|
103 |
-- the values are always strings. |
|
104 |
type OsParams = Container String |
|
105 |
|
|
89 | 106 |
-- * NIC definitions |
90 | 107 |
|
91 | 108 |
$(declareSADT "NICMode" |
... | ... | |
94 | 111 |
]) |
95 | 112 |
$(makeJSONInstance ''NICMode) |
96 | 113 |
|
97 |
$(buildParam "NIC" "nicp"
|
|
114 |
$(buildParam "Nic" "nicp"
|
|
98 | 115 |
[ simpleField "mode" [t| NICMode |] |
99 | 116 |
, simpleField "link" [t| String |] |
100 | 117 |
]) |
101 | 118 |
|
102 |
$(buildObject "PartialNIC" "nic"
|
|
119 |
$(buildObject "PartialNic" "nic"
|
|
103 | 120 |
[ simpleField "mac" [t| String |] |
104 | 121 |
, optionalField $ simpleField "ip" [t| String |] |
105 |
, simpleField "nicparams" [t| PartialNICParams |]
|
|
122 |
, simpleField "nicparams" [t| PartialNicParams |]
|
|
106 | 123 |
]) |
107 | 124 |
|
108 | 125 |
-- * Disk definitions |
... | ... | |
282 | 299 |
]) |
283 | 300 |
$(makeJSONInstance ''AdminState) |
284 | 301 |
|
285 |
$(buildParam "BE" "bep" $
|
|
302 |
$(buildParam "Be" "bep" $
|
|
286 | 303 |
[ simpleField "minmem" [t| Int |] |
287 | 304 |
, simpleField "maxmem" [t| Int |] |
288 | 305 |
, simpleField "vcpus" [t| Int |] |
... | ... | |
293 | 310 |
[ simpleField "name" [t| String |] |
294 | 311 |
, simpleField "primary_node" [t| String |] |
295 | 312 |
, simpleField "os" [t| String |] |
296 |
, simpleField "hypervisor" [t| String |]
|
|
297 |
-- , simpleField "hvparams" [t| [(String, String)] |]
|
|
298 |
, simpleField "beparams" [t| PartialBEParams |]
|
|
299 |
-- , simpleField "osparams" [t| [(String, String)] |]
|
|
313 |
, simpleField "hypervisor" [t| Hypervisor |]
|
|
314 |
, simpleField "hvparams" [t| HvParams |]
|
|
315 |
, simpleField "beparams" [t| PartialBeParams |]
|
|
316 |
, simpleField "osparams" [t| OsParams |]
|
|
300 | 317 |
, simpleField "admin_state" [t| AdminState |] |
301 |
, simpleField "nics" [t| [PartialNIC] |]
|
|
318 |
, simpleField "nics" [t| [PartialNic] |]
|
|
302 | 319 |
, simpleField "disks" [t| [Disk] |] |
303 | 320 |
, simpleField "disk_template" [t| DiskTemplate |] |
304 |
, optionalField $ simpleField "network_port" [t| Int |] |
|
321 |
, optionalField $ simpleField "network_port" [t| Int |]
|
|
305 | 322 |
] |
306 | 323 |
++ timeStampFields |
307 | 324 |
++ uuidFields |
... | ... | |
407 | 424 |
]) |
408 | 425 |
$(makeJSONInstance ''AllocPolicy) |
409 | 426 |
|
427 |
-- | The disk parameters type. |
|
428 |
type DiskParams = Container (Container JSValue) |
|
429 |
|
|
410 | 430 |
$(buildObject "NodeGroup" "group" $ |
411 | 431 |
[ simpleField "name" [t| String |] |
412 | 432 |
, defaultField [| [] |] $ simpleField "members" [t| [String] |] |
413 | 433 |
, simpleField "ndparams" [t| PartialNDParams |] |
414 | 434 |
, simpleField "alloc_policy" [t| AllocPolicy |] |
415 | 435 |
, simpleField "ipolicy" [t| PartialIPolicy |] |
436 |
, simpleField "diskparams" [t| DiskParams |] |
|
416 | 437 |
] |
417 | 438 |
++ timeStampFields |
418 | 439 |
++ uuidFields |
... | ... | |
432 | 453 |
ipFamilyToVersion IpFamilyV4 = C.ip4Version |
433 | 454 |
ipFamilyToVersion IpFamilyV6 = C.ip6Version |
434 | 455 |
|
456 |
-- | Cluster HvParams (hvtype to hvparams mapping). |
|
457 |
type ClusterHvParams = Container HvParams |
|
458 |
|
|
459 |
-- | Cluster Os-HvParams (os to hvparams mapping). |
|
460 |
type OsHvParams = Container ClusterHvParams |
|
461 |
|
|
462 |
-- | Cluser BeParams. |
|
463 |
type ClusterBeParams = Container FilledBeParams |
|
464 |
|
|
465 |
-- | Cluster OsParams. |
|
466 |
type ClusterOsParams = Container OsParams |
|
467 |
|
|
468 |
-- | Cluster NicParams. |
|
469 |
type ClusterNicParams = Container FilledNicParams |
|
470 |
|
|
471 |
-- | Cluster UID Pool, list (low, high) UID ranges. |
|
472 |
type UidPool = [(Int, Int)] |
|
473 |
|
|
435 | 474 |
-- * Cluster definitions |
436 | 475 |
$(buildObject "Cluster" "cluster" $ |
437 |
[ simpleField "rsahostkeypub" [t| String |]
|
|
438 |
, simpleField "highest_used_port" [t| Int |]
|
|
439 |
, simpleField "tcpudp_port_pool" [t| [Int] |]
|
|
440 |
, simpleField "mac_prefix" [t| String |]
|
|
441 |
, simpleField "volume_group_name" [t| String |]
|
|
442 |
, simpleField "reserved_lvs" [t| [String] |]
|
|
443 |
, optionalField $ simpleField "drbd_usermode_helper" [t| String |]
|
|
444 |
-- , simpleField "default_bridge" [t| String |]
|
|
445 |
-- , simpleField "default_hypervisor" [t| String |]
|
|
446 |
, simpleField "master_node" [t| String |]
|
|
447 |
, simpleField "master_ip" [t| String |]
|
|
448 |
, simpleField "master_netdev" [t| String |]
|
|
449 |
, simpleField "master_netmask" [t| Int |]
|
|
450 |
, simpleField "use_external_mip_script" [t| Bool |]
|
|
451 |
, simpleField "cluster_name" [t| String |]
|
|
452 |
, simpleField "file_storage_dir" [t| String |]
|
|
453 |
, simpleField "shared_file_storage_dir" [t| String |]
|
|
454 |
, simpleField "enabled_hypervisors" [t| [String] |]
|
|
455 |
-- , simpleField "hvparams" [t| [(String, [(String, String)])] |]
|
|
456 |
-- , simpleField "os_hvp" [t| [(String, String)] |]
|
|
457 |
, simpleField "beparams" [t| Container FilledBEParams |]
|
|
458 |
, simpleField "osparams" [t| Container (Container String) |]
|
|
459 |
, simpleField "nicparams" [t| Container FilledNICParams |]
|
|
460 |
, simpleField "ndparams" [t| FilledNDParams |]
|
|
461 |
, simpleField "candidate_pool_size" [t| Int |]
|
|
462 |
, simpleField "modify_etc_hosts" [t| Bool |]
|
|
463 |
, simpleField "modify_ssh_setup" [t| Bool |]
|
|
464 |
, simpleField "maintain_node_health" [t| Bool |]
|
|
465 |
, simpleField "uid_pool" [t| [(Int, Int)] |]
|
|
466 |
, simpleField "default_iallocator" [t| String |]
|
|
467 |
, simpleField "hidden_os" [t| [String] |]
|
|
468 |
, simpleField "blacklisted_os" [t| [String] |]
|
|
469 |
, simpleField "primary_ip_family" [t| IpFamily |]
|
|
470 |
, simpleField "prealloc_wipe_disks" [t| Bool |]
|
|
471 |
, simpleField "ipolicy" [t| FilledIPolicy |]
|
|
476 |
[ simpleField "rsahostkeypub" [t| String |]
|
|
477 |
, simpleField "highest_used_port" [t| Int |]
|
|
478 |
, simpleField "tcpudp_port_pool" [t| [Int] |]
|
|
479 |
, simpleField "mac_prefix" [t| String |]
|
|
480 |
, simpleField "volume_group_name" [t| String |]
|
|
481 |
, simpleField "reserved_lvs" [t| [String] |]
|
|
482 |
, optionalField $ |
|
483 |
simpleField "drbd_usermode_helper" [t| String |]
|
|
484 |
, simpleField "master_node" [t| String |]
|
|
485 |
, simpleField "master_ip" [t| String |]
|
|
486 |
, simpleField "master_netdev" [t| String |]
|
|
487 |
, simpleField "master_netmask" [t| Int |]
|
|
488 |
, simpleField "use_external_mip_script" [t| Bool |]
|
|
489 |
, simpleField "cluster_name" [t| String |]
|
|
490 |
, simpleField "file_storage_dir" [t| String |]
|
|
491 |
, simpleField "shared_file_storage_dir" [t| String |]
|
|
492 |
, simpleField "enabled_hypervisors" [t| [String] |]
|
|
493 |
, simpleField "hvparams" [t| ClusterHvParams |]
|
|
494 |
, simpleField "os_hvp" [t| OsHvParams |]
|
|
495 |
, simpleField "beparams" [t| ClusterBeParams |]
|
|
496 |
, simpleField "osparams" [t| ClusterOsParams |]
|
|
497 |
, simpleField "nicparams" [t| ClusterNicParams |]
|
|
498 |
, simpleField "ndparams" [t| FilledNDParams |]
|
|
499 |
, simpleField "diskparams" [t| DiskParams |]
|
|
500 |
, simpleField "candidate_pool_size" [t| Int |]
|
|
501 |
, simpleField "modify_etc_hosts" [t| Bool |]
|
|
502 |
, simpleField "modify_ssh_setup" [t| Bool |]
|
|
503 |
, simpleField "maintain_node_health" [t| Bool |]
|
|
504 |
, simpleField "uid_pool" [t| UidPool |]
|
|
505 |
, simpleField "default_iallocator" [t| String |]
|
|
506 |
, simpleField "hidden_os" [t| [String] |]
|
|
507 |
, simpleField "blacklisted_os" [t| [String] |]
|
|
508 |
, simpleField "primary_ip_family" [t| IpFamily |]
|
|
509 |
, simpleField "prealloc_wipe_disks" [t| Bool |]
|
|
510 |
, simpleField "ipolicy" [t| FilledIPolicy |]
|
|
472 | 511 |
] |
473 | 512 |
++ serialFields |
474 | 513 |
++ timeStampFields |
Also available in: Unified diff