From 00f91f29ebd844f75801e3533039fcc3c6360d53 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 2 Dec 2008 12:58:15 +0000 Subject: [PATCH] burnin: add instance reinstall and reboot These two operations were missing from burnin. The reboot is done with all valid modes (a new constant is added), and the reinstall is done both with and without specifying the OS (to account for the two code paths in the LU). Reviewed-by: imsnah --- lib/constants.py | 4 ++++ tools/burnin | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/constants.py b/lib/constants.py index d8d602274..9e935be9e 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -264,6 +264,10 @@ INSTANCE_REBOOT_SOFT = "soft" INSTANCE_REBOOT_HARD = "hard" INSTANCE_REBOOT_FULL = "full" +REBOOT_TYPES = frozenset([INSTANCE_REBOOT_SOFT, + INSTANCE_REBOOT_HARD, + INSTANCE_REBOOT_FULL]) + # HV parameter names (global namespace) HV_BOOT_ORDER = "boot_order" HV_CDROM_IMAGE_PATH = "cdrom_image_path" diff --git a/tools/burnin b/tools/burnin index 2629b6230..018396c8f 100755 --- a/tools/burnin +++ b/tools/burnin @@ -151,6 +151,12 @@ class Burner(object): parser.add_option("--no-startstop", dest="do_startstop", help="Skip instance stop/start", action="store_false", default=True) + parser.add_option("--no-reinstall", dest="do_reinstall", + help="Skip instance reinstall", action="store_false", + default=True) + parser.add_option("--no-reboot", dest="do_reboot", + help="Skip instance reboot", action="store_false", + default=True) parser.add_option("--no-nics", dest="nics", help="No network interfaces", action="store_const", const=[], default=[{}]) @@ -359,7 +365,8 @@ class Burner(object): if self.opts.iallocator: pnode = snode = None - import_log_msg = ("- Import instance %s from node %s (iallocator: %s)" % + import_log_msg = ("- Import instance %s from node %s" + " (iallocator: %s)" % (instance, enode, self.opts.iallocator)) elif self.opts.disk_template not in constants.DTS_NET_MIRROR: snode = None @@ -457,6 +464,29 @@ class Burner(object): self.RenameInstance(rename, instance) self.StartInstance(instance) + def Reinstall(self): + """Reinstall the instances.""" + for instance in self.instances: + self.StopInstance(instance) + op = opcodes.OpReinstallInstance(instance_name=instance) + Log("- Reinstall instance %s without passing the OS" % (instance,)) + self.ExecOp(op) + op = opcodes.OpReinstallInstance(instance_name=instance, + os_type=self.opts.os) + Log("- Reinstall instance %s specifying the OS" % (instance,)) + self.ExecOp(op) + self.StartInstance(instance) + + def Reboot(self): + """Reinstall the instances.""" + for instance in self.instances: + for reboot_type in constants.REBOOT_TYPES: + op = opcodes.OpRebootInstance(instance_name=instance, + reboot_type=reboot_type, + ignore_secondaries=False) + Log("- Reboot instance %s with type '%s'" % (instance, reboot_type)) + self.ExecOp(op) + def BurninCluster(self): """Test a cluster intensively. @@ -496,6 +526,12 @@ class Burner(object): constants.DT_FILE)): self.ImportExport() + if opts.do_reinstall: + self.Reinstall() + + if opts.do_reboot: + self.Reboot() + if opts.do_startstop: self.StopStart() -- GitLab