Commit e1a6850f authored by Agata Murawska's avatar Agata Murawska
Browse files

SetClusterParams supports instance policy changes


Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 18bb6d28
......@@ -921,7 +921,12 @@ def SetClusterParams(opts, args):
opts.use_external_mip_script is not None or
opts.prealloc_wipe_disks is not None or
opts.hv_state or
opts.disk_state):
opts.disk_state or
opts.ispecs_mem_size is not None or
opts.ispecs_cpu_count is not None or
opts.ispecs_disk_count is not None or
opts.ispecs_disk_size is not None or
opts.ispecs_nic_count is not None):
ToStderr("Please give at least one of the parameters.")
return 1
......@@ -965,6 +970,15 @@ def SetClusterParams(opts, args):
if ndparams is not None:
utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES)
ipolicy = \
objects.CreateIPolicyFromOpts(ispecs_mem_size=opts.ispecs_mem_size,
ispecs_cpu_count=opts.ispecs_cpu_count,
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count)
for value in ipolicy.values():
utils.ForceDictType(value, constants.ISPECS_PARAMETER_TYPES)
mnh = opts.maintain_node_health
uid_pool = opts.uid_pool
......@@ -1010,6 +1024,7 @@ def SetClusterParams(opts, args):
nicparams=nicparams,
ndparams=ndparams,
diskparams=diskparams,
ipolicy=ipolicy,
candidate_pool_size=opts.candidate_pool_size,
maintain_node_health=mnh,
uid_pool=uid_pool,
......
......@@ -3674,6 +3674,15 @@ class LUClusterSetParams(LogicalUnit):
for name, values in svalues.items()))
for storage, svalues in new_disk_state.items())
if self.op.ipolicy:
ipolicy = {}
for key, value in self.op.ipolicy.items():
utils.ForceDictType(value, constants.ISPECS_PARAMETER_TYPES)
ipolicy[key] = _GetUpdatedParams(cluster.ipolicy.get(key, {}),
value)
objects.InstancePolicy.CheckParameterSyntax(ipolicy)
self.new_ipolicy = ipolicy
if self.op.nicparams:
utils.ForceDictType(self.op.nicparams, constants.NICS_PARAMETER_TYPES)
self.new_nicparams = cluster.SimpleFillNIC(self.op.nicparams)
......@@ -3834,6 +3843,8 @@ class LUClusterSetParams(LogicalUnit):
self.cluster.beparams[constants.PP_DEFAULT] = self.new_beparams
if self.op.nicparams:
self.cluster.nicparams[constants.PP_DEFAULT] = self.new_nicparams
if self.op.ipolicy:
self.cluster.ipolicy = self.new_ipolicy
if self.op.osparams:
self.cluster.osparams = self.new_osp
if self.op.ndparams:
......
......@@ -793,6 +793,7 @@ class OpClusterSetParams(OpCode):
"Whether to wipe disks before allocating them to instances"),
("nicparams", None, ht.TMaybeDict, "Cluster-wide NIC parameter defaults"),
("ndparams", None, ht.TMaybeDict, "Cluster-wide node parameter defaults"),
("ipolicy", None, ht.TMaybeDict, "Cluster-wide instance policy specs"),
("drbd_helper", None, ht.TOr(ht.TString, ht.TNone), "DRBD helper program"),
("default_iallocator", None, ht.TOr(ht.TString, ht.TNone),
"Default iallocator for cluster"),
......
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