Revision bd2a5569 lib/client/gnt_instance.py

b/lib/client/gnt_instance.py
1313 1313
  return 0
1314 1314

  
1315 1315

  
1316
def ChangeGroup(opts, args):
1317
  """Moves an instance to another group.
1318

  
1319
  """
1320
  (instance_name, ) = args
1321

  
1322
  cl = GetClient()
1323

  
1324
  op = opcodes.OpInstanceChangeGroup(instance_name=instance_name,
1325
                                     iallocator=opts.iallocator,
1326
                                     target_groups=opts.to,
1327
                                     early_release=opts.early_release)
1328
  result = SubmitOpCode(op, cl=cl, opts=opts)
1329

  
1330
  # Keep track of submitted jobs
1331
  jex = JobExecutor(cl=cl, opts=opts)
1332

  
1333
  for (status, job_id) in result[constants.JOB_IDS_KEY]:
1334
    jex.AddJobId(None, status, job_id)
1335

  
1336
  results = jex.GetResults()
1337
  bad_cnt = len([row for row in results if not row[0]])
1338
  if bad_cnt == 0:
1339
    ToStdout("Instance '%s' changed group successfully.", instance_name)
1340
    rcode = constants.EXIT_SUCCESS
1341
  else:
1342
    ToStdout("There were %s errors while changing group of instance '%s'.",
1343
             bad_cnt, instance_name)
1344
    rcode = constants.EXIT_FAILURE
1345

  
1346
  return rcode
1347

  
1348

  
1316 1349
# multi-instance selection options
1317 1350
m_force_multi = cli_option("--force-multiple", dest="force_multi",
1318 1351
                           help="Do not ask for confirmation when more than"
......
1490 1523
     ArgUnknown(min=1, max=1)],
1491 1524
    [SUBMIT_OPT, NWSYNC_OPT, DRY_RUN_OPT, PRIORITY_OPT],
1492 1525
    "<instance> <disk> <size>", "Grow an instance's disk"),
1526
  "change-group": (
1527
    ChangeGroup, ARGS_ONE_INSTANCE,
1528
    [TO_GROUP_OPT, IALLOCATOR_OPT, EARLY_RELEASE_OPT],
1529
    "[-I <iallocator>] [--to <group>]", "Change group of instance"),
1493 1530
  "list-tags": (
1494 1531
    ListTags, ARGS_ONE_INSTANCE, [PRIORITY_OPT],
1495 1532
    "<instance_name>", "List the tags of the given instance"),

Also available in: Unified diff