Revision bd5e77f9 tools/burnin

b/tools/burnin
23 23

  
24 24
"""
25 25

  
26
import os
26 27
import sys
27 28
import optparse
28 29
from itertools import izip, islice, cycle
......
121 122
    parser.add_option("--no-failover", dest="do_failover",
122 123
                      help="Skip instance failovers", action="store_false",
123 124
                      default=True)
125
    parser.add_option("--no-importexport", dest="do_importexport",
126
                      help="Skip instance export/import", action="store_false",
127
                      default=True)
124 128
    parser.add_option("-t", "--disk-template", dest="disk_template",
125 129
                      choices=("plain", "remote_raid1", "drbd"),
126 130
                      default="remote_raid1",
......
258 262
      Log("- Failover instance %s" % (instance))
259 263
      self.ExecOp(op)
260 264

  
265
  def ImportExport(self):
266
    """Export the instance, delete it, and import it back.
267

  
268
    """
269

  
270
    mytor = izip(cycle(self.nodes),
271
                 islice(cycle(self.nodes), 1, None),
272
                 islice(cycle(self.nodes), 2, None),
273
                 self.instances)
274

  
275
    for pnode, snode, enode, instance in mytor:
276
      exp_op = opcodes.OpExportInstance(instance_name=instance,
277
                                           target_node=enode,
278
                                           shutdown=True)
279
      rem_op = opcodes.OpRemoveInstance(instance_name=instance)
280
      nam_op = opcodes.OpQueryInstances(output_fields=["name"],
281
                                           names=[instance])
282
      full_name = self.ExecOp(nam_op)[0][0]
283
      imp_dir = os.path.join(constants.EXPORT_DIR, full_name)
284
      imp_op = opcodes.OpCreateInstance(instance_name=instance,
285
                                        mem_size=128,
286
                                        disk_size=self.opts.os_size,
287
                                        swap_size=self.opts.swap_size,
288
                                        disk_template=self.opts.disk_template,
289
                                        mode=constants.INSTANCE_IMPORT,
290
                                        src_node=enode,
291
                                        src_path=imp_dir,
292
                                        pnode=pnode,
293
                                        snode=snode,
294
                                        vcpus=1,
295
                                        start=True,
296
                                        ip_check=True,
297
                                        wait_for_sync=True,
298
                                        mac="auto")
299

  
300
      Log("- Export instance %s to node %s" % (instance, enode))
301
      self.ExecOp(exp_op)
302
      Log("- Remove instance %s" % (instance))
303
      self.ExecOp(rem_op)
304
      self.to_rem.remove(instance)
305
      Log("- Import instance %s from node %s to node %s" %
306
          (instance, enode, pnode))
307
      self.ExecOp(imp_op)
308
      self.to_rem.append(instance)
309

  
261 310
  def StopStart(self):
262 311
    """Stop/start the instances."""
263 312
    for instance in self.instances:
......
307 356
      if opts.do_failover and opts.disk_template in constants.DTS_NET_MIRROR:
308 357
        self.Failover()
309 358

  
359
      if opts.do_importexport:
360
        self.ImportExport()
361

  
310 362
      self.StopStart()
311 363
      has_err = False
312 364
    finally:

Also available in: Unified diff