Revision 095e71aa lib/objects.py

b/lib/objects.py
942 942
    "group",
943 943
    "master_capable",
944 944
    "vm_capable",
945
    "ndparams",
945 946
    ] + _TIMESTAMPS + _UUID
946 947

  
947 948
  def UpgradeConfig(self):
......
956 957
    if self.vm_capable is None:
957 958
      self.vm_capable = True
958 959

  
960
    if self.ndparams is None:
961
      self.ndparams = {}
962

  
959 963

  
960 964
class NodeGroup(ConfigObject):
961 965
  """Config object representing a node group."""
962 966
  __slots__ = [
963 967
    "name",
964 968
    "members",
969
    "ndparams",
965 970
    ] + _TIMESTAMPS + _UUID
966 971

  
967 972
  def ToDict(self):
......
986 991
    obj.members = []
987 992
    return obj
988 993

  
994
  def UpgradeConfig(self):
995
    """Fill defaults for missing configuration values.
996

  
997
    """
998
    if self.ndparams is None:
999
      self.ndparams = {}
1000

  
1001
  def FillND(self, node):
1002
    """Return filled out ndparams for L{object.Node}
1003

  
1004
    @type node: L{objects.Node}
1005
    @param node: A Node object to fill
1006
    @return a copy of the node's ndparams with defaults filled
1007

  
1008
    """
1009
    return self.SimpleFillND(node.ndparams)
1010

  
1011
  def SimpleFillND(self, ndparams):
1012
    """Fill a given ndparams dict with defaults.
1013

  
1014
    @type ndparams: dict
1015
    @param ndparams: the dict to fill
1016
    @rtype: dict
1017
    @return: a copy of the passed in ndparams with missing keys filled
1018
        from the cluster defaults
1019

  
1020
    """
1021
    return FillDict(self.ndparams, ndparams)
1022

  
989 1023

  
990 1024
class Cluster(TaggableObject):
991 1025
  """Config object representing the cluster."""
......
1011 1045
    "beparams",
1012 1046
    "osparams",
1013 1047
    "nicparams",
1048
    "ndparams",
1014 1049
    "candidate_pool_size",
1015 1050
    "modify_etc_hosts",
1016 1051
    "modify_ssh_setup",
......
1043 1078
    if self.osparams is None:
1044 1079
      self.osparams = {}
1045 1080

  
1081
    if self.ndparams is None:
1082
      self.ndparams = constants.NDC_DEFAULTS
1083

  
1046 1084
    self.beparams = UpgradeGroupedParams(self.beparams,
1047 1085
                                         constants.BEC_DEFAULTS)
1048 1086
    migrate_default_bridge = not self.nicparams
......
1236 1274
    # specified params
1237 1275
    return FillDict(result, os_params)
1238 1276

  
1277
  def FillND(self, node, nodegroup):
1278
    """Return filled out ndparams for L{objects.NodeGroup} and L{object.Node}
1279

  
1280
    @type node: L{objects.Node}
1281
    @param node: A Node object to fill
1282
    @type nodegroup: L{objects.NodeGroup}
1283
    @param nodegroup: A Node object to fill
1284
    @return a copy of the node's ndparams with defaults filled
1285

  
1286
    """
1287
    return self.SimpleFillND(nodegroup.FillND(node))
1288

  
1289
  def SimpleFillND(self, ndparams):
1290
    """Fill a given ndparams dict with defaults.
1291

  
1292
    @type ndparams: dict
1293
    @param ndparams: the dict to fill
1294
    @rtype: dict
1295
    @return: a copy of the passed in ndparams with missing keys filled
1296
        from the cluster defaults
1297

  
1298
    """
1299
    return FillDict(self.ndparams, ndparams)
1300

  
1239 1301

  
1240 1302
class BlockDevStatus(ConfigObject):
1241 1303
  """Config object representing the status of a block device."""

Also available in: Unified diff