Revision a9e0c397 scripts/gnt-instance

b/scripts/gnt-instance
431 431

  
432 432
  """
433 433
  instance_name = args[0]
434
  new_secondary = opts.new_secondary
435
  op = opcodes.OpReplaceDisks(instance_name=args[0],
436
                              remote_node=opts.new_secondary)
434
  new_2ndary = opts.new_secondary
435
  if opts.disks is None:
436
    disks = ["sda", "sdb"]
437
  else:
438
    disks = opts.disks.split(",")
439
  if opts.on_primary == opts.on_secondary: # no -p or -s passed, or both passed
440
    mode = constants.REPLACE_DISK_ALL
441
  elif opts.on_primary: # only on primary:
442
    mode = constants.REPLACE_DISK_PRI
443
    if new_2ndary is not None:
444
      raise errors.OpPrereqError("Can't change secondary node on primary disk"
445
                                 " replacement")
446
  elif opts.on_secondary is not None: # only on secondary
447
    mode = constants.REPLACE_DISK_SEC
448

  
449
  op = opcodes.OpReplaceDisks(instance_name=args[0], disks=disks,
450
                              remote_node=new_2ndary, mode=mode)
437 451
  SubmitOpCode(op)
438 452
  return 0
439 453

  
......
745 759
  'replace-disks': (ReplaceDisks, ARGS_ONE,
746 760
                    [DEBUG_OPT,
747 761
                     make_option("-n", "--new-secondary", dest="new_secondary",
748
                                 metavar="NODE",
749
                                 help=("New secondary node (if you want to"
750
                                       " change the secondary)"))],
762
                                 help=("New secondary node (for secondary"
763
                                       " node change)"), metavar="NODE"),
764
                     make_option("-p", "--on-primary", dest="on_primary",
765
                                 default=False, action="store_true",
766
                                 help=("Replace the disk(s) on the primary"
767
                                       " node (only for the drbd8 template)")),
768
                     make_option("-s", "--on-secondary", dest="on_secondary",
769
                                 default=False, action="store_true",
770
                                 help=("Replace the disk(s) on the secondary"
771
                                       " node (only for the drbd8 template)")),
772
                     make_option("--disks", dest="disks", default=None,
773
                                 help=("Comma-separated list of disks"
774
                                       " to replace (e.g. sda) (optional,"
775
                                       " defaults to all disks")),
776
                     ],
751 777
                    "[-n NODE] <instance>",
752 778
                    "Replaces all disks for the instance"),
753 779
  'modify': (SetInstanceParms, ARGS_ONE,

Also available in: Unified diff