Revision 83180411 qa/qa_instance.py

b/qa/qa_instance.py
433 433
  AssertCommand(["gnt-instance", "start", instance["name"]])
434 434

  
435 435

  
436
def _AssertRecreateDisks(cmdargs, instance, fail=False, check=True,
437
                         destroy=True):
438
  """Execute gnt-instance recreate-disks and check the result
439

  
440
  @param cmdargs: Arguments (instance name excluded)
441
  @param instance: Instance to operate on
442
  @param fail: True if the command is expected to fail
443
  @param check: If True and fail is False, check that the disks work
444
  @prama destroy: If True, destroy the old disks first
445

  
446
  """
447
  if destroy:
448
    _DestroyInstanceVolumes(instance)
449
  AssertCommand((["gnt-instance", "recreate-disks"] + cmdargs +
450
                 [instance["name"]]), fail)
451
  if not fail and check:
452
    # Quick check that the disks are there
453
    AssertCommand(["gnt-instance", "activate-disks", instance["name"]])
454
    AssertCommand(["gnt-instance", "deactivate-disks", instance["name"]])
455

  
456
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
457
def TestRecreateDisks(instance, pnode, snode, othernodes):
458
  """gnt-instance recreate-disks
459

  
460
  @param instance: Instance to work on
461
  @param pnode: Primary node
462
  @param snode: Secondary node, or None for sigle-homed instances
463
  @param othernodes: list/tuple of nodes where to temporarily recreate disks
464

  
465
  """
466
  other_seq = ":".join([n["primary"] for n in othernodes])
467
  orig_seq = pnode["primary"]
468
  if snode:
469
    orig_seq = orig_seq + ":" + snode["primary"]
470
  # This fails beacuse the instance is running
471
  _AssertRecreateDisks(["-n", other_seq], instance, fail=True, destroy=False)
472
  AssertCommand(["gnt-instance", "stop", instance["name"]])
473
  # Disks exist: this should fail
474
  _AssertRecreateDisks([], instance, fail=True, destroy=False)
475
  # Recreate disks in place
476
  _AssertRecreateDisks([], instance)
477
  # Move disks away
478
  _AssertRecreateDisks(["-n", other_seq], instance)
479
  # Move disks back
480
  _AssertRecreateDisks(["-n", orig_seq], instance, check=False)
481
  # This and InstanceCheck decoration check that the disks are working
482
  AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
483
  AssertCommand(["gnt-instance", "start", instance["name"]])
484

  
485

  
436 486
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
437 487
def TestInstanceExport(instance, node):
438 488
  """gnt-backup export -n ..."""

Also available in: Unified diff