Hs2Py constants: nics
authorJose A. Lopes <jabolopes@google.com>
Fri, 4 Oct 2013 16:28:12 +0000 (18:28 +0200)
committerJose A. Lopes <jabolopes@google.com>
Tue, 8 Oct 2013 12:57:29 +0000 (14:57 +0200)
Add nics related constants to the Haskell to Python constant
generation.

Signed-off-by: Jose A. Lopes <jabolopes@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

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

index c97fa37..81929c4 100644 (file)
@@ -808,10 +808,11 @@ OOB_STATUSES = _constants.OOB_STATUSES
 # Instance Parameters Profile
 PP_DEFAULT = "default"
 
-# NIC_* constants are used inside the ganeti config
 NIC_MODE = _constants.NIC_MODE
 NIC_LINK = _constants.NIC_LINK
 NIC_VLAN = _constants.NIC_VLAN
+NICS_PARAMETER_TYPES = _constants.NICS_PARAMETER_TYPES
+NICS_PARAMETERS = _constants.NICS_PARAMETERS
 
 NIC_MODE_BRIDGED = _constants.NIC_MODE_BRIDGED
 NIC_MODE_ROUTED = _constants.NIC_MODE_ROUTED
@@ -822,14 +823,6 @@ NIC_VALID_MODES = _constants.NIC_VALID_MODES
 RESERVE_ACTION = "reserve"
 RELEASE_ACTION = "release"
 
-NICS_PARAMETER_TYPES = {
-  NIC_MODE: VTYPE_STRING,
-  NIC_LINK: VTYPE_STRING,
-  NIC_VLAN: VTYPE_MAYBE_STRING,
-  }
-
-NICS_PARAMETERS = frozenset(NICS_PARAMETER_TYPES.keys())
-
 # IDISK_* constants are used in opcodes, to create/change disks
 IDISK_SIZE = "size"
 IDISK_SPINDLES = "spindles"
index 9b1aaea..fe80e55 100644 (file)
@@ -2096,7 +2096,7 @@ oobStatusWarning = Types.oobStatusToRaw OobStatusWarning
 oobStatuses :: FrozenSet String
 oobStatuses = ConstantUtils.mkSet $ map Types.oobStatusToRaw [minBound..]
 
--- * NIC_* constants are used inside the ganeti config
+-- * nic* constants are used inside the ganeti config
 
 nicLink :: String
 nicLink = "link"
@@ -2107,6 +2107,15 @@ nicMode = "mode"
 nicVlan :: String
 nicVlan = "vlan"
 
+nicsParameterTypes :: Map String VType
+nicsParameterTypes =
+  Map.fromList [(nicMode, vtypeString),
+                (nicLink, vtypeString),
+                (nicVlan, vtypeMaybeString)]
+
+nicsParameters :: FrozenSet String
+nicsParameters = ConstantUtils.mkSet (Map.keys nicsParameterTypes)
+
 nicModeBridged :: String
 nicModeBridged = Types.nICModeToRaw NMBridged