Commit e1374a9e authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Use explicit configuration for nodes in GanetiContext



This way, each call to AddNode or RemoveNode uses a passed configuration
object that belongs to the appropriate job.

This is required to subsequently get rid of the single shared
ConfigWriter object.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 7a311c56
......@@ -415,7 +415,7 @@ class LUNodeAdd(LogicalUnit):
result.Warn("Node failed to demote itself from master candidate status",
self.LogWarning)
else:
self.context.AddNode(self.new_node, self.proc.GetECId())
self.context.AddNode(self.cfg, self.new_node, self.proc.GetECId())
RedistributeAncillaryFiles(self)
# We create a new certificate even if the node is readded
......@@ -1478,7 +1478,7 @@ class LUNodeRemove(LogicalUnit):
# Promote nodes to master candidate as needed
AdjustCandidatePool(self, [self.node.uuid])
self.context.RemoveNode(self.node)
self.context.RemoveNode(self.cfg, self.node)
# Run post hooks on the node before it's removed
RunPostHook(self, self.node.name)
......
......@@ -489,12 +489,12 @@ class GanetiContext(object):
def GetWConfdContext(self, ec_id):
return config.GetWConfdContext(ec_id, self.livelock)
def AddNode(self, node, ec_id):
def AddNode(self, cfg, node, ec_id):
"""Adds a node to the configuration.
"""
# Add it to the configuration
self.cfg.AddNode(node, ec_id)
cfg.AddNode(node, ec_id)
# If preseeding fails it'll not be added
self.jobqueue.AddNode(node)
......@@ -506,12 +506,12 @@ class GanetiContext(object):
# Synchronize the queue again
self.jobqueue.AddNode(node)
def RemoveNode(self, node):
def RemoveNode(self, cfg, node):
"""Removes a node from the configuration and lock manager.
"""
# Remove node from configuration
self.cfg.RemoveNode(node.uuid)
cfg.RemoveNode(node.uuid)
# Notify job queue
self.jobqueue.RemoveNode(node.name)
......
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