Revision f665d9de

b/lib/cli.py
98 98
  "GLOBAL_SHARED_FILEDIR_OPT",
99 99
  "HOTPLUG_OPT",
100 100
  "HOTPLUG_IF_POSSIBLE_OPT",
101
  "KEEPDISKS_OPT",
101 102
  "HVLIST_OPT",
102 103
  "HVOPTS_OPT",
103 104
  "HYPERVISOR_OPT",
......
1666 1667
                                     help="Hotplug devices in case"
1667 1668
                                          " hotplug is supported")
1668 1669

  
1670
KEEPDISKS_OPT = cli_option("--keep-disks", dest="keep_disks",
1671
                           action="store_true", default=False,
1672
                           help="Do not remove disks")
1673

  
1669 1674
#: Options provided by all commands
1670 1675
COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
1671 1676

  
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
3447 3447
    (anno_disk,) = AnnotateDiskParams(self.instance, [root], self.cfg)
3448 3448
    for node_uuid, disk in anno_disk.ComputeNodeTree(
3449 3449
                             self.instance.primary_node):
3450
      if self.op.keep_disks and disk.dev_type is constants.DT_EXT:
3451
        continue
3450 3452
      msg = self.rpc.call_blockdev_remove(node_uuid, (disk, self.instance)) \
3451 3453
              .fail_msg
3452 3454
      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
......
562 563
  defaultField [| [] |] $
563 564
  simpleField "instances" [t| [NonEmptyString] |]
564 565

  
566
-- | Whether to remove disks.
567
pKeepDisks :: Field
568
pKeepDisks = defaultFalse "keep_disks"
569

  
565 570
pOutputFields :: Field
566 571
pOutputFields =
567 572
  withDoc "Selected output fields" $
b/test/hs/Test/Ganeti/OpCodes.hs
257 257
          arbitrary <*> genMaybe genNameNE <*> genMaybe (pure emptyJSObject)
258 258
      "OP_INSTANCE_REMOVE" ->
259 259
        OpCodes.OpInstanceRemove <$> genFQDN <*> return Nothing <*>
260
          arbitrary <*> arbitrary
260
          arbitrary <*> arbitrary <*> arbitrary
261 261
      "OP_INSTANCE_RENAME" ->
262 262
        OpCodes.OpInstanceRename <$> genFQDN <*> return Nothing <*>
263 263
          genNodeNameNE <*> arbitrary <*> arbitrary
......
299 299
          pure emptyJSObject <*> arbitrary <*> genMaybe genNodeNameNE <*>
300 300
          return Nothing <*> genMaybe genNodeNameNE <*> return Nothing <*>
301 301
          genMaybe genNameNE <*> pure emptyJSObject <*> arbitrary <*>
302
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
302
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
303 303
      "OP_INSTANCE_GROW_DISK" ->
304 304
        OpCodes.OpInstanceGrowDisk <$> genFQDN <*> return Nothing <*>
305 305
          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary

Also available in: Unified diff