Revision d9b7a0b4

b/tools/burnin
247 247
      raise BurninFailure()
248 248
    return results
249 249

  
250
  def _DoCheckInstances(fn):
251
    """Decorator for checking instances.
252

  
253
    """
254
    def wrapper(self, *args, **kwargs):
255
      val = fn(self, *args, **kwargs)
256
      for instance in self.instances:
257
        self._CheckInstanceAlive(instance)
258
      return val
259

  
260
    return wrapper
261

  
250 262
  def ParseOptions(self):
251 263
    """Parses the command line options.
252 264

  
......
415 427
    if self.opts.os not in os_set:
416 428
      Err("OS '%s' not found" % self.opts.os)
417 429

  
430
  @_DoCheckInstances
418 431
  def BurnCreateInstances(self):
419 432
    """Create the given instances.
420 433

  
......
463 476

  
464 477
    self.CommitQueue()
465 478

  
466
    for instance in self.instances:
467
      self._CheckInstanceAlive(instance)
468

  
469 479
  def BurnGrowDisks(self):
470 480
    """Grow both the os and the swap disks by the requested amount, if any."""
471 481
    Log("Growing disks")
......
520 530
      self.ExecOrQueue(instance, op)
521 531
    self.CommitQueue()
522 532

  
533
  @_DoCheckInstances
523 534
  def BurnFailover(self):
524 535
    """Failover the instances."""
525 536
    Log("Failing over instances")
......
531 542

  
532 543
      self.ExecOrQueue(instance, op)
533 544
    self.CommitQueue()
534
    for instance in self.instances:
535
      self._CheckInstanceAlive(instance)
536 545

  
537 546
  def BurnMigrate(self):
538 547
    """Migrate the instances."""
......
549 558
      self.ExecOrQueue(instance, op1, op2)
550 559
    self.CommitQueue()
551 560

  
561
  @_DoCheckInstances
552 562
  def BurnImportExport(self):
553 563
    """Export the instance, delete it, and import it back.
554 564

  
......
615 625
      self.ExecOrQueue(instance, exp_op, rem_op, imp_op, erem_op)
616 626

  
617 627
    self.CommitQueue()
618
    for instance in self.instances:
619
      self._CheckInstanceAlive(instance)
620 628

  
621 629
  def StopInstanceOp(self, instance):
622 630
    """Stop given instance."""
......
631 639
    return opcodes.OpRenameInstance(instance_name=instance,
632 640
                                    new_name=instance_new)
633 641

  
642
  @_DoCheckInstances
634 643
  def BurnStopStart(self):
635 644
    """Stop/start the instances."""
636 645
    Log("Stopping and starting instances")
......
643 652

  
644 653
    self.CommitQueue()
645 654

  
646
    for instance in self.instances:
647
      self._CheckInstanceAlive(instance)
648

  
649 655
  def BurnRemove(self):
650 656
    """Remove the instances."""
651 657
    self.StartBatch(False)
......
680 686
      self.ExecOp(False, op_stop2, op_rename2, op_start2)
681 687
      self._CheckInstanceAlive(instance)
682 688

  
689
  @_DoCheckInstances
683 690
  def BurnReinstall(self):
684 691
    """Reinstall the instances."""
685 692
    Log("Reinstalling instances")
......
697 704

  
698 705
    self.CommitQueue()
699 706

  
700
    for instance in self.instances:
701
      self._CheckInstanceAlive(instance)
702

  
707
  @_DoCheckInstances
703 708
  def BurnReboot(self):
704 709
    """Reboot the instances."""
705 710
    Log("Rebooting instances")
......
717 722

  
718 723
    self.CommitQueue()
719 724

  
720
    for instance in self.instances:
721
      self._CheckInstanceAlive(instance)
722

  
725
  @_DoCheckInstances
723 726
  def BurnActivateDisks(self):
724 727
    """Activate and deactivate disks of the instances."""
725 728
    Log("Activating/deactivating disks")
......
735 738
      Log("deactivate disks (when offline)", indent=2)
736 739
      self.ExecOrQueue(instance, op_act, op_stop, op_act, op_deact, op_start)
737 740
    self.CommitQueue()
738
    for instance in self.instances:
739
      self._CheckInstanceAlive(instance)
740 741

  
742
  @_DoCheckInstances
741 743
  def BurnAddRemoveDisks(self):
742 744
    """Add and remove an extra disk for the instances."""
743 745
    Log("Adding and removing disks")
......
755 757
      Log("removing last disk", indent=2)
756 758
      self.ExecOrQueue(instance, op_add, op_stop, op_rem, op_start)
757 759
    self.CommitQueue()
758
    for instance in self.instances:
759
      self._CheckInstanceAlive(instance)
760 760

  
761 761
  def BurnAddRemoveNICs(self):
762 762
    """Add and remove an extra NIC for the instances."""

Also available in: Unified diff