ganeti

Safe HaskellNone

Ganeti.Objects

Contents

Description

Implementation of the Ganeti config objects.

Some object fields are not implemented yet, and as such they are commented out below.

Synopsis

Generic definitions

fillDict :: Ord k => Map k v -> Map k v -> [k] -> Map k vSource

Fills one map with keys from the other map, if not already existing. Mirrors objects.py:FillDict.

type HvParams = Container JSValueSource

The hypervisor parameter type. This is currently a simple map, without type checking on key/value pairs.

type OsParams = Container StringSource

The OS parameters type. This is, and will remain, a string container, since the keys are dynamically declared by the OSes, and the values are always strings.

class TimeStampObject a whereSource

Class of objects that have timestamps.

Methods

cTimeOf :: a -> DoubleSource

mTimeOf :: a -> DoubleSource

class UuidObject a whereSource

Class of objects that have an UUID.

Methods

uuidOf :: a -> StringSource

class TagsObject a whereSource

Class of objects that have tags.

Methods

tagsOf :: a -> Set StringSource

Network definitions

Ipv4 types

data Ip4Address Source

Custom type for a simple IPv4 address.

Constructors

Ip4Address Word8 Word8 Word8 Word8 

Instances

Eq Ip4Address 
Show Ip4Address 
IsString Ip4Address

IsString instance for Ip4Address, to help write the tests.

Arbitrary Ip4Address 
JSON Ip4Address

JSON instance for Ip4Address.

readIp4Address :: (Applicative m, Monad m) => String -> m Ip4AddressSource

Parses an IPv4 address from a string.

nextIp4Address :: Ip4Address -> Ip4AddressSource

"Next" address implementation for IPv4 addresses.

Note that this loops! Note also that this is a very dumb implementation.

data Ip4Network Source

Custom type for an IPv4 network.

Constructors

Ip4Network Ip4Address Word8 

Instances

Eq Ip4Network 
Show Ip4Network 
Arbitrary Ip4Network 
JSON Ip4Network

JSON instance for Ip4Network.

Ganeti "network" config object.

data Network Source

Constructors

Network 

Fields

networkName :: NonEmptyString
 
networkMacPrefix :: Maybe String
 
networkNetwork :: Ip4Network
 
networkNetwork6 :: Maybe String
 
networkGateway :: Maybe Ip4Address
 
networkGateway6 :: Maybe String
 
networkReservations :: Maybe String
 
networkExtReservations :: Maybe String
 
networkUuid :: String
 
networkCtime :: Double
 
networkMtime :: Double
 
networkSerial :: Int
 
networkTags :: TagSet
 

loadNetwork :: JSValue -> Result NetworkSource

toDictNetwork :: Network -> [(String, JSValue)]Source

NIC definitions

data PartialNicParams Source

Constructors

PartialNicParams 

Fields

nicpModeP :: Maybe NICMode
 
nicpLinkP :: Maybe String
 
nicpVlanP :: Maybe String
 

data PartialNic Source

Constructors

PartialNic 

Fields

nicMac :: String
 
nicIp :: Maybe String
 
nicNicparams :: PartialNicParams
 
nicNetwork :: Maybe String
 
nicName :: Maybe String
 
nicUuid :: String
 

Instances

loadPartialNic :: JSValue -> Result PartialNicSource

toDictPartialNic :: PartialNic -> [(String, JSValue)]Source

Disk definitions

devType :: StringSource

data DiskLogicalId Source

The disk configuration type. This includes the disk type itself, for a more complete consistency. Note that since in the Python code-base there's no authoritative place where we document the logical id, this is probably a good reference point.

Constructors

LIDPlain String String

Volume group, logical volume

LIDDrbd8 String String Int Int Int String

NodeA, NodeB, Port, MinorA, MinorB, Secret

LIDFile FileDriver String

Driver, path

LIDSharedFile FileDriver String

Driver, path

LIDBlockDev BlockDriver String

Driver, path (must be under /dev)

LIDRados String String

Unused, path

LIDExt String String

ExtProvider, unique name

Instances

lidEncodeType :: DiskLogicalId -> [(String, JSValue)]Source

encodeFullDLId :: DiskLogicalId -> (JSValue, [(String, JSValue)])Source

decodeDLId :: [(String, JSValue)] -> JSValue -> Result DiskLogicalIdSource

data Disk Source

Disk data structure.

This is declared manually as it's a recursive structure, and our TH code currently can't build it.

Constructors

Disk 

Fields

diskLogicalId :: DiskLogicalId
 
diskChildren :: [Disk]
 
diskIvName :: String
 
diskSize :: Int
 
diskMode :: DiskMode
 
diskName :: Maybe String
 
diskSpindles :: Maybe Int
 
diskUuid :: String
 

Instances

Eq Disk 
Show Disk 
Arbitrary Disk

Disk arbitrary instance. Since we don't test disk hierarchy properties, we only generate disks with no children (FIXME), as generating recursive datastructures is a bit more work.

JSON Disk 
UuidObject Disk 

loadDisk :: JSValue -> Result DiskSource

saveDisk :: Disk -> JSValueSource

toDictDisk :: Disk -> [(String, JSValue)]Source

includesLogicalId :: String -> String -> Disk -> BoolSource

Determines whether a disk or one of his children has the given logical id (determined by the volume group name and by the logical volume name). This can be true only for DRBD or LVM disks.

Instance definitions

data FilledBeParams Source

Constructors

FilledBeParams 

Fields

bepMinmem :: Int
 
bepMaxmem :: Int
 
bepVcpus :: Int
 
bepAutoBalance :: Bool
 
bepAlwaysFailover :: Bool
 
bepSpindleUse :: Int
 

data PartialBeParams Source

Constructors

PartialBeParams 

Fields

bepMinmemP :: Maybe Int
 
bepMaxmemP :: Maybe Int
 
bepVcpusP :: Maybe Int
 
bepAutoBalanceP :: Maybe Bool
 
bepAlwaysFailoverP :: Maybe Bool
 
bepSpindleUseP :: Maybe Int
 

Instances

toDictFilledBeParams :: FilledBeParams -> [(String, JSValue)]Source

loadInstance :: JSValue -> Result InstanceSource

toDictInstance :: Instance -> [(String, JSValue)]Source

getDiskSizeRequirements :: Instance -> IntSource

Retrieves the real disk size requirements for all the disks of the instance. This includes the metadata etc. and is different from the values visible to the instance.

IPolicy definitions

data PartialISpecParams Source

Constructors

PartialISpecParams 

Fields

ispecMemorySizeP :: Maybe Int
 
ispecDiskSizeP :: Maybe Int
 
ispecDiskCountP :: Maybe Int
 
ispecCpuCountP :: Maybe Int
 
ispecNicCountP :: Maybe Int
 
ispecSpindleUseP :: Maybe Int
 

Instances

Eq PartialISpecParams 
Show PartialISpecParams 
Arbitrary PartialISpecParams

FIXME: This generates completely random data, without normal validation rules.

JSON PartialISpecParams 

toDictMinMaxISpecs :: MinMaxISpecs -> [(String, JSValue)]Source

data PartialIPolicy Source

Custom partial ipolicy. This is not built via buildParam since it has a special 2-level inheritance mode.

Instances

Eq PartialIPolicy 
Show PartialIPolicy 
Arbitrary PartialIPolicy

FIXME: This generates completely random data, without normal validation rules.

JSON PartialIPolicy 

toDictPartialIPolicy :: PartialIPolicy -> [(String, JSValue)]Source

data FilledIPolicy Source

Custom filled ipolicy. This is not built via buildParam since it has a special 2-level inheritance mode.

Instances

toDictFilledIPolicy :: FilledIPolicy -> [(String, JSValue)]Source

fillIPolicy :: FilledIPolicy -> PartialIPolicy -> FilledIPolicySource

Custom filler for the ipolicy types.

Node definitions

data FilledNDParams Source

Constructors

FilledNDParams 

Fields

ndpOobProgram :: String
 
ndpSpindleCount :: Int
 
ndpExclusiveStorage :: Bool
 
ndpOvs :: Bool
 
ndpOvsName :: String
 
ndpOvsLink :: String
 
ndpSshPort :: Int
 

data PartialNDParams Source

Constructors

PartialNDParams 

Fields

ndpOobProgramP :: Maybe String
 
ndpSpindleCountP :: Maybe Int
 
ndpExclusiveStorageP :: Maybe Bool
 
ndpOvsP :: Maybe Bool
 
ndpOvsNameP :: Maybe String
 
ndpOvsLinkP :: Maybe String
 
ndpSshPortP :: Maybe Int
 

Instances

toDictFilledNDParams :: FilledNDParams -> [(String, JSValue)]Source

data Node Source

Constructors

Node 

Fields

nodeName :: String
 
nodePrimaryIp :: String
 
nodeSecondaryIp :: String
 
nodeMasterCandidate :: Bool
 
nodeOffline :: Bool
 
nodeDrained :: Bool
 
nodeGroup :: String
 
nodeMasterCapable :: Bool
 
nodeVmCapable :: Bool
 
nodeNdparams :: PartialNDParams
 
nodePowered :: Bool
 
nodeCtime :: Double
 
nodeMtime :: Double
 
nodeUuid :: String
 
nodeSerial :: Int
 
nodeTags :: TagSet
 

loadNode :: JSValue -> Result NodeSource

saveNode :: Node -> JSValueSource

toDictNode :: Node -> [(String, JSValue)]Source

NodeGroup definitions

type DiskParams = Container (Container JSValue)Source

The disk parameters type.

loadNodeGroup :: JSValue -> Result NodeGroupSource

toDictNodeGroup :: NodeGroup -> [(String, JSValue)]Source

data IpFamily Source

IP family type

Constructors

IpFamilyV4 
IpFamilyV6 

Instances

Bounded IpFamily 
Enum IpFamily 
Eq IpFamily 
Ord IpFamily 
Show IpFamily 
Arbitrary IpFamily 
JSON IpFamily 

ipFamilyFromRaw :: forall m. Monad m => Int -> m IpFamilySource

ipFamilyToVersion :: IpFamily -> IntSource

Conversion from IP family to IP version. This is needed because Python uses both, depending on context.

type ClusterHvParams = Container HvParamsSource

Cluster HvParams (hvtype to hvparams mapping).

type OsHvParams = Container ClusterHvParamsSource

Cluster Os-HvParams (os to hvparams mapping).

type ClusterOsParams = Container OsParamsSource

Cluster OsParams.

type UidPool = [(Int, Int)]Source

type IAllocatorParams = Container JSValueSource

The iallocator parameters type.

Cluster definitions

data Cluster Source

Constructors

Cluster 

Fields

clusterRsahostkeypub :: String
 
clusterDsahostkeypub :: Maybe String
 
clusterHighestUsedPort :: Int
 
clusterTcpudpPortPool :: [Int]
 
clusterMacPrefix :: String
 
clusterVolumeGroupName :: Maybe String
 
clusterReservedLvs :: [String]
 
clusterDrbdUsermodeHelper :: Maybe String
 
clusterMasterNode :: String
 
clusterMasterIp :: String
 
clusterMasterNetdev :: String
 
clusterMasterNetmask :: Int
 
clusterUseExternalMipScript :: Bool
 
clusterClusterName :: String
 
clusterFileStorageDir :: String
 
clusterSharedFileStorageDir :: String
 
clusterGlusterStorageDir :: String
 
clusterEnabledHypervisors :: [Hypervisor]
 
clusterHvparams :: ClusterHvParams
 
clusterOsHvp :: OsHvParams
 
clusterBeparams :: ClusterBeParams
 
clusterOsparams :: ClusterOsParams
 
clusterNicparams :: ClusterNicParams
 
clusterNdparams :: FilledNDParams
 
clusterDiskparams :: DiskParams
 
clusterCandidatePoolSize :: Int
 
clusterModifyEtcHosts :: Bool
 
clusterModifySshSetup :: Bool
 
clusterMaintainNodeHealth :: Bool
 
clusterUidPool :: UidPool
 
clusterDefaultIallocator :: String
 
clusterDefaultIallocatorParams :: IAllocatorParams
 
clusterHiddenOs :: [String]
 
clusterBlacklistedOs :: [String]
 
clusterPrimaryIpFamily :: IpFamily
 
clusterPreallocWipeDisks :: Bool
 
clusterIpolicy :: FilledIPolicy
 
clusterEnabledDiskTemplates :: [DiskTemplate]
 
clusterCandidateCerts :: CandidateCertificates
 
clusterMaxRunningJobs :: Int
 
clusterEnabledUserShutdown :: Bool
 
clusterCtime :: Double
 
clusterMtime :: Double
 
clusterUuid :: String
 
clusterSerial :: Int
 
clusterTags :: TagSet
 

loadCluster :: JSValue -> Result ClusterSource

toDictCluster :: Cluster -> [(String, JSValue)]Source

ConfigData definitions

loadConfigData :: JSValue -> Result ConfigDataSource

toDictConfigData :: ConfigData -> [(String, JSValue)]Source