Commit 4c04ae43 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Fix calls to Update in LUClusterSetParams



Since this LU intersperses calls ConfigWriter methods with modifying
objects directly, it's necessary to call 'Update' and/or re-read them at
appropriate places.

Also a new ConfigWriter method is created for modifying the instance
communication network.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent ee115038
......@@ -1418,8 +1418,7 @@ class LUClusterSetParams(LogicalUnit):
return None
@staticmethod
def _ModifyInstanceCommunicationNetwork(cfg, cluster, network_name,
feedback_fn):
def _ModifyInstanceCommunicationNetwork(cfg, network_name, feedback_fn):
"""Update the instance communication network stored in the cluster
configuration.
......@@ -1432,9 +1431,6 @@ class LUClusterSetParams(LogicalUnit):
@type cfg: L{config.ConfigWriter}
@param cfg: cluster configuration
@type cluster: L{ganeti.objects.Cluster}
@param cluster: Ganeti cluster
@type network_name: string
@param network_name: instance communication network name
......@@ -1466,7 +1462,7 @@ class LUClusterSetParams(LogicalUnit):
feedback_fn("Disabling instance communication network, only new"
" instances will be affected.")
cluster.instance_communication_network = network_name
cfg.SetInstanceCommunicationNetwork(network_name)
if network_name:
return LUClusterSetParams._EnsureInstanceCommunicationNetwork(
......@@ -1479,14 +1475,21 @@ class LUClusterSetParams(LogicalUnit):
"""Change the parameters of the cluster.
"""
# re-read the fresh configuration
self.cluster = self.cfg.GetClusterInfo()
if self.op.enabled_disk_templates:
self.cluster.enabled_disk_templates = \
list(self.op.enabled_disk_templates)
# save the changes
self.cfg.Update(self.cluster, feedback_fn)
self._SetVgName(feedback_fn)
self._SetFileStorageDir(feedback_fn)
self._SetDrbdHelper(feedback_fn)
# re-read the fresh configuration
self.cluster = self.cfg.GetClusterInfo()
if self.op.hvparams:
self.cluster.hvparams = self.new_hvparams
if self.op.os_hvp:
......@@ -1622,7 +1625,7 @@ class LUClusterSetParams(LogicalUnit):
network_name = self.op.instance_communication_network
if network_name is not None:
return self._ModifyInstanceCommunicationNetwork(self.cfg, self.cluster,
return self._ModifyInstanceCommunicationNetwork(self.cfg,
network_name, feedback_fn)
else:
return None
......
......@@ -1354,6 +1354,17 @@ class ConfigWriter(object):
"""
return self._ConfigData().cluster.instance_communication_network
@_ConfigSync()
def SetInstanceCommunicationNetwork(self, network_name):
"""Set cluster instance communication network
@type network_name: string
@param network_name: instance communication network, which is the name of
the network used for instance communication
"""
self._ConfigData().cluster.instance_communication_network = network_name
@_ConfigSync()
def AddNodeGroup(self, group, ec_id, check_uuid=True):
"""Add a node group to the configuration.
......
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