Commit f936c153 authored by Iustin Pop's avatar Iustin Pop
Browse files

Rename node.nodegroup to node.group



In the context of a node, its group has (at least today) only one
meaning, that is the node's node group. As such, we rename
node.nodegroup to just node.group.

Note: if we want to keep node in there, it should be at least
node_group, for consistency with the other node attributes.

Similarly, we rename the OpAddNode nodegroup attribute to group.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent a285fcfd
......@@ -3568,7 +3568,7 @@ class LUAddNode(LogicalUnit):
("primary_ip", None, ht.NoType),
("secondary_ip", None, ht.TMaybeString),
("readd", False, ht.TBool),
("nodegroup", None, ht.TMaybeString)
("group", None, ht.TMaybeString)
]
def CheckArguments(self):
......@@ -3577,8 +3577,8 @@ class LUAddNode(LogicalUnit):
self.hostname = netutils.GetHostname(name=self.op.node_name,
family=self.primary_ip_family)
self.op.node_name = self.hostname.name
if self.op.readd and self.op.nodegroup:
raise errors.OpPrereqError("Cannot pass a nodegroup when a node is"
if self.op.readd and self.op.group:
raise errors.OpPrereqError("Cannot pass a node group when a node is"
" being readded", errors.ECODE_INVAL)
def BuildHooksEnv(self):
......@@ -3694,13 +3694,13 @@ class LUAddNode(LogicalUnit):
self.new_node = self.cfg.GetNodeInfo(node)
assert self.new_node is not None, "Can't retrieve locked node %s" % node
else:
nodegroup = cfg.LookupNodeGroup(self.op.nodegroup)
node_group = cfg.LookupNodeGroup(self.op.group)
self.new_node = objects.Node(name=node,
primary_ip=primary_ip,
secondary_ip=secondary_ip,
master_candidate=self.master_candidate,
offline=False, drained=False,
nodegroup=nodegroup)
group=node_group)
def Exec(self, feedback_fn):
"""Adds the new node to the cluster.
......
......@@ -1079,7 +1079,7 @@ class ConfigWriter:
node.serial_no = 1
node.ctime = node.mtime = time.time()
self._UnlockedAddNodeToGroup(node.name, node.nodegroup)
self._UnlockedAddNodeToGroup(node.name, node.group)
self._config_data.nodes[node.name] = node
self._config_data.cluster.serial_no += 1
self._WriteConfig()
......@@ -1264,7 +1264,7 @@ class ConfigWriter:
# when we're adding the first node to it, since we don't keep a lock in
# the meantime. It's ok though, as we'll fail cleanly if the node group
# is not found anymore.
raise errors.OpExecError("Unknown nodegroup: %s" % nodegroup_uuid)
raise errors.OpExecError("Unknown node group: %s" % nodegroup_uuid)
if node_name not in self._config_data.nodegroups[nodegroup_uuid].members:
self._config_data.nodegroups[nodegroup_uuid].members.append(node_name)
......@@ -1272,13 +1272,13 @@ class ConfigWriter:
"""Remove a given node from its group.
"""
nodegroup = node.nodegroup
nodegroup = node.group
if nodegroup not in self._config_data.nodegroups:
logging.warning("Warning: node '%s' has a non-existing nodegroup '%s'"
logging.warning("Warning: node '%s' has unknown node group '%s'"
" (while being removed from it)", node.name, nodegroup)
nodegroup_obj = self._config_data.nodegroups[nodegroup]
if node.name not in nodegroup_obj.members:
logging.warning("Warning: node '%s' not a member of its nodegroup '%s'"
logging.warning("Warning: node '%s' not a member of its node group '%s'"
" (while being removed from it)", node.name, nodegroup)
else:
nodegroup_obj.members.remove(node.name)
......@@ -1366,14 +1366,14 @@ class ConfigWriter:
self._config_data.nodegroups[default_nodegroup_uuid] = default_nodegroup
modified = True
for node in self._config_data.nodes.values():
if not node.nodegroup:
node.nodegroup = self.LookupNodeGroup(None)
if not node.group:
node.group = self.LookupNodeGroup(None)
modified = True
# This is technically *not* an upgrade, but needs to be done both when
# nodegroups are being added, and upon normally loading the config,
# because the members list of a node group is discarded upon
# serializing/deserializing the object.
self._UnlockedAddNodeToGroup(node.name, node.nodegroup)
self._UnlockedAddNodeToGroup(node.name, node.group)
if modified:
self._WriteConfig()
# This is ok even if it acquires the internal lock, as _UpgradeConfig is
......
......@@ -939,7 +939,7 @@ class Node(TaggableObject):
"master_candidate",
"offline",
"drained",
"nodegroup",
"group",
] + _TIMESTAMPS + _UUID
......
......@@ -363,11 +363,13 @@ class OpAddNode(OpCode):
name is already in the cluster; use this parameter to 'repair'
a node that had its configuration broken, or was reinstalled
without removal from the cluster.
@type group: C{str}
@ivar group: The node group to which this node will belong.
"""
OP_ID = "OP_NODE_ADD"
OP_DSC_FIELD = "node_name"
__slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "nodegroup"]
__slots__ = ["node_name", "primary_ip", "secondary_ip", "readd", "group"]
class OpQueryNodes(OpCode):
......
......@@ -214,7 +214,7 @@ def AddNode(opts, args):
bootstrap.SetupNodeDaemon(cluster_name, node, opts.ssh_key_check)
op = opcodes.OpAddNode(node_name=args[0], secondary_ip=sip,
readd=opts.readd, nodegroup=opts.nodegroup)
readd=opts.readd, group=opts.nodegroup)
SubmitOpCode(op, opts=opts)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment