Revision b5f33afa

b/qa/ganeti-qa.py
276 276
  if qa_config.TestEnabled("instance-rename"):
277 277
    tgt_instance = qa_config.AcquireInstance()
278 278
    try:
279
      rename_source = instance["name"]
280
      rename_target = tgt_instance["name"]
279
      rename_source = instance.name
280
      rename_target = tgt_instance.name
281 281
      # perform instance rename to the same name
282 282
      RunTest(qa_instance.TestInstanceRenameAndBack,
283 283
              rename_source, rename_source)
b/qa/qa_cluster.py
546 546
        cmd.append("--no-reboot")
547 547
      else:
548 548
        cmd.append("--reboot-types=%s" % ",".join(reboot_types))
549
      cmd += [inst["name"] for inst in instances]
549
      cmd += [inst.name for inst in instances]
550 550
      AssertCommand(cmd)
551 551
    finally:
552 552
      AssertCommand(["rm", "-f", script])
b/qa/qa_daemon.py
110 110
  """Test automatic restart of instance by ganeti-watcher.
111 111

  
112 112
  """
113
  inst_name = qa_utils.ResolveInstanceName(instance["name"])
113
  inst_name = qa_utils.ResolveInstanceName(instance.name)
114 114

  
115 115
  _ResetWatcherDaemon()
116 116
  _ShutdownInstance(inst_name)
......
128 128
  """Test five consecutive instance failures.
129 129

  
130 130
  """
131
  inst_name = qa_utils.ResolveInstanceName(instance["name"])
131
  inst_name = qa_utils.ResolveInstanceName(instance.name)
132 132

  
133 133
  _ResetWatcherDaemon()
134 134

  
b/qa/qa_instance.py
71 71
            "--disk-template=%s" % disk_template,
72 72
            "--node=%s" % node] +
73 73
           _GetGenericAddParameters(instance))
74
    cmd.append(instance["name"])
74
    cmd.append(instance.name)
75 75

  
76 76
    AssertCommand(cmd)
77 77

  
78
    _CheckSsconfInstanceList(instance["name"])
78
    _CheckSsconfInstanceList(instance.name)
79 79
    qa_config.SetInstanceTemplate(instance, disk_template)
80 80

  
81 81
    return instance
......
147 147
  @param instance: the instance
148 148

  
149 149
  """
150
  info = _GetInstanceInfo(instance["name"])
150
  info = _GetInstanceInfo(instance.name)
151 151
  vols = info["volumes"]
152 152
  for node in info["nodes"]:
153 153
    AssertCommand(["lvremove", "-f"] + vols, node=node)
......
208 208
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
209 209
def TestInstanceRemove(instance):
210 210
  """gnt-instance remove"""
211
  AssertCommand(["gnt-instance", "remove", "-f", instance["name"]])
211
  AssertCommand(["gnt-instance", "remove", "-f", instance.name])
212 212

  
213 213

  
214 214
@InstanceCheck(INST_DOWN, INST_UP, FIRST_ARG)
215 215
def TestInstanceStartup(instance):
216 216
  """gnt-instance startup"""
217
  AssertCommand(["gnt-instance", "startup", instance["name"]])
217
  AssertCommand(["gnt-instance", "startup", instance.name])
218 218

  
219 219

  
220 220
@InstanceCheck(INST_UP, INST_DOWN, FIRST_ARG)
221 221
def TestInstanceShutdown(instance):
222 222
  """gnt-instance shutdown"""
223
  AssertCommand(["gnt-instance", "shutdown", instance["name"]])
223
  AssertCommand(["gnt-instance", "shutdown", instance.name])
224 224

  
225 225

  
226 226
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
228 228
  """gnt-instance reboot"""
229 229
  options = qa_config.get("options", {})
230 230
  reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
231
  name = instance["name"]
231
  name = instance.name
232 232
  for rtype in reboot_types:
233 233
    AssertCommand(["gnt-instance", "reboot", "--type=%s" % rtype, name])
234 234

  
......
246 246
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
247 247
def TestInstanceReinstall(instance):
248 248
  """gnt-instance reinstall"""
249
  AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
249
  AssertCommand(["gnt-instance", "reinstall", "-f", instance.name])
250 250

  
251 251
  # Test with non-existant OS definition
252 252
  AssertCommand(["gnt-instance", "reinstall", "-f",
253 253
                 "--os-type=NonExistantOsForQa",
254
                 instance["name"]],
254
                 instance.name],
255 255
                fail=True)
256 256

  
257 257

  
......
336 336
                              " test")
337 337
    return
338 338

  
339
  cmd = ["gnt-instance", "failover", "--force", instance["name"]]
339
  cmd = ["gnt-instance", "failover", "--force", instance.name]
340 340

  
341 341
  # failover ...
342 342
  AssertCommand(cmd)
......
354 354
                              " test")
355 355
    return
356 356

  
357
  cmd = ["gnt-instance", "migrate", "--force", instance["name"]]
357
  cmd = ["gnt-instance", "migrate", "--force", instance.name]
358 358
  af_par = constants.BE_ALWAYS_FAILOVER
359 359
  af_field = "be/" + constants.BE_ALWAYS_FAILOVER
360
  af_init_val = _GetBoolInstanceField(instance["name"], af_field)
360
  af_init_val = _GetBoolInstanceField(instance.name, af_field)
361 361

  
362 362
  # migrate ...
363 363
  AssertCommand(cmd)
......
368 368
  if toggle_always_failover:
369 369
    AssertCommand(["gnt-instance", "modify", "-B",
370 370
                   ("%s=%s" % (af_par, not af_init_val)),
371
                   instance["name"]])
371
                   instance.name])
372 372
  AssertCommand(cmd)
373 373
  # TODO: Verify the choice between failover and migration
374 374
  qa_utils.RunInstanceCheck(instance, True)
375 375
  if toggle_always_failover:
376 376
    AssertCommand(["gnt-instance", "modify", "-B",
377
                   ("%s=%s" % (af_par, af_init_val)), instance["name"]])
377
                   ("%s=%s" % (af_par, af_init_val)), instance.name])
378 378

  
379 379
  # TODO: Split into multiple tests
380
  AssertCommand(["gnt-instance", "shutdown", instance["name"]])
380
  AssertCommand(["gnt-instance", "shutdown", instance.name])
381 381
  qa_utils.RunInstanceCheck(instance, False)
382 382
  AssertCommand(cmd, fail=True)
383 383
  AssertCommand(["gnt-instance", "migrate", "--force", "--allow-failover",
384
                 instance["name"]])
385
  AssertCommand(["gnt-instance", "start", instance["name"]])
384
                 instance.name])
385
  AssertCommand(["gnt-instance", "start", instance.name])
386 386
  AssertCommand(cmd)
387 387
  # @InstanceCheck enforces the check that the instance is running
388 388
  qa_utils.RunInstanceCheck(instance, True)
......
390 390
  AssertCommand(["gnt-instance", "modify", "-B",
391 391
                 ("%s=%s" %
392 392
                  (constants.BE_ALWAYS_FAILOVER, constants.VALUE_TRUE)),
393
                 instance["name"]])
393
                 instance.name])
394 394

  
395 395
  AssertCommand(cmd)
396 396
  qa_utils.RunInstanceCheck(instance, True)
......
400 400
  AssertCommand(["gnt-instance", "modify", "-B",
401 401
                 ("%s=%s" %
402 402
                  (constants.BE_ALWAYS_FAILOVER, constants.VALUE_FALSE)),
403
                 instance["name"]])
403
                 instance.name])
404 404

  
405 405
  AssertCommand(cmd)
406 406
  qa_utils.RunInstanceCheck(instance, True)
......
408 408

  
409 409
def TestInstanceInfo(instance):
410 410
  """gnt-instance info"""
411
  AssertCommand(["gnt-instance", "info", instance["name"]])
411
  AssertCommand(["gnt-instance", "info", instance.name])
412 412

  
413 413

  
414 414
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
456 456
      ])
457 457

  
458 458
  for alist in args:
459
    AssertCommand(["gnt-instance", "modify"] + alist + [instance["name"]])
459
    AssertCommand(["gnt-instance", "modify"] + alist + [instance.name])
460 460

  
461 461
  # check no-modify
462
  AssertCommand(["gnt-instance", "modify", instance["name"]], fail=True)
462
  AssertCommand(["gnt-instance", "modify", instance.name], fail=True)
463 463

  
464 464
  # Marking offline while instance is running must fail...
465
  AssertCommand(["gnt-instance", "modify", "--offline", instance["name"]],
465
  AssertCommand(["gnt-instance", "modify", "--offline", instance.name],
466 466
                 fail=True)
467 467

  
468 468
  # ...while making it online is ok, and should work
469
  AssertCommand(["gnt-instance", "modify", "--online", instance["name"]])
469
  AssertCommand(["gnt-instance", "modify", "--online", instance.name])
470 470

  
471 471

  
472 472
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
473 473
def TestInstanceStoppedModify(instance):
474 474
  """gnt-instance modify (stopped instance)"""
475
  name = instance["name"]
475
  name = instance.name
476 476

  
477 477
  # Instance was not marked offline; try marking it online once more
478 478
  AssertCommand(["gnt-instance", "modify", "--online", name])
......
497 497
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
498 498
def TestInstanceConvertDiskToPlain(instance, inodes):
499 499
  """gnt-instance modify -t"""
500
  name = instance["name"]
500
  name = instance.name
501 501
  template = qa_config.GetInstanceTemplate(instance)
502 502
  if template != "drbd":
503 503
    print qa_utils.FormatInfo("Unsupported template %s, skipping conversion"
......
515 515
  if qa_config.GetExclusiveStorage():
516 516
    print qa_utils.FormatInfo("Test not supported with exclusive_storage")
517 517
    return
518
  name = instance["name"]
518
  name = instance.name
519 519
  all_size = qa_config.get("disk")
520 520
  all_grow = qa_config.get("disk-growth")
521 521
  if not all_grow:
......
548 548
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
549 549
def TestInstanceConsole(instance):
550 550
  """gnt-instance console"""
551
  AssertCommand(["gnt-instance", "console", "--show-cmd", instance["name"]])
551
  AssertCommand(["gnt-instance", "console", "--show-cmd", instance.name])
552 552

  
553 553

  
554 554
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
557 557
  def buildcmd(args):
558 558
    cmd = ["gnt-instance", "replace-disks"]
559 559
    cmd.extend(args)
560
    cmd.append(instance["name"])
560
    cmd.append(instance.name)
561 561
    return cmd
562 562

  
563 563
  if not IsDiskReplacingSupported(instance):
......
589 589
    AssertCommand(buildcmd(data))
590 590

  
591 591
  AssertCommand(buildcmd(["-a"]))
592
  AssertCommand(["gnt-instance", "stop", instance["name"]])
592
  AssertCommand(["gnt-instance", "stop", instance.name])
593 593
  AssertCommand(buildcmd(["-a"]), fail=True)
594
  AssertCommand(["gnt-instance", "activate-disks", instance["name"]])
594
  AssertCommand(["gnt-instance", "activate-disks", instance.name])
595 595
  AssertCommand(["gnt-instance", "activate-disks", "--wait-for-sync",
596
                 instance["name"]])
596
                 instance.name])
597 597
  AssertCommand(buildcmd(["-a"]))
598
  AssertCommand(["gnt-instance", "start", instance["name"]])
598
  AssertCommand(["gnt-instance", "start", instance.name])
599 599

  
600 600

  
601 601
def _AssertRecreateDisks(cmdargs, instance, fail=False, check=True,
......
612 612
  if destroy:
613 613
    _DestroyInstanceVolumes(instance)
614 614
  AssertCommand((["gnt-instance", "recreate-disks"] + cmdargs +
615
                 [instance["name"]]), fail)
615
                 [instance.name]), fail)
616 616
  if not fail and check:
617 617
    # Quick check that the disks are there
618
    AssertCommand(["gnt-instance", "activate-disks", instance["name"]])
618
    AssertCommand(["gnt-instance", "activate-disks", instance.name])
619 619
    AssertCommand(["gnt-instance", "activate-disks", "--wait-for-sync",
620
                   instance["name"]])
621
    AssertCommand(["gnt-instance", "deactivate-disks", instance["name"]])
620
                   instance.name])
621
    AssertCommand(["gnt-instance", "deactivate-disks", instance.name])
622 622

  
623 623

  
624 624
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
640 640
    _AssertRecreateDisks(["-I", "hail"], instance, fail=True, destroy=False)
641 641
  else:
642 642
    _AssertRecreateDisks(["-n", other_seq], instance, fail=True, destroy=False)
643
  AssertCommand(["gnt-instance", "stop", instance["name"]])
643
  AssertCommand(["gnt-instance", "stop", instance.name])
644 644
  # Disks exist: this should fail
645 645
  _AssertRecreateDisks([], instance, fail=True, destroy=False)
646 646
  # Recreate disks in place
......
656 656
  # Move disks back
657 657
  _AssertRecreateDisks(["-n", orig_seq], instance, check=False)
658 658
  # This and InstanceCheck decoration check that the disks are working
659
  AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
660
  AssertCommand(["gnt-instance", "start", instance["name"]])
659
  AssertCommand(["gnt-instance", "reinstall", "-f", instance.name])
660
  AssertCommand(["gnt-instance", "start", instance.name])
661 661

  
662 662

  
663 663
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
664 664
def TestInstanceExport(instance, node):
665 665
  """gnt-backup export -n ..."""
666
  name = instance["name"]
666
  name = instance.name
667 667
  AssertCommand(["gnt-backup", "export", "-n", node.primary, name])
668 668
  return qa_utils.ResolveInstanceName(name)
669 669

  
......
672 672
def TestInstanceExportWithRemove(instance, node):
673 673
  """gnt-backup export --remove-instance"""
674 674
  AssertCommand(["gnt-backup", "export", "-n", node.primary,
675
                 "--remove-instance", instance["name"]])
675
                 "--remove-instance", instance.name])
676 676

  
677 677

  
678 678
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
679 679
def TestInstanceExportNoTarget(instance):
680 680
  """gnt-backup export (without target node, should fail)"""
681
  AssertCommand(["gnt-backup", "export", instance["name"]], fail=True)
681
  AssertCommand(["gnt-backup", "export", instance.name], fail=True)
682 682

  
683 683

  
684 684
@InstanceCheck(None, INST_DOWN, FIRST_ARG)
......
692 692
          "--src-dir=%s/%s" % (pathutils.EXPORT_DIR, name),
693 693
          "--node=%s" % node.primary] +
694 694
         _GetGenericAddParameters(newinst, force_mac=constants.VALUE_GENERATE))
695
  cmd.append(newinst["name"])
695
  cmd.append(newinst.name)
696 696
  AssertCommand(cmd)
697 697
  qa_config.SetInstanceTemplate(newinst, templ)
698 698

  
......
719 719
  @param set_online: function to call to set the node on-line
720 720

  
721 721
  """
722
  info = _GetInstanceInfo(instance["name"])
722
  info = _GetInstanceInfo(instance.name)
723 723
  set_offline(snode)
724 724
  try:
725 725
    TestInstanceRemove(instance)
b/qa/qa_rapi.py
377 377
      _VerifyInstance(instance_data)
378 378

  
379 379
  _DoTests([
380
    ("/2/instances/%s" % instance["name"], _VerifyInstance, "GET", None),
380
    ("/2/instances/%s" % instance.name, _VerifyInstance, "GET", None),
381 381
    ("/2/instances", _VerifyInstancesList, "GET", None),
382 382
    ("/2/instances?bulk=1", _VerifyInstancesBulk, "GET", None),
383
    ("/2/instances/%s/activate-disks" % instance["name"],
383
    ("/2/instances/%s/activate-disks" % instance.name,
384 384
     _VerifyReturnsJob, "PUT", None),
385
    ("/2/instances/%s/deactivate-disks" % instance["name"],
385
    ("/2/instances/%s/deactivate-disks" % instance.name,
386 386
     _VerifyReturnsJob, "PUT", None),
387 387
    ])
388 388

  
389 389
  # Test OpBackupPrepare
390 390
  (job_id, ) = _DoTests([
391 391
    ("/2/instances/%s/prepare-export?mode=%s" %
392
     (instance["name"], constants.EXPORT_MODE_REMOTE),
392
     (instance.name, constants.EXPORT_MODE_REMOTE),
393 393
     _VerifyReturnsJob, "PUT", None),
394 394
    ])
395 395

  
......
571 571

  
572 572
    if use_client:
573 573
      job_id = _rapi_client.CreateInstance(constants.INSTANCE_CREATE,
574
                                           instance["name"],
574
                                           instance.name,
575 575
                                           constants.DT_PLAIN,
576 576
                                           disks, nics,
577 577
                                           os=qa_config.get("os"),
......
581 581
      body = {
582 582
        "__version__": 1,
583 583
        "mode": constants.INSTANCE_CREATE,
584
        "name": instance["name"],
584
        "name": instance.name,
585 585
        "os_type": qa_config.get("os"),
586 586
        "disk_template": constants.DT_PLAIN,
587 587
        "pnode": node.primary,
......
606 606
def TestRapiInstanceRemove(instance, use_client):
607 607
  """Test removing instance via RAPI"""
608 608
  if use_client:
609
    job_id = _rapi_client.DeleteInstance(instance["name"])
609
    job_id = _rapi_client.DeleteInstance(instance.name)
610 610
  else:
611 611
    (job_id, ) = _DoTests([
612
      ("/2/instances/%s" % instance["name"], _VerifyReturnsJob, "DELETE", None),
612
      ("/2/instances/%s" % instance.name, _VerifyReturnsJob, "DELETE", None),
613 613
      ])
614 614

  
615 615
  _WaitForRapiJob(job_id)
......
623 623
                              " test")
624 624
    return
625 625
  # Move to secondary node
626
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"]))
626
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance.name))
627 627
  qa_utils.RunInstanceCheck(instance, True)
628 628
  # And back to previous primary
629
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance["name"]))
629
  _WaitForRapiJob(_rapi_client.MigrateInstance(instance.name))
630 630

  
631 631

  
632 632
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
......
637 637
                              " test")
638 638
    return
639 639
  # Move to secondary node
640
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"]))
640
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance.name))
641 641
  qa_utils.RunInstanceCheck(instance, True)
642 642
  # And back to previous primary
643
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance["name"]))
643
  _WaitForRapiJob(_rapi_client.FailoverInstance(instance.name))
644 644

  
645 645

  
646 646
@InstanceCheck(INST_UP, INST_DOWN, FIRST_ARG)
647 647
def TestRapiInstanceShutdown(instance):
648 648
  """Test stopping an instance via RAPI"""
649
  _WaitForRapiJob(_rapi_client.ShutdownInstance(instance["name"]))
649
  _WaitForRapiJob(_rapi_client.ShutdownInstance(instance.name))
650 650

  
651 651

  
652 652
@InstanceCheck(INST_DOWN, INST_UP, FIRST_ARG)
653 653
def TestRapiInstanceStartup(instance):
654 654
  """Test starting an instance via RAPI"""
655
  _WaitForRapiJob(_rapi_client.StartupInstance(instance["name"]))
655
  _WaitForRapiJob(_rapi_client.StartupInstance(instance.name))
656 656

  
657 657

  
658 658
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
......
673 673
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
674 674
def TestRapiInstanceReinstall(instance):
675 675
  """Test reinstalling an instance via RAPI"""
676
  _WaitForRapiJob(_rapi_client.ReinstallInstance(instance["name"]))
676
  _WaitForRapiJob(_rapi_client.ReinstallInstance(instance.name))
677 677
  # By default, the instance is started again
678 678
  qa_utils.RunInstanceCheck(instance, True)
679 679

  
680 680
  # Reinstall again without starting
681
  _WaitForRapiJob(_rapi_client.ReinstallInstance(instance["name"],
681
  _WaitForRapiJob(_rapi_client.ReinstallInstance(instance.name,
682 682
                                                 no_startup=True))
683 683

  
684 684

  
......
690 690
                              " skipping test")
691 691
    return
692 692
  fn = _rapi_client.ReplaceInstanceDisks
693
  _WaitForRapiJob(fn(instance["name"],
693
  _WaitForRapiJob(fn(instance.name,
694 694
                     mode=constants.REPLACE_DISK_AUTO, disks=[]))
695
  _WaitForRapiJob(fn(instance["name"],
695
  _WaitForRapiJob(fn(instance.name,
696 696
                     mode=constants.REPLACE_DISK_SEC, disks="0"))
697 697

  
698 698

  
......
702 702
  default_hv = qa_config.GetDefaultHypervisor()
703 703

  
704 704
  def _ModifyInstance(**kwargs):
705
    _WaitForRapiJob(_rapi_client.ModifyInstance(instance["name"], **kwargs))
705
    _WaitForRapiJob(_rapi_client.ModifyInstance(instance.name, **kwargs))
706 706

  
707 707
  _ModifyInstance(beparams={
708 708
    constants.BE_VCPUS: 3,
......
731 731
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
732 732
def TestRapiInstanceConsole(instance):
733 733
  """Test getting instance console information via RAPI"""
734
  result = _rapi_client.GetInstanceConsole(instance["name"])
734
  result = _rapi_client.GetInstanceConsole(instance.name)
735 735
  console = objects.InstanceConsole.FromDict(result)
736 736
  AssertEqual(console.Validate(), True)
737
  AssertEqual(console.instance, qa_utils.ResolveInstanceName(instance["name"]))
737
  AssertEqual(console.instance, qa_utils.ResolveInstanceName(instance.name))
738 738

  
739 739

  
740 740
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG)
741 741
def TestRapiStoppedInstanceConsole(instance):
742 742
  """Test getting stopped instance's console information via RAPI"""
743 743
  try:
744
    _rapi_client.GetInstanceConsole(instance["name"])
744
    _rapi_client.GetInstanceConsole(instance.name)
745 745
  except rapi.client.GanetiApiError, err:
746 746
    AssertEqual(err.code, 503)
747 747
  else:
......
782 782
  pnode = inodes[0]
783 783
  # note: pnode:snode are the *current* nodes, so we move it first to
784 784
  # tnode:pnode, then back to pnode:snode
785
  for si, di, pn, sn in [(src_instance["name"], dest_instance["name"],
785
  for si, di, pn, sn in [(src_instance.name, dest_instance.name,
786 786
                          tnode.primary, pnode.primary),
787
                         (dest_instance["name"], src_instance["name"],
787
                         (dest_instance.name, src_instance.name,
788 788
                          pnode.primary, snode.primary)]:
789 789
    cmd = [
790 790
      "../tools/move-instance",
b/qa/qa_tags.py
82 82

  
83 83
def TestInstanceTags(instance):
84 84
  """gnt-instance tags"""
85
  _TestTags(constants.TAG_INSTANCE, instance["name"])
85
  _TestTags(constants.TAG_INSTANCE, instance.name)

Also available in: Unified diff