Commit a957e150 authored by Iustin Pop's avatar Iustin Pop
Browse files

Improve Objects.hs definitions



This adds a few missing/incomplete definitions. We're still missing
the special parameters (disk params, hvparams, os_hvp).
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent d5a93a80
...@@ -539,11 +539,14 @@ instance Arbitrary Types.IPolicy where ...@@ -539,11 +539,14 @@ instance Arbitrary Types.IPolicy where
instance Arbitrary Objects.Hypervisor where instance Arbitrary Objects.Hypervisor where
arbitrary = elements [minBound..maxBound] arbitrary = elements [minBound..maxBound]
instance Arbitrary Objects.PartialNDParams where
arbitrary = Objects.PartialNDParams <$> arbitrary
instance Arbitrary Objects.Node where instance Arbitrary Objects.Node where
arbitrary = Objects.Node <$> getFQDN <*> getFQDN <*> getFQDN arbitrary = Objects.Node <$> getFQDN <*> getFQDN <*> getFQDN
<*> arbitrary <*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary <*> arbitrary <*> arbitrary <*> getFQDN
<*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
<*> arbitrary <*> getFQDN <*> arbitrary <*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary
instance Arbitrary Rpc.RpcCallAllInstancesInfo where instance Arbitrary Rpc.RpcCallAllInstancesInfo where
arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary arbitrary = Rpc.RpcCallAllInstancesInfo <$> arbitrary
......
...@@ -53,6 +53,8 @@ module Ganeti.Objects ...@@ -53,6 +53,8 @@ module Ganeti.Objects
, Node(..) , Node(..)
, AllocPolicy(..) , AllocPolicy(..)
, NodeGroup(..) , NodeGroup(..)
, IpFamily(..)
, ipFamilyToVersion
, Cluster(..) , Cluster(..)
, ConfigData(..) , ConfigData(..)
) where ) where
...@@ -251,6 +253,7 @@ $(declareSADT "DiskTemplate" ...@@ -251,6 +253,7 @@ $(declareSADT "DiskTemplate"
, ("DTPlain", 'C.dtPlain) , ("DTPlain", 'C.dtPlain)
, ("DTBlock", 'C.dtBlock) , ("DTBlock", 'C.dtBlock)
, ("DTDrbd8", 'C.dtDrbd8) , ("DTDrbd8", 'C.dtDrbd8)
, ("DTRados", 'C.dtRbd)
]) ])
$(makeJSONInstance ''DiskTemplate) $(makeJSONInstance ''DiskTemplate)
...@@ -302,7 +305,7 @@ $(buildObject "Node" "node" $ ...@@ -302,7 +305,7 @@ $(buildObject "Node" "node" $
, simpleField "group" [t| String |] , simpleField "group" [t| String |]
, simpleField "master_capable" [t| Bool |] , simpleField "master_capable" [t| Bool |]
, simpleField "vm_capable" [t| Bool |] , simpleField "vm_capable" [t| Bool |]
-- , simpleField "ndparams" [t| PartialNDParams |] , simpleField "ndparams" [t| PartialNDParams |]
, simpleField "powered" [t| Bool |] , simpleField "powered" [t| Bool |]
] ]
++ timeStampFields ++ timeStampFields
...@@ -329,13 +332,26 @@ $(makeJSONInstance ''AllocPolicy) ...@@ -329,13 +332,26 @@ $(makeJSONInstance ''AllocPolicy)
$(buildObject "NodeGroup" "group" $ $(buildObject "NodeGroup" "group" $
[ simpleField "name" [t| String |] [ simpleField "name" [t| String |]
, defaultField [| [] |] $ simpleField "members" [t| [String] |] , defaultField [| [] |] $ simpleField "members" [t| [String] |]
-- , simpleField "ndparams" [t| PartialNDParams |] , simpleField "ndparams" [t| PartialNDParams |]
, simpleField "alloc_policy" [t| AllocPolicy |] , simpleField "alloc_policy" [t| AllocPolicy |]
] ]
++ timeStampFields ++ timeStampFields
++ uuidFields ++ uuidFields
++ serialFields) ++ serialFields)
-- | IP family type
$(declareIADT "IpFamily"
[ ("IpFamilyV4", 'C.ip4Family)
, ("IpFamilyV6", 'C.ip6Family)
])
$(makeJSONInstance ''IpFamily)
-- | Conversion from IP family to IP version. This is needed because
-- Python uses both, depending on context.
ipFamilyToVersion :: IpFamily -> Int
ipFamilyToVersion IpFamilyV4 = C.ip4Version
ipFamilyToVersion IpFamilyV6 = C.ip6Version
-- * Cluster definitions -- * Cluster definitions
$(buildObject "Cluster" "cluster" $ $(buildObject "Cluster" "cluster" $
[ simpleField "rsahostkeypub" [t| String |] [ simpleField "rsahostkeypub" [t| String |]
...@@ -344,32 +360,33 @@ $(buildObject "Cluster" "cluster" $ ...@@ -344,32 +360,33 @@ $(buildObject "Cluster" "cluster" $
, simpleField "mac_prefix" [t| String |] , simpleField "mac_prefix" [t| String |]
, simpleField "volume_group_name" [t| String |] , simpleField "volume_group_name" [t| String |]
, simpleField "reserved_lvs" [t| [String] |] , simpleField "reserved_lvs" [t| [String] |]
-- , simpleField "drbd_usermode_helper" [t| String |] , optionalField $ simpleField "drbd_usermode_helper" [t| String |]
-- , simpleField "default_bridge" [t| String |] -- , simpleField "default_bridge" [t| String |]
-- , simpleField "default_hypervisor" [t| String |] -- , simpleField "default_hypervisor" [t| String |]
, simpleField "master_node" [t| String |] , simpleField "master_node" [t| String |]
, simpleField "master_ip" [t| String |] , simpleField "master_ip" [t| String |]
, simpleField "master_netdev" [t| String |] , simpleField "master_netdev" [t| String |]
-- , simpleField "master_netmask" [t| String |] , simpleField "master_netmask" [t| Int |]
, simpleField "use_external_mip_script" [t| Bool |]
, simpleField "cluster_name" [t| String |] , simpleField "cluster_name" [t| String |]
, simpleField "file_storage_dir" [t| String |] , simpleField "file_storage_dir" [t| String |]
-- , simpleField "shared_file_storage_dir" [t| String |] , simpleField "shared_file_storage_dir" [t| String |]
, simpleField "enabled_hypervisors" [t| [String] |] , simpleField "enabled_hypervisors" [t| [String] |]
-- , simpleField "hvparams" [t| [(String, [(String, String)])] |] -- , simpleField "hvparams" [t| [(String, [(String, String)])] |]
-- , simpleField "os_hvp" [t| [(String, String)] |] -- , simpleField "os_hvp" [t| [(String, String)] |]
, simpleField "beparams" [t| Container FilledBEParams |] , simpleField "beparams" [t| Container FilledBEParams |]
-- , simpleField "osparams" [t| [(String, String)] |] , simpleField "osparams" [t| Container (Container String) |]
, simpleField "nicparams" [t| Container FilledNICParams |] , simpleField "nicparams" [t| Container FilledNICParams |]
-- , simpleField "ndparams" [t| FilledNDParams |] , simpleField "ndparams" [t| FilledNDParams |]
, simpleField "candidate_pool_size" [t| Int |] , simpleField "candidate_pool_size" [t| Int |]
, simpleField "modify_etc_hosts" [t| Bool |] , simpleField "modify_etc_hosts" [t| Bool |]
, simpleField "modify_ssh_setup" [t| Bool |] , simpleField "modify_ssh_setup" [t| Bool |]
, simpleField "maintain_node_health" [t| Bool |] , simpleField "maintain_node_health" [t| Bool |]
, simpleField "uid_pool" [t| [Int] |] , simpleField "uid_pool" [t| [(Int, Int)] |]
, simpleField "default_iallocator" [t| String |] , simpleField "default_iallocator" [t| String |]
, simpleField "hidden_os" [t| [String] |] , simpleField "hidden_os" [t| [String] |]
, simpleField "blacklisted_os" [t| [String] |] , simpleField "blacklisted_os" [t| [String] |]
, simpleField "primary_ip_family" [t| Int |] , simpleField "primary_ip_family" [t| IpFamily |]
, simpleField "prealloc_wipe_disks" [t| Bool |] , simpleField "prealloc_wipe_disks" [t| Bool |]
] ]
++ serialFields ++ serialFields
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment