Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / Objects.hs @ 277a2ec9

History | View | Annotate | Download (21.2 kB)

1
{-# LANGUAGE TemplateHaskell #-}
2

    
3
{-| Implementation of the Ganeti config objects.
4

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

    
8
-}
9

    
10
{-
11

    
12
Copyright (C) 2011, 2012 Google Inc.
13

    
14
This program is free software; you can redistribute it and/or modify
15
it under the terms of the GNU General Public License as published by
16
the Free Software Foundation; either version 2 of the License, or
17
(at your option) any later version.
18

    
19
This program is distributed in the hope that it will be useful, but
20
WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
General Public License for more details.
23

    
24
You should have received a copy of the GNU General Public License
25
along with this program; if not, write to the Free Software
26
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27
02110-1301, USA.
28

    
29
-}
30

    
31
module Ganeti.Objects
32
  ( VType(..)
33
  , vTypeFromRaw
34
  , HvParams
35
  , OsParams
36
  , PartialNicParams(..)
37
  , FilledNicParams(..)
38
  , fillNicParams
39
  , allNicParamFields
40
  , PartialNic(..)
41
  , FileDriver(..)
42
  , BlockDriver(..)
43
  , DiskMode(..)
44
  , DiskType(..)
45
  , DiskLogicalId(..)
46
  , Disk(..)
47
  , DiskTemplate(..)
48
  , PartialBeParams(..)
49
  , FilledBeParams(..)
50
  , fillBeParams
51
  , allBeParamFields
52
  , AdminState(..)
53
  , adminStateFromRaw
54
  , Instance(..)
55
  , toDictInstance
56
  , PartialNDParams(..)
57
  , FilledNDParams(..)
58
  , fillNDParams
59
  , allNDParamFields
60
  , Node(..)
61
  , NodeRole(..)
62
  , nodeRoleToRaw
63
  , roleDescription
64
  , AllocPolicy(..)
65
  , FilledISpecParams(..)
66
  , PartialISpecParams(..)
67
  , fillISpecParams
68
  , allISpecParamFields
69
  , FilledIPolicy(..)
70
  , PartialIPolicy(..)
71
  , fillIPolicy
72
  , DiskParams
73
  , NodeGroup(..)
74
  , IpFamily(..)
75
  , ipFamilyToVersion
76
  , fillDict
77
  , ClusterHvParams
78
  , OsHvParams
79
  , ClusterBeParams
80
  , ClusterOsParams
81
  , ClusterNicParams
82
  , Cluster(..)
83
  , ConfigData(..)
84
  , TimeStampObject(..)
85
  , UuidObject(..)
86
  , SerialNoObject(..)
87
  , TagsObject(..)
88
  , DictObject(..) -- re-exported from THH
89
  , TagSet -- re-exported from THH
90
  , Network(..)
91
  ) where
92

    
93
import Data.List (foldl')
94
import Data.Maybe
95
import qualified Data.Map as Map
96
import qualified Data.Set as Set
97
import Text.JSON (showJSON, readJSON, JSON, JSValue(..))
98
import qualified Text.JSON as J
99

    
100
import qualified Ganeti.Constants as C
101
import Ganeti.JSON
102
import Ganeti.Types
103
import Ganeti.THH
104

    
105
-- * Generic definitions
106

    
107
-- | Fills one map with keys from the other map, if not already
108
-- existing. Mirrors objects.py:FillDict.
109
fillDict :: (Ord k) => Map.Map k v -> Map.Map k v -> [k] -> Map.Map k v
110
fillDict defaults custom skip_keys =
111
  let updated = Map.union custom defaults
112
  in foldl' (flip Map.delete) updated skip_keys
113

    
114
-- | The VTYPES, a mini-type system in Python.
115
$(declareSADT "VType"
116
  [ ("VTypeString",      'C.vtypeString)
117
  , ("VTypeMaybeString", 'C.vtypeMaybeString)
118
  , ("VTypeBool",        'C.vtypeBool)
119
  , ("VTypeSize",        'C.vtypeSize)
120
  , ("VTypeInt",         'C.vtypeInt)
121
  ])
122
$(makeJSONInstance ''VType)
123

    
124
-- | The hypervisor parameter type. This is currently a simple map,
125
-- without type checking on key/value pairs.
126
type HvParams = Container JSValue
127

    
128
-- | The OS parameters type. This is, and will remain, a string
129
-- container, since the keys are dynamically declared by the OSes, and
130
-- the values are always strings.
131
type OsParams = Container String
132

    
133
-- | Class of objects that have timestamps.
134
class TimeStampObject a where
135
  cTimeOf :: a -> Double
136
  mTimeOf :: a -> Double
137

    
138
-- | Class of objects that have an UUID.
139
class UuidObject a where
140
  uuidOf :: a -> String
141

    
142
-- | Class of object that have a serial number.
143
class SerialNoObject a where
144
  serialOf :: a -> Int
145

    
146
-- | Class of objects that have tags.
147
class TagsObject a where
148
  tagsOf :: a -> Set.Set String
149

    
150
-- * Node role object
151

    
152
$(declareSADT "NodeRole"
153
  [ ("NROffline",   'C.nrOffline)
154
  , ("NRDrained",   'C.nrDrained)
155
  , ("NRRegular",   'C.nrRegular)
156
  , ("NRCandidate", 'C.nrMcandidate)
157
  , ("NRMaster",    'C.nrMaster)
158
  ])
159
$(makeJSONInstance ''NodeRole)
160

    
161
-- | The description of the node role.
162
roleDescription :: NodeRole -> String
163
roleDescription NROffline   = "offline"
164
roleDescription NRDrained   = "drained"
165
roleDescription NRRegular   = "regular"
166
roleDescription NRCandidate = "master candidate"
167
roleDescription NRMaster    = "master"
168

    
169
-- * Network definitions
170

    
171
-- FIXME: Not all types might be correct here, since they
172
-- haven't been exhaustively deduced from the python code yet.
173
$(buildObject "Network" "network" $
174
  [ simpleField "name"             [t| NonEmptyString |]
175
  , optionalField $
176
    simpleField "network_type"     [t| NetworkType |]
177
  , optionalField $
178
    simpleField "mac_prefix"       [t| String |]
179
  , optionalField $
180
    simpleField "family"           [t| Int |]
181
  , simpleField "network"          [t| NonEmptyString |]
182
  , optionalField $
183
    simpleField "network6"         [t| String |]
184
  , optionalField $
185
    simpleField "gateway"          [t| String |]
186
  , optionalField $
187
    simpleField "gateway6"         [t| String |]
188
  , optionalField $
189
    simpleField "size"             [t| J.JSValue |]
190
  , optionalField $
191
    simpleField "reservations"     [t| String |]
192
  , optionalField $
193
    simpleField "ext_reservations" [t| String |]
194
  ]
195
  ++ serialFields
196
  ++ tagsFields)
197

    
198
instance SerialNoObject Network where
199
  serialOf = networkSerial
200

    
201
instance TagsObject Network where
202
  tagsOf = networkTags
203

    
204
-- * NIC definitions
205

    
206
$(buildParam "Nic" "nicp"
207
  [ simpleField "mode" [t| NICMode |]
208
  , simpleField "link" [t| String  |]
209
  ])
210

    
211
$(buildObject "PartialNic" "nic"
212
  [ simpleField "mac" [t| String |]
213
  , optionalField $ simpleField "ip" [t| String |]
214
  , simpleField "nicparams" [t| PartialNicParams |]
215
  , optionalField $ simpleField "network" [t| Network |]
216
  ])
217

    
218
-- * Disk definitions
219

    
220
$(declareSADT "DiskMode"
221
  [ ("DiskRdOnly", 'C.diskRdonly)
222
  , ("DiskRdWr",   'C.diskRdwr)
223
  ])
224
$(makeJSONInstance ''DiskMode)
225

    
226
$(declareSADT "DiskType"
227
  [ ("LD_LV",       'C.ldLv)
228
  , ("LD_DRBD8",    'C.ldDrbd8)
229
  , ("LD_FILE",     'C.ldFile)
230
  , ("LD_BLOCKDEV", 'C.ldBlockdev)
231
  , ("LD_RADOS",    'C.ldRbd)
232
  , ("LD_EXT",      'C.ldExt)
233
  ])
234
$(makeJSONInstance ''DiskType)
235

    
236
-- | The persistent block driver type. Currently only one type is allowed.
237
$(declareSADT "BlockDriver"
238
  [ ("BlockDrvManual", 'C.blockdevDriverManual)
239
  ])
240
$(makeJSONInstance ''BlockDriver)
241

    
242
-- | Constant for the dev_type key entry in the disk config.
243
devType :: String
244
devType = "dev_type"
245

    
246
-- | The disk configuration type. This includes the disk type itself,
247
-- for a more complete consistency. Note that since in the Python
248
-- code-base there's no authoritative place where we document the
249
-- logical id, this is probably a good reference point.
250
data DiskLogicalId
251
  = LIDPlain String String  -- ^ Volume group, logical volume
252
  | LIDDrbd8 String String Int Int Int String
253
  -- ^ NodeA, NodeB, Port, MinorA, MinorB, Secret
254
  | LIDFile FileDriver String -- ^ Driver, path
255
  | LIDBlockDev BlockDriver String -- ^ Driver, path (must be under /dev)
256
  | LIDRados String String -- ^ Unused, path
257
  | LIDExt String String -- ^ ExtProvider, unique name
258
    deriving (Show, Eq)
259

    
260
-- | Mapping from a logical id to a disk type.
261
lidDiskType :: DiskLogicalId -> DiskType
262
lidDiskType (LIDPlain {}) = LD_LV
263
lidDiskType (LIDDrbd8 {}) = LD_DRBD8
264
lidDiskType (LIDFile  {}) = LD_FILE
265
lidDiskType (LIDBlockDev {}) = LD_BLOCKDEV
266
lidDiskType (LIDRados {}) = LD_RADOS
267
lidDiskType (LIDExt {}) = LD_EXT
268

    
269
-- | Builds the extra disk_type field for a given logical id.
270
lidEncodeType :: DiskLogicalId -> [(String, JSValue)]
271
lidEncodeType v = [(devType, showJSON . lidDiskType $ v)]
272

    
273
-- | Custom encoder for DiskLogicalId (logical id only).
274
encodeDLId :: DiskLogicalId -> JSValue
275
encodeDLId (LIDPlain vg lv) = JSArray [showJSON vg, showJSON lv]
276
encodeDLId (LIDDrbd8 nodeA nodeB port minorA minorB key) =
277
  JSArray [ showJSON nodeA, showJSON nodeB, showJSON port
278
          , showJSON minorA, showJSON minorB, showJSON key ]
279
encodeDLId (LIDRados pool name) = JSArray [showJSON pool, showJSON name]
280
encodeDLId (LIDFile driver name) = JSArray [showJSON driver, showJSON name]
281
encodeDLId (LIDBlockDev driver name) = JSArray [showJSON driver, showJSON name]
282
encodeDLId (LIDExt extprovider name) = JSArray [showJSON extprovider, showJSON name]
283

    
284
-- | Custom encoder for DiskLogicalId, composing both the logical id
285
-- and the extra disk_type field.
286
encodeFullDLId :: DiskLogicalId -> (JSValue, [(String, JSValue)])
287
encodeFullDLId v = (encodeDLId v, lidEncodeType v)
288

    
289
-- | Custom decoder for DiskLogicalId. This is manual for now, since
290
-- we don't have yet automation for separate-key style fields.
291
decodeDLId :: [(String, JSValue)] -> JSValue -> J.Result DiskLogicalId
292
decodeDLId obj lid = do
293
  dtype <- fromObj obj devType
294
  case dtype of
295
    LD_DRBD8 ->
296
      case lid of
297
        JSArray [nA, nB, p, mA, mB, k] -> do
298
          nA' <- readJSON nA
299
          nB' <- readJSON nB
300
          p'  <- readJSON p
301
          mA' <- readJSON mA
302
          mB' <- readJSON mB
303
          k'  <- readJSON k
304
          return $ LIDDrbd8 nA' nB' p' mA' mB' k'
305
        _ -> fail "Can't read logical_id for DRBD8 type"
306
    LD_LV ->
307
      case lid of
308
        JSArray [vg, lv] -> do
309
          vg' <- readJSON vg
310
          lv' <- readJSON lv
311
          return $ LIDPlain vg' lv'
312
        _ -> fail "Can't read logical_id for plain type"
313
    LD_FILE ->
314
      case lid of
315
        JSArray [driver, path] -> do
316
          driver' <- readJSON driver
317
          path'   <- readJSON path
318
          return $ LIDFile driver' path'
319
        _ -> fail "Can't read logical_id for file type"
320
    LD_BLOCKDEV ->
321
      case lid of
322
        JSArray [driver, path] -> do
323
          driver' <- readJSON driver
324
          path'   <- readJSON path
325
          return $ LIDBlockDev driver' path'
326
        _ -> fail "Can't read logical_id for blockdev type"
327
    LD_RADOS ->
328
      case lid of
329
        JSArray [driver, path] -> do
330
          driver' <- readJSON driver
331
          path'   <- readJSON path
332
          return $ LIDRados driver' path'
333
        _ -> fail "Can't read logical_id for rdb type"
334
    LD_EXT ->
335
      case lid of
336
        JSArray [extprovider, name] -> do
337
          extprovider' <- readJSON extprovider
338
          name'   <- readJSON name
339
          return $ LIDExt extprovider' name'
340
        _ -> fail "Can't read logical_id for extstorage type"
341

    
342
-- | Disk data structure.
343
--
344
-- This is declared manually as it's a recursive structure, and our TH
345
-- code currently can't build it.
346
data Disk = Disk
347
  { diskLogicalId  :: DiskLogicalId
348
--  , diskPhysicalId :: String
349
  , diskChildren   :: [Disk]
350
  , diskIvName     :: String
351
  , diskSize       :: Int
352
  , diskMode       :: DiskMode
353
  } deriving (Show, Eq)
354

    
355
$(buildObjectSerialisation "Disk"
356
  [ customField 'decodeDLId 'encodeFullDLId ["dev_type"] $
357
      simpleField "logical_id"    [t| DiskLogicalId   |]
358
--  , simpleField "physical_id" [t| String   |]
359
  , defaultField  [| [] |] $ simpleField "children" [t| [Disk] |]
360
  , defaultField [| "" |] $ simpleField "iv_name" [t| String |]
361
  , simpleField "size" [t| Int |]
362
  , defaultField [| DiskRdWr |] $ simpleField "mode" [t| DiskMode |]
363
  ])
364

    
365
-- * Instance definitions
366

    
367
$(declareSADT "AdminState"
368
  [ ("AdminOffline", 'C.adminstOffline)
369
  , ("AdminDown",    'C.adminstDown)
370
  , ("AdminUp",      'C.adminstUp)
371
  ])
372
$(makeJSONInstance ''AdminState)
373

    
374
$(buildParam "Be" "bep"
375
  [ simpleField "minmem"       [t| Int  |]
376
  , simpleField "maxmem"       [t| Int  |]
377
  , simpleField "vcpus"        [t| Int  |]
378
  , simpleField "auto_balance" [t| Bool |]
379
  ])
380

    
381
$(buildObject "Instance" "inst" $
382
  [ simpleField "name"           [t| String             |]
383
  , simpleField "primary_node"   [t| String             |]
384
  , simpleField "os"             [t| String             |]
385
  , simpleField "hypervisor"     [t| Hypervisor         |]
386
  , simpleField "hvparams"       [t| HvParams           |]
387
  , simpleField "beparams"       [t| PartialBeParams    |]
388
  , simpleField "osparams"       [t| OsParams           |]
389
  , simpleField "admin_state"    [t| AdminState         |]
390
  , simpleField "nics"           [t| [PartialNic]       |]
391
  , simpleField "disks"          [t| [Disk]             |]
392
  , simpleField "disk_template"  [t| DiskTemplate       |]
393
  , optionalField $ simpleField "network_port" [t| Int  |]
394
  ]
395
  ++ timeStampFields
396
  ++ uuidFields
397
  ++ serialFields
398
  ++ tagsFields)
399

    
400
instance TimeStampObject Instance where
401
  cTimeOf = instCtime
402
  mTimeOf = instMtime
403

    
404
instance UuidObject Instance where
405
  uuidOf = instUuid
406

    
407
instance SerialNoObject Instance where
408
  serialOf = instSerial
409

    
410
instance TagsObject Instance where
411
  tagsOf = instTags
412

    
413
-- * IPolicy definitions
414

    
415
$(buildParam "ISpec" "ispec"
416
  [ simpleField C.ispecMemSize     [t| Int |]
417
  , simpleField C.ispecDiskSize    [t| Int |]
418
  , simpleField C.ispecDiskCount   [t| Int |]
419
  , simpleField C.ispecCpuCount    [t| Int |]
420
  , simpleField C.ispecNicCount    [t| Int |]
421
  , simpleField C.ispecSpindleUse  [t| Int |]
422
  ])
423

    
424
-- | Custom partial ipolicy. This is not built via buildParam since it
425
-- has a special 2-level inheritance mode.
426
$(buildObject "PartialIPolicy" "ipolicy"
427
  [ renameField "MinSpecP" $ simpleField "min" [t| PartialISpecParams |]
428
  , renameField "MaxSpecP" $ simpleField "max" [t| PartialISpecParams |]
429
  , renameField "StdSpecP" $ simpleField "std" [t| PartialISpecParams |]
430
  , optionalField . renameField "SpindleRatioP"
431
                    $ simpleField "spindle-ratio"  [t| Double |]
432
  , optionalField . renameField "VcpuRatioP"
433
                    $ simpleField "vcpu-ratio"     [t| Double |]
434
  , optionalField . renameField "DiskTemplatesP"
435
                    $ simpleField "disk-templates" [t| [DiskTemplate] |]
436
  ])
437

    
438
-- | Custom filled ipolicy. This is not built via buildParam since it
439
-- has a special 2-level inheritance mode.
440
$(buildObject "FilledIPolicy" "ipolicy"
441
  [ renameField "MinSpec" $ simpleField "min" [t| FilledISpecParams |]
442
  , renameField "MaxSpec" $ simpleField "max" [t| FilledISpecParams |]
443
  , renameField "StdSpec" $ simpleField "std" [t| FilledISpecParams |]
444
  , simpleField "spindle-ratio"  [t| Double |]
445
  , simpleField "vcpu-ratio"     [t| Double |]
446
  , simpleField "disk-templates" [t| [DiskTemplate] |]
447
  ])
448

    
449
-- | Custom filler for the ipolicy types.
450
fillIPolicy :: FilledIPolicy -> PartialIPolicy -> FilledIPolicy
451
fillIPolicy (FilledIPolicy { ipolicyMinSpec       = fmin
452
                           , ipolicyMaxSpec       = fmax
453
                           , ipolicyStdSpec       = fstd
454
                           , ipolicySpindleRatio  = fspindleRatio
455
                           , ipolicyVcpuRatio     = fvcpuRatio
456
                           , ipolicyDiskTemplates = fdiskTemplates})
457
            (PartialIPolicy { ipolicyMinSpecP       = pmin
458
                            , ipolicyMaxSpecP       = pmax
459
                            , ipolicyStdSpecP       = pstd
460
                            , ipolicySpindleRatioP  = pspindleRatio
461
                            , ipolicyVcpuRatioP     = pvcpuRatio
462
                            , ipolicyDiskTemplatesP = pdiskTemplates}) =
463
  FilledIPolicy { ipolicyMinSpec       = fillISpecParams fmin pmin
464
                , ipolicyMaxSpec       = fillISpecParams fmax pmax
465
                , ipolicyStdSpec       = fillISpecParams fstd pstd
466
                , ipolicySpindleRatio  = fromMaybe fspindleRatio pspindleRatio
467
                , ipolicyVcpuRatio     = fromMaybe fvcpuRatio pvcpuRatio
468
                , ipolicyDiskTemplates = fromMaybe fdiskTemplates
469
                                         pdiskTemplates
470
                }
471
-- * Node definitions
472

    
473
$(buildParam "ND" "ndp"
474
  [ simpleField "oob_program"   [t| String |]
475
  , simpleField "spindle_count" [t| Int    |]
476
  , simpleField "exclusive_storage" [t| Bool |]
477
  ])
478

    
479
$(buildObject "Node" "node" $
480
  [ simpleField "name"             [t| String |]
481
  , simpleField "primary_ip"       [t| String |]
482
  , simpleField "secondary_ip"     [t| String |]
483
  , simpleField "master_candidate" [t| Bool   |]
484
  , simpleField "offline"          [t| Bool   |]
485
  , simpleField "drained"          [t| Bool   |]
486
  , simpleField "group"            [t| String |]
487
  , simpleField "master_capable"   [t| Bool   |]
488
  , simpleField "vm_capable"       [t| Bool   |]
489
  , simpleField "ndparams"         [t| PartialNDParams |]
490
  , simpleField "powered"          [t| Bool   |]
491
  ]
492
  ++ timeStampFields
493
  ++ uuidFields
494
  ++ serialFields
495
  ++ tagsFields)
496

    
497
instance TimeStampObject Node where
498
  cTimeOf = nodeCtime
499
  mTimeOf = nodeMtime
500

    
501
instance UuidObject Node where
502
  uuidOf = nodeUuid
503

    
504
instance SerialNoObject Node where
505
  serialOf = nodeSerial
506

    
507
instance TagsObject Node where
508
  tagsOf = nodeTags
509

    
510
-- * NodeGroup definitions
511

    
512
-- | The disk parameters type.
513
type DiskParams = Container (Container JSValue)
514

    
515
-- | A mapping from network UUIDs to nic params of the networks.
516
type Networks = Container PartialNic
517

    
518
$(buildObject "NodeGroup" "group" $
519
  [ simpleField "name"         [t| String |]
520
  , defaultField [| [] |] $ simpleField "members" [t| [String] |]
521
  , simpleField "ndparams"     [t| PartialNDParams |]
522
  , simpleField "alloc_policy" [t| AllocPolicy     |]
523
  , simpleField "ipolicy"      [t| PartialIPolicy  |]
524
  , simpleField "diskparams"   [t| DiskParams      |]
525
  , simpleField "networks"     [t| Networks        |]
526
  ]
527
  ++ timeStampFields
528
  ++ uuidFields
529
  ++ serialFields
530
  ++ tagsFields)
531

    
532
instance TimeStampObject NodeGroup where
533
  cTimeOf = groupCtime
534
  mTimeOf = groupMtime
535

    
536
instance UuidObject NodeGroup where
537
  uuidOf = groupUuid
538

    
539
instance SerialNoObject NodeGroup where
540
  serialOf = groupSerial
541

    
542
instance TagsObject NodeGroup where
543
  tagsOf = groupTags
544

    
545
-- | IP family type
546
$(declareIADT "IpFamily"
547
  [ ("IpFamilyV4", 'C.ip4Family)
548
  , ("IpFamilyV6", 'C.ip6Family)
549
  ])
550
$(makeJSONInstance ''IpFamily)
551

    
552
-- | Conversion from IP family to IP version. This is needed because
553
-- Python uses both, depending on context.
554
ipFamilyToVersion :: IpFamily -> Int
555
ipFamilyToVersion IpFamilyV4 = C.ip4Version
556
ipFamilyToVersion IpFamilyV6 = C.ip6Version
557

    
558
-- | Cluster HvParams (hvtype to hvparams mapping).
559
type ClusterHvParams = Container HvParams
560

    
561
-- | Cluster Os-HvParams (os to hvparams mapping).
562
type OsHvParams = Container ClusterHvParams
563

    
564
-- | Cluser BeParams.
565
type ClusterBeParams = Container FilledBeParams
566

    
567
-- | Cluster OsParams.
568
type ClusterOsParams = Container OsParams
569

    
570
-- | Cluster NicParams.
571
type ClusterNicParams = Container FilledNicParams
572

    
573
-- | Cluster UID Pool, list (low, high) UID ranges.
574
type UidPool = [(Int, Int)]
575

    
576
-- * Cluster definitions
577
$(buildObject "Cluster" "cluster" $
578
  [ simpleField "rsahostkeypub"           [t| String           |]
579
  , simpleField "highest_used_port"       [t| Int              |]
580
  , simpleField "tcpudp_port_pool"        [t| [Int]            |]
581
  , simpleField "mac_prefix"              [t| String           |]
582
  , simpleField "volume_group_name"       [t| String           |]
583
  , simpleField "reserved_lvs"            [t| [String]         |]
584
  , optionalField $
585
    simpleField "drbd_usermode_helper"    [t| String           |]
586
  , simpleField "master_node"             [t| String           |]
587
  , simpleField "master_ip"               [t| String           |]
588
  , simpleField "master_netdev"           [t| String           |]
589
  , simpleField "master_netmask"          [t| Int              |]
590
  , simpleField "use_external_mip_script" [t| Bool             |]
591
  , simpleField "cluster_name"            [t| String           |]
592
  , simpleField "file_storage_dir"        [t| String           |]
593
  , simpleField "shared_file_storage_dir" [t| String           |]
594
  , simpleField "enabled_hypervisors"     [t| [Hypervisor]     |]
595
  , simpleField "hvparams"                [t| ClusterHvParams  |]
596
  , simpleField "os_hvp"                  [t| OsHvParams       |]
597
  , simpleField "beparams"                [t| ClusterBeParams  |]
598
  , simpleField "osparams"                [t| ClusterOsParams  |]
599
  , simpleField "nicparams"               [t| ClusterNicParams |]
600
  , simpleField "ndparams"                [t| FilledNDParams   |]
601
  , simpleField "diskparams"              [t| DiskParams       |]
602
  , simpleField "candidate_pool_size"     [t| Int              |]
603
  , simpleField "modify_etc_hosts"        [t| Bool             |]
604
  , simpleField "modify_ssh_setup"        [t| Bool             |]
605
  , simpleField "maintain_node_health"    [t| Bool             |]
606
  , simpleField "uid_pool"                [t| UidPool          |]
607
  , simpleField "default_iallocator"      [t| String           |]
608
  , simpleField "hidden_os"               [t| [String]         |]
609
  , simpleField "blacklisted_os"          [t| [String]         |]
610
  , simpleField "primary_ip_family"       [t| IpFamily         |]
611
  , simpleField "prealloc_wipe_disks"     [t| Bool             |]
612
  , simpleField "ipolicy"                 [t| FilledIPolicy    |]
613
 ]
614
 ++ timeStampFields
615
 ++ uuidFields
616
 ++ serialFields
617
 ++ tagsFields)
618

    
619
instance TimeStampObject Cluster where
620
  cTimeOf = clusterCtime
621
  mTimeOf = clusterMtime
622

    
623
instance UuidObject Cluster where
624
  uuidOf = clusterUuid
625

    
626
instance SerialNoObject Cluster where
627
  serialOf = clusterSerial
628

    
629
instance TagsObject Cluster where
630
  tagsOf = clusterTags
631

    
632
-- * ConfigData definitions
633

    
634
$(buildObject "ConfigData" "config" $
635
--  timeStampFields ++
636
  [ simpleField "version"    [t| Int                 |]
637
  , simpleField "cluster"    [t| Cluster             |]
638
  , simpleField "nodes"      [t| Container Node      |]
639
  , simpleField "nodegroups" [t| Container NodeGroup |]
640
  , simpleField "instances"  [t| Container Instance  |]
641
  ]
642
  ++ serialFields)
643

    
644
instance SerialNoObject ConfigData where
645
  serialOf = configSerial