Revision d2e0774d lib/client/gnt_instance.py

b/lib/client/gnt_instance.py
403 403
    return constants.EXIT_FAILURE
404 404

  
405 405

  
406
def SnapshotInstance(opts, args):
407
  """Snapshot an instance.
408

  
409
  @param opts: the command line options selected by the user
410
  @type args: list
411
  @param args: should contain only one element, the name of the
412
      instance to be reinstalled
413
  @rtype: int
414
  @return: the desired exit code
415

  
416
  """
417
  instance_name  = args[0]
418
  inames = _ExpandMultiNames(_EXPAND_INSTANCES, [instance_name])
419
  if not inames:
420
    raise errors.OpPrereqError("Selection filter does not match any instances",
421
                               errors.ECODE_INVAL)
422
  multi_on = len(inames) > 1
423
  jex = JobExecutor(verbose=multi_on, opts=opts)
424
  for instance_name in inames:
425
    op = opcodes.OpInstanceSnapshot(instance_name=instance_name,
426
                                    disks=opts.disks)
427
    jex.QueueJob(instance_name, op)
428

  
429
  results = jex.WaitOrShow(not opts.submit_only)
430

  
431
  if compat.all(map(compat.fst, results)):
432
    return constants.EXIT_SUCCESS
433
  else:
434
    return constants.EXIT_FAILURE
435

  
406 436
def RemoveInstance(opts, args):
407 437
  """Remove an instance.
408 438

  
......
1522 1552
     m_pri_node_tags_opt, m_sec_node_tags_opt, m_inst_tags_opt, SELECT_OS_OPT,
1523 1553
     SUBMIT_OPT, DRY_RUN_OPT, PRIORITY_OPT, OSPARAMS_OPT],
1524 1554
    "[-f] <instance>", "Reinstall a stopped instance"),
1555
  "snapshot": (
1556
    SnapshotInstance, [ArgInstance(min=1,max=1)],
1557
    [DISK_OPT, SUBMIT_OPT, DRY_RUN_OPT],
1558
    "<instance>", "Snapshot an instance's disk(s)"),
1525 1559
  "remove": (
1526 1560
    RemoveInstance, ARGS_ONE_INSTANCE,
1527 1561
    [FORCE_OPT, SHUTDOWN_TIMEOUT_OPT, IGNORE_FAILURES_OPT, SUBMIT_OPT,

Also available in: Unified diff