Revision ecf43dcb

b/lib/constants.py
976 976
  DS_DISK_OVERHEAD: 0,
977 977
  }
978 978

  
979
ND_OOB_PROGRAM = _constants.ND_OOB_PROGRAM
980
ND_SPINDLE_COUNT = _constants.ND_SPINDLE_COUNT
981
ND_EXCLUSIVE_STORAGE = _constants.ND_EXCLUSIVE_STORAGE
982
ND_OVS = _constants.ND_OVS
983
ND_OVS_NAME = _constants.ND_OVS_NAME
984
ND_OVS_LINK = _constants.ND_OVS_LINK
985

  
986
NDS_PARAMETER_TYPES = _constants.NDS_PARAMETER_TYPES
987
NDS_PARAMETERS = _constants.NDS_PARAMETERS
988
NDS_PARAMETER_TITLES = _constants.NDS_PARAMETER_TITLES
979 989
DSS_PARAMETER_TYPES = {
980 990
  DS_DISK_TOTAL: VTYPE_INT,
981 991
  DS_DISK_RESERVED: VTYPE_INT,
......
1057 1067
IPOLICY_ALL_KEYS = (IPOLICY_PARAMETERS |
1058 1068
                    frozenset([ISPECS_MINMAX, ISPECS_STD, IPOLICY_DTS]))
1059 1069

  
1060
# Node parameter names
1061
ND_OOB_PROGRAM = "oob_program"
1062
ND_SPINDLE_COUNT = "spindle_count"
1063
ND_EXCLUSIVE_STORAGE = "exclusive_storage"
1064
ND_OVS = "ovs"
1065
ND_OVS_NAME = "ovs_name"
1066
ND_OVS_LINK = "ovs_link"
1067

  
1068
NDS_PARAMETER_TYPES = {
1069
  ND_OOB_PROGRAM: VTYPE_STRING,
1070
  ND_SPINDLE_COUNT: VTYPE_INT,
1071
  ND_EXCLUSIVE_STORAGE: VTYPE_BOOL,
1072
  ND_OVS: VTYPE_BOOL,
1073
  ND_OVS_NAME: VTYPE_MAYBE_STRING,
1074
  ND_OVS_LINK: VTYPE_MAYBE_STRING,
1075
  }
1076

  
1077
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
1078

  
1079
NDS_PARAMETER_TITLES = {
1080
  ND_OOB_PROGRAM: "OutOfBandProgram",
1081
  ND_SPINDLE_COUNT: "SpindleCount",
1082
  ND_EXCLUSIVE_STORAGE: "ExclusiveStorage",
1083
  ND_OVS: "OpenvSwitch",
1084
  ND_OVS_NAME: "OpenvSwitchName",
1085
  ND_OVS_LINK: "OpenvSwitchLink",
1086
  }
1087

  
1088 1070
# Logical Disks parameters
1089 1071
LDP_RESYNC_RATE = "resync-rate"
1090 1072
LDP_STRIPES = "stripes"
b/src/Ganeti/HsConstants.hs
38 38

  
39 39
import Data.List ((\\))
40 40
import Data.Map (Map)
41
import qualified Data.Map as Map (fromList)
41
import qualified Data.Map as Map (fromList, keys, insert)
42 42

  
43 43
import AutoConf
44 44
import Ganeti.ConstantUtils (FrozenSet, Protocol(..), buildVersion)
......
664 664
rpcConnectTimeout :: Int
665 665
rpcConnectTimeout = 5
666 666

  
667
-- | Node parameter names
668

  
669
ndExclusiveStorage :: String
670
ndExclusiveStorage = "exclusive_storage"
671

  
672
ndOobProgram :: String
673
ndOobProgram = "oob_program"
674

  
675
ndSpindleCount :: String
676
ndSpindleCount = "spindle_count"
677

  
678
ndOvs :: String
679
ndOvs = "ovs"
680

  
681
ndOvsLink :: String
682
ndOvsLink = "ovs_link"
683

  
684
ndOvsName :: String
685
ndOvsName = "ovs_name"
686

  
687
ndsParameterTypes :: Map String VType
688
ndsParameterTypes =
689
  Map.fromList
690
  [(ndExclusiveStorage, VTypeBool),
691
   (ndOobProgram, VTypeString),
692
   (ndOvs, VTypeBool),
693
   (ndOvsLink, VTypeMaybeString),
694
   (ndOvsName, VTypeMaybeString),
695
   (ndSpindleCount, VTypeInt)]
696

  
697
ndsParameters :: FrozenSet String
698
ndsParameters = ConstantUtils.mkSet (Map.keys ndsParameterTypes)
699

  
700
ndsParameterTitles :: Map String String
701
ndsParameterTitles =
702
  Map.fromList
703
  [(ndExclusiveStorage, "ExclusiveStorage"),
704
   (ndOobProgram, "OutOfBandProgram"),
705
   (ndOvs, "OpenvSwitch"),
706
   (ndOvsLink, "OpenvSwitchLink"),
707
   (ndOvsName, "OpenvSwitchName"),
708
   (ndSpindleCount, "SpindleCount")]
709

  
667 710
ipCommandPath :: String
668 711
ipCommandPath = AutoConf.ipPath
669 712

  
b/src/Ganeti/Query/Common.hs
37 37
  , serialFields
38 38
  , tagsFields
39 39
  , dictFieldGetter
40
  , buildQFTLookup
41 40
  , buildNdParamField
42 41
  ) where
43 42

  
......
147 146
dictFieldGetter :: (DictObject a) => String -> Maybe a -> ResultEntry
148 147
dictFieldGetter k = maybe rsNoData (rsMaybeNoData . lookup k . toDict)
149 148

  
150
-- | Build an optimised lookup map from a Python _PARAMETER_TYPES
151
-- association list.
152
buildQFTLookup :: [(String, String)] -> Map.Map String FieldType
153
buildQFTLookup =
154
  Map.fromList .
155
  map (\(k, v) -> (k, maybe QFTOther vTypeToQFT (vTypeFromRaw v)))
156

  
157 149
-- | Ndparams optimised lookup map.
158 150
ndParamTypes :: Map.Map String FieldType
159
ndParamTypes = buildQFTLookup C.ndsParameterTypes
151
ndParamTypes = Map.map vTypeToQFT C.ndsParameterTypes
160 152

  
161 153
-- | Ndparams title map.
162 154
ndParamTitles :: Map.Map String FieldTitle
163
ndParamTitles = Map.fromList C.ndsParameterTitles
155
ndParamTitles = C.ndsParameterTitles
164 156

  
165 157
-- | Ndparam getter builder: given a field, it returns a FieldConfig
166 158
-- getter, that is a function that takes the config and the object and

Also available in: Unified diff