From 9fdc92faed3f27557e010dc31329639814914a14 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Mon, 13 Dec 2010 11:53:39 +0000
Subject: [PATCH] burnin: rename instances to same name

this (a) allows us to test renaming in burnin even if we don't have an
extra instance name and (b) is a valid operation, as it allows to "fix"
an instance who went name-astray

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 tools/burnin | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/burnin b/tools/burnin
index d2dd0def6..30f34bf72 100755
--- a/tools/burnin
+++ b/tools/burnin
@@ -171,6 +171,9 @@ OPTIONS = [
   cli.cli_option("--no-reboot", dest="do_reboot",
                  help="Skip instance reboot", action="store_false",
                  default=True),
+  cli.cli_option("--no-renamesame", dest="do_renamesame",
+                 help="Skip instance rename to same name", action="store_false",
+                 default=True),
   cli.cli_option("--reboot-types", dest="reboot_types",
                  help="Specify the reboot types", default=None),
   cli.cli_option("--no-activate-disks", dest="do_activate_disks",
@@ -870,6 +873,19 @@ class Burner(object):
         ops.append(op)
       self.ExecOrQueue(instance, ops)
 
+  @_DoCheckInstances
+  @_DoBatch(True)
+  def BurnRenameSame(self):
+    """Rename the instances to their own name."""
+    Log("Renaming the instances to their own name")
+    for instance in self.instances:
+      Log("instance %s", instance, indent=1)
+      op1 = self.StopInstanceOp(instance)
+      op2 = self.RenameInstanceOp(instance, instance)
+      Log("rename to the same name", indent=2)
+      op4 = self.StartInstanceOp(instance)
+      self.ExecOrQueue(instance, [op1, op2, op4])
+
   @_DoCheckInstances
   @_DoBatch(True)
   def BurnActivateDisks(self):
@@ -1074,6 +1090,9 @@ class Burner(object):
       if opts.do_reboot:
         self.BurnReboot()
 
+      if opts.do_renamesame:
+        self.BurnRenameSame()
+
       if opts.do_addremove_disks:
         self.BurnAddRemoveDisks()
 
-- 
GitLab