Revision 96b39bcc

b/lib/cmdlib.py
7744 7744
      self.op.disk_template = None
7745 7745
    if not hasattr(self.op, "remote_node"):
7746 7746
      self.op.remote_node = None
7747
    if not hasattr(self.op, "os_name"):
7748
      self.op.os_name = None
7749
    if not hasattr(self.op, "force_variant"):
7750
      self.op.force_variant = False
7747 7751
    self.op.force = getattr(self.op, "force", False)
7748 7752
    if not (self.op.nics or self.op.disks or self.op.disk_template or
7749
            self.op.hvparams or self.op.beparams):
7753
            self.op.hvparams or self.op.beparams or self.op.os_name):
7750 7754
      raise errors.OpPrereqError("No changes submitted", errors.ECODE_INVAL)
7751 7755

  
7752 7756
    if self.op.hvparams:
......
8174 8178
                                     (disk_op, len(instance.disks)),
8175 8179
                                     errors.ECODE_INVAL)
8176 8180

  
8181
    # OS change
8182
    if self.op.os_name and not self.op.force:
8183
      _CheckNodeHasOS(self, instance.primary_node, self.op.os_name,
8184
                      self.op.force_variant)
8185

  
8177 8186
    return
8178 8187

  
8179 8188
  def _ConvertPlainToDrbd(self, feedback_fn):
......
8384 8393
      for key, val in self.op.beparams.iteritems():
8385 8394
        result.append(("be/%s" % key, val))
8386 8395

  
8396
    # OS change
8397
    if self.op.os_name:
8398
      instance.os = self.op.os_name
8399

  
8387 8400
    self.cfg.Update(instance, feedback_fn)
8388 8401

  
8389 8402
    return result
b/lib/opcodes.py
621 621
    "instance_name",
622 622
    "hvparams", "beparams", "force",
623 623
    "nics", "disks", "disk_template",
624
    "remote_node",
624
    "remote_node", "os_name", "force_variant",
625 625
    ]
626 626

  
627 627

  
b/man/gnt-instance.sgml
1403 1403
              <arg>drbd</arg>
1404 1404
            </group></arg>
1405 1405

  
1406
          <sbr>
1407
            <arg>--os-name=<replaceable>OS</replaceable> <arg>--force-variant</arg></arg>
1406 1408

  
1407 1409
          <sbr>
1408 1410
          <arg>--submit</arg>
......
1454 1456
        </para>
1455 1457

  
1456 1458
        <para>
1459
          The option <option>--os-name</option> will change the OS
1460
          name for the instance (without reinstallation). In case an
1461
          OS variant is specified that is not found, then by default
1462
          the modification is refused,
1463
          unless <option>--force-variant</option> is passed. An
1464
          invalid OS will also be refused, unless
1465
          the <option>--force</option> option is given.
1466
        </para>
1467

  
1468
        <para>
1457 1469
          The <option>--submit</option> option is used to send the job to
1458 1470
          the master daemon but not wait for its completion. The job
1459 1471
          ID will be shown so that it can be examined via
b/scripts/gnt-instance
1208 1208

  
1209 1209
  """
1210 1210
  if not (opts.nics or opts.disks or opts.disk_template or
1211
          opts.hvparams or opts.beparams):
1211
          opts.hvparams or opts.beparams or opts.os):
1212 1212
    ToStderr("Please give at least one of the parameters.")
1213 1213
    return 1
1214 1214

  
......
1261 1261
                                   remote_node=opts.node,
1262 1262
                                   hvparams=opts.hvparams,
1263 1263
                                   beparams=opts.beparams,
1264
                                   os_name=opts.os,
1265
                                   force_variant=opts.force_variant,
1264 1266
                                   force=opts.force)
1265 1267

  
1266 1268
  # even if here we process the result, we allow submit only
......
1417 1419
  'modify': (
1418 1420
    SetInstanceParams, ARGS_ONE_INSTANCE,
1419 1421
    [BACKEND_OPT, DISK_OPT, FORCE_OPT, HVOPTS_OPT, NET_OPT, SUBMIT_OPT,
1420
     DISK_TEMPLATE_OPT, SINGLE_NODE_OPT],
1422
     DISK_TEMPLATE_OPT, SINGLE_NODE_OPT, OS_OPT, FORCE_VARIANT_OPT],
1421 1423
    "<instance>", "Alters the parameters of an instance"),
1422 1424
  'shutdown': (
1423 1425
    GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],

Also available in: Unified diff