"master_candidate",
"offline",
"drained",
- "nodegroup",
+ "group",
+ "master_capable",
+ "vm_capable",
+ "ndparams",
] + _TIMESTAMPS + _UUID
+ def UpgradeConfig(self):
+ """Fill defaults for missing configuration values.
+
+ """
+ # pylint: disable-msg=E0203
+ # because these are "defined" via slots, not manually
+ if self.master_capable is None:
+ self.master_capable = True
+
+ if self.vm_capable is None:
+ self.vm_capable = True
+
+ if self.ndparams is None:
+ self.ndparams = {}
+
class NodeGroup(ConfigObject):
"""Config object representing a node group."""
__slots__ = [
"name",
"members",
+ "ndparams",
] + _TIMESTAMPS + _UUID
def ToDict(self):
obj.members = []
return obj
+ def UpgradeConfig(self):
+ """Fill defaults for missing configuration values.
+
+ """
+ if self.ndparams is None:
+ self.ndparams = {}
+
+ def FillND(self, node):
+ """Return filled out ndparams for L{object.Node}
+
+ @type node: L{objects.Node}
+ @param node: A Node object to fill
+ @return a copy of the node's ndparams with defaults filled
+
+ """
+ return self.SimpleFillND(node.ndparams)
+
+ def SimpleFillND(self, ndparams):
+ """Fill a given ndparams dict with defaults.
+
+ @type ndparams: dict
+ @param ndparams: the dict to fill
+ @rtype: dict
+ @return: a copy of the passed in ndparams with missing keys filled
+ from the cluster defaults
+
+ """
+ return FillDict(self.ndparams, ndparams)
+
class Cluster(TaggableObject):
"""Config object representing the cluster."""
"beparams",
"osparams",
"nicparams",
+ "ndparams",
"candidate_pool_size",
"modify_etc_hosts",
"modify_ssh_setup",
if self.osparams is None:
self.osparams = {}
+ if self.ndparams is None:
+ self.ndparams = constants.NDC_DEFAULTS
+
self.beparams = UpgradeGroupedParams(self.beparams,
constants.BEC_DEFAULTS)
migrate_default_bridge = not self.nicparams
# specified params
return FillDict(result, os_params)
+ def FillND(self, node, nodegroup):
+ """Return filled out ndparams for L{objects.NodeGroup} and L{object.Node}
+
+ @type node: L{objects.Node}
+ @param node: A Node object to fill
+ @type nodegroup: L{objects.NodeGroup}
+ @param nodegroup: A Node object to fill
+ @return a copy of the node's ndparams with defaults filled
+
+ """
+ return self.SimpleFillND(nodegroup.FillND(node))
+
+ def SimpleFillND(self, ndparams):
+ """Fill a given ndparams dict with defaults.
+
+ @type ndparams: dict
+ @param ndparams: the dict to fill
+ @rtype: dict
+ @return: a copy of the passed in ndparams with missing keys filled
+ from the cluster defaults
+
+ """
+ return FillDict(self.ndparams, ndparams)
+
class BlockDevStatus(ConfigObject):
"""Config object representing the status of a block device."""
@ivar ca_pem: Remote peer CA in PEM format (None for cluster certificate)
@ivar compress: Compression method (one of L{constants.IEC_ALL})
@ivar magic: Used to ensure the connection goes to the right disk
+ @ivar ipv6: Whether to use IPv6
"""
__slots__ = [
"ca_pem",
"compress",
"magic",
+ "ipv6",
]
]
+class QueryFieldDefinition(ConfigObject):
+ """Object holding a query field definition.
+
+ @ivar name: Field name as a regular expression
+ @ivar title: Human-readable title
+ @ivar kind: Field type
+
+ """
+ __slots__ = [
+ "name",
+ "title",
+ "kind",
+ ]
+
+
class SerializableConfigParser(ConfigParser.SafeConfigParser):
"""Simple wrapper over ConfigParse that allows serialization.