Hs2Py constants: add 'diskDtDefaults'
authorJose A. Lopes <jabolopes@google.com>
Tue, 15 Oct 2013 16:22:17 +0000 (18:22 +0200)
committerJose A. Lopes <jabolopes@google.com>
Mon, 28 Oct 2013 10:04:55 +0000 (11:04 +0100)
* add constant 'diskDtDefaults' to the Haskell to Python constant
  generation

* remove 2 local variables which were used only by 'DISK_DT_DEFAULTS'
  and are, therefore, no longer necessary

Signed-off-by: Jose A. Lopes <jabolopes@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/constants.py
src/Ganeti/HsConstants.hs

index 44dbb0a..eea2bb2 100644 (file)
@@ -1284,45 +1284,7 @@ NDC_DEFAULTS = _constants.NDC_DEFAULTS
 NDC_GLOBALS = _constants.NDC_GLOBALS
 
 DISK_LD_DEFAULTS = _constants.DISK_LD_DEFAULTS
-
-# readability shortcuts
-_LV_DEFAULTS = DISK_LD_DEFAULTS[DT_PLAIN]
-_DRBD_DEFAULTS = DISK_LD_DEFAULTS[DT_DRBD8]
-
-DISK_DT_DEFAULTS = {
-  DT_PLAIN: {
-    LV_STRIPES: DISK_LD_DEFAULTS[DT_PLAIN][LDP_STRIPES],
-    },
-  DT_DRBD8: {
-    DRBD_RESYNC_RATE: _DRBD_DEFAULTS[LDP_RESYNC_RATE],
-    DRBD_DATA_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
-    DRBD_META_STRIPES: _LV_DEFAULTS[LDP_STRIPES],
-    DRBD_DISK_BARRIERS: _DRBD_DEFAULTS[LDP_BARRIERS],
-    DRBD_META_BARRIERS: _DRBD_DEFAULTS[LDP_NO_META_FLUSH],
-    DRBD_DEFAULT_METAVG: _DRBD_DEFAULTS[LDP_DEFAULT_METAVG],
-    DRBD_DISK_CUSTOM: _DRBD_DEFAULTS[LDP_DISK_CUSTOM],
-    DRBD_NET_CUSTOM: _DRBD_DEFAULTS[LDP_NET_CUSTOM],
-    DRBD_PROTOCOL: _DRBD_DEFAULTS[LDP_PROTOCOL],
-    DRBD_DYNAMIC_RESYNC: _DRBD_DEFAULTS[LDP_DYNAMIC_RESYNC],
-    DRBD_PLAN_AHEAD: _DRBD_DEFAULTS[LDP_PLAN_AHEAD],
-    DRBD_FILL_TARGET: _DRBD_DEFAULTS[LDP_FILL_TARGET],
-    DRBD_DELAY_TARGET: _DRBD_DEFAULTS[LDP_DELAY_TARGET],
-    DRBD_MAX_RATE: _DRBD_DEFAULTS[LDP_MAX_RATE],
-    DRBD_MIN_RATE: _DRBD_DEFAULTS[LDP_MIN_RATE],
-    },
-  DT_DISKLESS: {},
-  DT_FILE: {},
-  DT_SHARED_FILE: {},
-  DT_BLOCK: {},
-  DT_RBD: {
-    RBD_POOL: DISK_LD_DEFAULTS[DT_RBD][LDP_POOL],
-    RBD_ACCESS: DISK_LD_DEFAULTS[DT_RBD][LDP_ACCESS],
-    },
-  DT_EXT: {},
-  }
-
-# we don't want to export the shortcuts
-del _LV_DEFAULTS, _DRBD_DEFAULTS
+DISK_DT_DEFAULTS = _constants.DISK_DT_DEFAULTS
 
 NICC_DEFAULTS = _constants.NICC_DEFAULTS
 ISPECS_MINMAX_DEFAULTS = _constants.ISPECS_MINMAX_DEFAULTS
index 17d36ed..f3b6926 100644 (file)
@@ -3505,39 +3505,99 @@ ndcDefaults =
 ndcGlobals :: FrozenSet String
 ndcGlobals = ConstantUtils.mkSet [ndExclusiveStorage]
 
+-- | Default delay target measured in sectors
+defaultDelayTarget :: Int
+defaultDelayTarget = 1
+
+defaultDiskCustom :: String
+defaultDiskCustom = ""
+
+defaultDiskResync :: Bool
+defaultDiskResync = False
+
+-- | Default fill target measured in sectors
+defaultFillTarget :: Int
+defaultFillTarget = 0
+
+-- | Default mininum rate measured in KiB/s
+defaultMinRate :: Int
+defaultMinRate = 4 * 1024
+
+defaultNetCustom :: String
+defaultNetCustom = ""
+
+-- | Default plan ahead measured in sectors
+--
+-- The default values for the DRBD dynamic resync speed algorithm are
+-- taken from the drbsetup 8.3.11 man page, except for c-plan-ahead
+-- (that we don't need to set to 0, because we have a separate option
+-- to enable it) and for c-max-rate, that we cap to the default value
+-- for the static resync rate.
+defaultPlanAhead :: Int
+defaultPlanAhead = 20
+
+defaultRbdPool :: String
+defaultRbdPool = "rbd"
+
 diskLdDefaults :: Map DiskTemplate (Map String PyValueEx)
 diskLdDefaults =
   Map.fromList
-  [ (DTDrbd8, Map.fromList
-              [ (ldpBarriers, PyValueEx drbdBarriers)
+  [ (DTBlock, Map.empty)
+  , (DTDrbd8, Map.fromList
+              [ (ldpBarriers,      PyValueEx drbdBarriers)
               , (ldpDefaultMetavg, PyValueEx defaultVg)
-              , (ldpDelayTarget, PyValueEx (1 :: Int)) -- ds
-              , (ldpDiskCustom, PyValueEx "")
-              , (ldpDynamicResync, PyValueEx False)
-              , (ldpFillTarget, PyValueEx (0 :: Int)) -- sectors
-              , (ldpMaxRate, PyValueEx (classicDrbdSyncSpeed :: Int)) -- KiB/s
-              , (ldpMinRate, PyValueEx (4 * 1024 :: Int)) -- KiB/s
-              , (ldpNetCustom, PyValueEx "")
-              , (ldpNoMetaFlush, PyValueEx drbdNoMetaFlush)
-                -- The default values for the DRBD dynamic resync
-                -- speed algorithm are taken from the drbsetup 8.3.11
-                -- man page, except for c-plan-ahead (that we don't
-                -- need to set to 0, because we have a separate option
-                -- to enable it) and for c-max-rate, that we cap to
-                -- the default value for the static resync rate.
-              , (ldpPlanAhead, PyValueEx (20 :: Int)) -- ds
-              , (ldpProtocol, PyValueEx drbdDefaultNetProtocol)
-              , (ldpResyncRate, PyValueEx classicDrbdSyncSpeed)
+              , (ldpDelayTarget,   PyValueEx defaultDelayTarget)
+              , (ldpDiskCustom,    PyValueEx defaultDiskCustom)
+              , (ldpDynamicResync, PyValueEx defaultDiskResync)
+              , (ldpFillTarget,    PyValueEx defaultFillTarget)
+              , (ldpMaxRate,       PyValueEx classicDrbdSyncSpeed)
+              , (ldpMinRate,       PyValueEx defaultMinRate)
+              , (ldpNetCustom,     PyValueEx defaultNetCustom)
+              , (ldpNoMetaFlush,   PyValueEx drbdNoMetaFlush)
+              , (ldpPlanAhead,     PyValueEx defaultPlanAhead)
+              , (ldpProtocol,      PyValueEx drbdDefaultNetProtocol)
+              , (ldpResyncRate,    PyValueEx classicDrbdSyncSpeed)
               ])
-  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
+  , (DTExt, Map.empty)
   , (DTFile, Map.empty)
-  , (DTSharedFile, Map.empty)
-  , (DTBlock, Map.empty)
+  , (DTPlain, Map.fromList [(ldpStripes, PyValueEx lvmStripecount)])
   , (DTRbd, Map.fromList
-            [ (ldpPool, PyValueEx "rbd")
+            [ (ldpPool, PyValueEx defaultRbdPool)
             , (ldpAccess, PyValueEx diskKernelspace)
             ])
-  , (DTExt, Map.empty)
+  , (DTSharedFile, Map.empty)
+  ]
+
+diskDtDefaults :: Map DiskTemplate (Map String PyValueEx)
+diskDtDefaults =
+  Map.fromList
+  [ (DTBlock,      Map.empty)
+  , (DTDiskless,   Map.empty)
+  , (DTDrbd8,      Map.fromList
+                   [ (drbdDataStripes,   PyValueEx lvmStripecount)
+                   , (drbdDefaultMetavg, PyValueEx defaultVg)
+                   , (drbdDelayTarget,   PyValueEx defaultDelayTarget)
+                   , (drbdDiskBarriers,  PyValueEx drbdBarriers)
+                   , (drbdDiskCustom,    PyValueEx defaultDiskCustom)
+                   , (drbdDynamicResync, PyValueEx defaultDiskResync)
+                   , (drbdFillTarget,    PyValueEx defaultFillTarget)
+                   , (drbdMaxRate,       PyValueEx classicDrbdSyncSpeed)
+                   , (drbdMetaBarriers,  PyValueEx drbdNoMetaFlush)
+                   , (drbdMetaStripes,   PyValueEx lvmStripecount)
+                   , (drbdMinRate,       PyValueEx defaultMinRate)
+                   , (drbdNetCustom,     PyValueEx defaultNetCustom)
+                   , (drbdPlanAhead,     PyValueEx defaultPlanAhead)
+                   , (drbdProtocol,      PyValueEx drbdDefaultNetProtocol)
+                   , (drbdResyncRate,    PyValueEx classicDrbdSyncSpeed)
+                   ])
+  , (DTExt,        Map.empty)
+  , (DTFile,       Map.empty)
+  , (DTPlain,      Map.fromList [(lvStripes, PyValueEx lvmStripecount)])
+  , (DTRbd,        Map.fromList
+                   [ (rbdPool, PyValueEx defaultRbdPool)
+                   , (rbdAccess, PyValueEx diskKernelspace)
+                   ])
+  , (DTSharedFile, Map.empty)
   ]
 
 niccDefaults :: Map String PyValueEx