Commit 7c6deb9f authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Add SSConf keys for hypervisor parameters



.. and a function for converting hypervisor types to the keys.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 81236679
...@@ -38,6 +38,7 @@ module Ganeti.Ssconf ...@@ -38,6 +38,7 @@ module Ganeti.Ssconf
( SSKey(..) ( SSKey(..)
, sSKeyToRaw , sSKeyToRaw
, sSKeyFromRaw , sSKeyFromRaw
, hvparamsSSKey
, getPrimaryIPFamily , getPrimaryIPFamily
, parseNodesVmCapable , parseNodesVmCapable
, getNodesVmCapable , getNodesVmCapable
...@@ -53,6 +54,7 @@ module Ganeti.Ssconf ...@@ -53,6 +54,7 @@ module Ganeti.Ssconf
, emptySSConf , emptySSConf
) where ) where
import Control.Arrow ((&&&))
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Control.Exception import Control.Exception
import Control.Monad (forM, liftM) import Control.Monad (forM, liftM)
...@@ -83,40 +85,61 @@ maxFileSize = 131072 ...@@ -83,40 +85,61 @@ maxFileSize = 131072
sSFilePrefix :: FilePath sSFilePrefix :: FilePath
sSFilePrefix = C.ssconfFileprefix sSFilePrefix = C.ssconfFileprefix
$(declareSADT "SSKey" $(declareLADT ''String "SSKey" (
[ ("SSClusterName", 'C.ssClusterName) [ ("SSClusterName", C.ssClusterName)
, ("SSClusterTags", 'C.ssClusterTags) , ("SSClusterTags", C.ssClusterTags)
, ("SSFileStorageDir", 'C.ssFileStorageDir) , ("SSFileStorageDir", C.ssFileStorageDir)
, ("SSSharedFileStorageDir", 'C.ssSharedFileStorageDir) , ("SSSharedFileStorageDir", C.ssSharedFileStorageDir)
, ("SSGlusterStorageDir", 'C.ssGlusterStorageDir) , ("SSGlusterStorageDir", C.ssGlusterStorageDir)
, ("SSMasterCandidates", 'C.ssMasterCandidates) , ("SSMasterCandidates", C.ssMasterCandidates)
, ("SSMasterCandidatesIps", 'C.ssMasterCandidatesIps) , ("SSMasterCandidatesIps", C.ssMasterCandidatesIps)
, ("SSMasterCandidatesCerts",'C.ssMasterCandidatesCerts) , ("SSMasterCandidatesCerts", C.ssMasterCandidatesCerts)
, ("SSMasterIp", 'C.ssMasterIp) , ("SSMasterIp", C.ssMasterIp)
, ("SSMasterNetdev", 'C.ssMasterNetdev) , ("SSMasterNetdev", C.ssMasterNetdev)
, ("SSMasterNetmask", 'C.ssMasterNetmask) , ("SSMasterNetmask", C.ssMasterNetmask)
, ("SSMasterNode", 'C.ssMasterNode) , ("SSMasterNode", C.ssMasterNode)
, ("SSNodeList", 'C.ssNodeList) , ("SSNodeList", C.ssNodeList)
, ("SSNodePrimaryIps", 'C.ssNodePrimaryIps) , ("SSNodePrimaryIps", C.ssNodePrimaryIps)
, ("SSNodeSecondaryIps", 'C.ssNodeSecondaryIps) , ("SSNodeSecondaryIps", C.ssNodeSecondaryIps)
, ("SSNodeVmCapable", 'C.ssNodeVmCapable) , ("SSNodeVmCapable", C.ssNodeVmCapable)
, ("SSOfflineNodes", 'C.ssOfflineNodes) , ("SSOfflineNodes", C.ssOfflineNodes)
, ("SSOnlineNodes", 'C.ssOnlineNodes) , ("SSOnlineNodes", C.ssOnlineNodes)
, ("SSPrimaryIpFamily", 'C.ssPrimaryIpFamily) , ("SSPrimaryIpFamily", C.ssPrimaryIpFamily)
, ("SSInstanceList", 'C.ssInstanceList) , ("SSInstanceList", C.ssInstanceList)
, ("SSReleaseVersion", 'C.ssReleaseVersion) , ("SSReleaseVersion", C.ssReleaseVersion)
, ("SSHypervisorList", 'C.ssHypervisorList) , ("SSHypervisorList", C.ssHypervisorList)
, ("SSMaintainNodeHealth", 'C.ssMaintainNodeHealth) , ("SSMaintainNodeHealth", C.ssMaintainNodeHealth)
, ("SSUidPool", 'C.ssUidPool) , ("SSUidPool", C.ssUidPool)
, ("SSNodegroups", 'C.ssNodegroups) , ("SSNodegroups", C.ssNodegroups)
, ("SSNetworks", 'C.ssNetworks) , ("SSNetworks", C.ssNetworks)
, ("SSEnabledUserShutdown", 'C.ssEnabledUserShutdown) , ("SSEnabledUserShutdown", C.ssEnabledUserShutdown)
]) ] ++
-- Automatically generate SSHvparamsXxx for each hypervisor type:
map ((("SSHvparams" ++) . show)
&&& ((C.ssHvparamsPref ++) . Types.hypervisorToRaw))
[minBound..maxBound]
))
instance HasStringRepr SSKey where instance HasStringRepr SSKey where
fromStringRepr = sSKeyFromRaw fromStringRepr = sSKeyFromRaw
toStringRepr = sSKeyToRaw toStringRepr = sSKeyToRaw
-- | For a given hypervisor get the corresponding SSConf key that contains its
-- parameters.
--
-- The corresponding SSKeys are generated automatically by TH, but since we
-- don't have convenient infrastructure for generating this function, it's just
-- manual. All constructors must be given explicitly so that adding another
-- hypervisor will trigger "incomplete pattern" warning and force the
-- corresponding addition.
hvparamsSSKey :: Types.Hypervisor -> SSKey
hvparamsSSKey Types.Kvm = SSHvparamsKvm
hvparamsSSKey Types.XenPvm = SSHvparamsXenPvm
hvparamsSSKey Types.Chroot = SSHvparamsChroot
hvparamsSSKey Types.XenHvm = SSHvparamsXenHvm
hvparamsSSKey Types.Lxc = SSHvparamsLxc
hvparamsSSKey Types.Fake = SSHvparamsFake
-- | Convert a ssconf key into a (full) file path. -- | Convert a ssconf key into a (full) file path.
keyToFilename :: FilePath -- ^ Config path root keyToFilename :: FilePath -- ^ Config path root
-> SSKey -- ^ Ssconf key -> SSKey -- ^ Ssconf key
......
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