Revision 20e23543 scripts/gnt-instance

b/scripts/gnt-instance
303 303
  """
304 304
  instance_name = args[0]
305 305

  
306
  if opts.select_os is True:
307
    op = opcodes.OpDiagnoseOS(output_fields=["name", "valid"], names=[])
308
    result = SubmitOpCode(op)
309

  
310
    if not result:
311
      logger.ToStdout("Can't get the OS list")
312
      return 1
313

  
314
    logger.ToStdout("Available OS templates:")
315
    number = 0
316
    choices = []
317
    for entry in result:
318
      logger.ToStdout("%3s: %s" % (number, entry[0]))
319
      choices.append(("%s" % number, entry[0], entry[0]))
320
      number = number + 1
321

  
322
    choices.append(('x', 'exit', 'Exit gnt-instance reinstall'))
323
    selected = AskUser("Enter OS template name or number (or x to abort):",
324
                       choices)
325

  
326
    if selected == 'exit':
327
      logger.ToStdout("User aborted reinstall, exiting")
328
      return 1
329

  
330
    os = selected
331
  else:
332
    os = opts.os
333

  
306 334
  if not opts.force:
307 335
    usertext = ("This will reinstall the instance %s and remove"
308 336
                " all data. Continue?") % instance_name
......
310 338
      return 1
311 339

  
312 340
  op = opcodes.OpReinstallInstance(instance_name=instance_name,
313
                                   os_type=opts.os)
341
                                   os_type=os)
314 342
  SubmitOpCode(op)
315 343

  
316 344
  return 0
......
928 956
           " ip, mac, bridge, sda_size, sdb_size, vcpus. The default field"
929 957
           " list is (in order): %s." % ", ".join(_LIST_DEF_FIELDS),
930 958
           ),
931
  'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT, os_opt],
959
  'reinstall': (ReinstallInstance, ARGS_ONE,
960
                [DEBUG_OPT, FORCE_OPT, os_opt,
961
                 make_option("--select-os", dest="select_os",
962
                             action="store_true", default=False,
963
                             help="Interactive OS reinstall, lists available"
964
                             " OS templates for selection")],
932 965
                "[-f] <instance>", "Reinstall a stopped instance"),
933 966
  'remove': (RemoveInstance, ARGS_ONE,
934 967
             [DEBUG_OPT, FORCE_OPT,

Also available in: Unified diff