Commit 96b39bcc authored by Iustin Pop's avatar Iustin Pop

Allow OS changes without reinstallation

This patch modifies LUSetInstanceParms to allow OS name changes, without
reinstallation, in case an OS gets renamed on-disk.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 231cd901
......@@ -7744,9 +7744,13 @@ class LUSetInstanceParams(LogicalUnit):
self.op.disk_template = None
if not hasattr(self.op, "remote_node"):
self.op.remote_node = None
if not hasattr(self.op, "os_name"):
self.op.os_name = None
if not hasattr(self.op, "force_variant"):
self.op.force_variant = False
self.op.force = getattr(self.op, "force", False)
if not (self.op.nics or self.op.disks or self.op.disk_template or
self.op.hvparams or self.op.beparams):
self.op.hvparams or self.op.beparams or self.op.os_name):
raise errors.OpPrereqError("No changes submitted", errors.ECODE_INVAL)
if self.op.hvparams:
......@@ -8174,6 +8178,11 @@ class LUSetInstanceParams(LogicalUnit):
(disk_op, len(instance.disks)),
errors.ECODE_INVAL)
# OS change
if self.op.os_name and not self.op.force:
_CheckNodeHasOS(self, instance.primary_node, self.op.os_name,
self.op.force_variant)
return
def _ConvertPlainToDrbd(self, feedback_fn):
......@@ -8384,6 +8393,10 @@ class LUSetInstanceParams(LogicalUnit):
for key, val in self.op.beparams.iteritems():
result.append(("be/%s" % key, val))
# OS change
if self.op.os_name:
instance.os = self.op.os_name
self.cfg.Update(instance, feedback_fn)
return result
......
......@@ -621,7 +621,7 @@ class OpSetInstanceParams(OpCode):
"instance_name",
"hvparams", "beparams", "force",
"nics", "disks", "disk_template",
"remote_node",
"remote_node", "os_name", "force_variant",
]
......
......@@ -1403,6 +1403,8 @@ instance5: 11225
<arg>drbd</arg>
</group></arg>
<sbr>
<arg>--os-name=<replaceable>OS</replaceable> <arg>--force-variant</arg></arg>
<sbr>
<arg>--submit</arg>
......@@ -1453,6 +1455,16 @@ instance5: 11225
option will change the parameters of the Nth instance NIC.
</para>
<para>
The option <option>--os-name</option> will change the OS
name for the instance (without reinstallation). In case an
OS variant is specified that is not found, then by default
the modification is refused,
unless <option>--force-variant</option> is passed. An
invalid OS will also be refused, unless
the <option>--force</option> option is given.
</para>
<para>
The <option>--submit</option> option is used to send the job to
the master daemon but not wait for its completion. The job
......
......@@ -1208,7 +1208,7 @@ def SetInstanceParams(opts, args):
"""
if not (opts.nics or opts.disks or opts.disk_template or
opts.hvparams or opts.beparams):
opts.hvparams or opts.beparams or opts.os):
ToStderr("Please give at least one of the parameters.")
return 1
......@@ -1261,6 +1261,8 @@ def SetInstanceParams(opts, args):
remote_node=opts.node,
hvparams=opts.hvparams,
beparams=opts.beparams,
os_name=opts.os,
force_variant=opts.force_variant,
force=opts.force)
# even if here we process the result, we allow submit only
......@@ -1417,7 +1419,7 @@ commands = {
'modify': (
SetInstanceParams, ARGS_ONE_INSTANCE,
[BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT, SUBMIT_OPT,
DISK_TEMPLATE_OPT, SINGLE_NODE_OPT],
DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT],
"<instance>", "Alters the parameters of an instance"),
'shutdown': (
GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
......
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