Revision 41f2bf8d

b/lib/cli.py
97 97
  "GLOBAL_SHARED_FILEDIR_OPT",
98 98
  "HOTPLUG_OPT",
99 99
  "HOTPLUG_IF_POSSIBLE_OPT",
100
  "KEEPDISKS_OPT",
100 101
  "HVLIST_OPT",
101 102
  "HVOPTS_OPT",
102 103
  "HYPERVISOR_OPT",
......
1654 1655
                                     help="Hotplug devices in case"
1655 1656
                                          " hotplug is supported")
1656 1657

  
1658
KEEPDISKS_OPT = cli_option("--keep-disks", dest="keep_disks",
1659
                           action="store_true", default=False,
1660
                           help="Do not remove disks")
1661

  
1657 1662
#: Options provided by all commands
1658 1663
COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
1659 1664

  
b/lib/client/gnt_instance.py
460 460

  
461 461
  op = opcodes.OpInstanceRemove(instance_name=instance_name,
462 462
                                ignore_failures=opts.ignore_failures,
463
                                shutdown_timeout=opts.shutdown_timeout)
463
                                shutdown_timeout=opts.shutdown_timeout,
464
                                keep_disks=opts.keep_disks)
464 465
  SubmitOrSend(op, opts, cl=cl)
465 466
  return 0
466 467

  
......
1375 1376
                                   disks=disks,
1376 1377
                                   hotplug=opts.hotplug,
1377 1378
                                   hotplug_if_possible=opts.hotplug_if_possible,
1379
                                   keep_disks=opts.keep_disks,
1378 1380
                                   disk_template=opts.disk_template,
1379 1381
                                   remote_node=opts.node,
1380 1382
                                   pnode=opts.new_primary_node,
......
1565 1567
  "remove": (
1566 1568
    RemoveInstance, ARGS_ONE_INSTANCE,
1567 1569
    [FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT] + SUBMIT_OPTS
1568
    + [DRY_RUN_OPT, PRIORITY_OPT],
1570
    + [DRY_RUN_OPT, PRIORITY_OPT, KEEPDISKS_OPT],
1569 1571
    "[-f] <instance>", "Shuts down the instance and removes it"),
1570 1572
  "rename": (
1571 1573
    RenameInstance,
......
1587 1589
     OSPARAMS_OPT, DRY_RUN_OPT, PRIORITY_OPT, NWSYNC_OPT, OFFLINE_INST_OPT,
1588 1590
     ONLINE_INST_OPT, IGNORE_IPOLICY_OPT, RUNTIME_MEM_OPT,
1589 1591
     NOCONFLICTSCHECK_OPT, NEW_PRIMARY_OPT, HOTPLUG_OPT,
1590
     HOTPLUG_IF_POSSIBLE_OPT],
1592
     HOTPLUG_IF_POSSIBLE_OPT, KEEPDISKS_OPT],
1591 1593
    "<instance>", "Alters the parameters of an instance"),
1592 1594
  "shutdown": (
1593 1595
    GenericManyOps("shutdown", _ShutdownInstance), [ArgInstance()],
b/lib/cmdlib/instance.py
3418 3418
    (anno_disk,) = AnnotateDiskParams(self.instance, [root], self.cfg)
3419 3419
    for node_uuid, disk in anno_disk.ComputeNodeTree(
3420 3420
                             self.instance.primary_node):
3421
      if self.op.keep_disks and disk.dev_type is constants.DT_EXT:
3422
        continue
3421 3423
      msg = self.rpc.call_blockdev_remove(node_uuid, (disk, self.instance)) \
3422 3424
              .fail_msg
3423 3425
      if msg:
b/lib/cmdlib/instance_utils.py
276 276
    else:
277 277
      edata = device.ComputeNodeTree(instance.primary_node)
278 278
    for node_uuid, disk in edata:
279
      if getattr(lu.op, "keep_disks", None):
280
        if lu.op.keep_disks and disk.dev_type is constants.DT_EXT:
281
          continue
279 282
      result = lu.rpc.call_blockdev_remove(node_uuid, (disk, instance))
280 283
      if result.fail_msg:
281 284
        lu.LogWarning("Could not remove disk %s on node %s,"
b/src/Ganeti/OpCodes.hs
484 484
     , pInstanceUuid
485 485
     , pShutdownTimeout
486 486
     , pIgnoreFailures
487
     , pKeepDisks
487 488
     ],
488 489
     "instance_name")
489 490
  , ("OpInstanceRename",
......
666 667
     , pIpConflictsCheck
667 668
     , pHotplug
668 669
     , pHotplugIfPossible
670
     , pKeepDisks
669 671
     ],
670 672
     "instance_name")
671 673
  , ("OpInstanceGrowDisk",
b/src/Ganeti/OpParams.hs
98 98
  , pIgnoreIpolicy
99 99
  , pHotplug
100 100
  , pHotplugIfPossible
101
  , pKeepDisks
101 102
  , pAllowRuntimeChgs
102 103
  , pInstDisks
103 104
  , pInstSnaps
......
551 552
  defaultField [| [] |] $
552 553
  simpleField "instances" [t| [NonEmptyString] |]
553 554

  
555
-- | Whether to remove disks.
556
pKeepDisks :: Field
557
pKeepDisks = defaultFalse "keep_disks"
558

  
554 559
pOutputFields :: Field
555 560
pOutputFields =
556 561
  withDoc "Selected output fields" $
b/test/hs/Test/Ganeti/OpCodes.hs
256 256
          arbitrary <*> genMaybe genNameNE <*> genMaybe (pure emptyJSObject)
257 257
      "OP_INSTANCE_REMOVE" ->
258 258
        OpCodes.OpInstanceRemove <$> genFQDN <*> return Nothing <*>
259
          arbitrary <*> arbitrary
259
          arbitrary <*> arbitrary <*> arbitrary
260 260
      "OP_INSTANCE_RENAME" ->
261 261
        OpCodes.OpInstanceRename <$> genFQDN <*> return Nothing <*>
262 262
          genNodeNameNE <*> arbitrary <*> arbitrary
......
298 298
          pure emptyJSObject <*> arbitrary <*> genMaybe genNodeNameNE <*>
299 299
          return Nothing <*> genMaybe genNodeNameNE <*> return Nothing <*>
300 300
          genMaybe genNameNE <*> pure emptyJSObject <*> arbitrary <*>
301
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
301
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
302 302
      "OP_INSTANCE_GROW_DISK" ->
303 303
        OpCodes.OpInstanceGrowDisk <$> genFQDN <*> return Nothing <*>
304 304
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary

Also available in: Unified diff