示例#1
0
 def MakeOpCode(self, disks, early_release=False, ignore_ipolicy=False,
                remote_node=False, mode='replace_auto'):
   return opcodes.OpInstanceReplaceDisks(
       instance_name=self.instance.name,
       instance_uuid=self.instance.uuid,
       early_release=early_release,
       ignore_ipolicy=ignore_ipolicy,
       mode=mode,
       disks=disks,
       remote_node=self.node2.name if remote_node else None,
       remote_node_uuid=self.node2.uuid if remote_node else None,
       iallocator=None)
示例#2
0
 def BurnReplaceDisks1D8(self):
   """Replace disks on primary and secondary for drbd8."""
   Log("Replacing disks on the same nodes")
   early_release = self.opts.early_release
   for instance in self.instances:
     Log("instance %s", instance, indent=1)
     ops = []
     for mode in constants.REPLACE_DISK_SEC, constants.REPLACE_DISK_PRI:
       op = opcodes.OpInstanceReplaceDisks(instance_name=instance,
                                           mode=mode,
                                           disks=list(range(self.disk_count)),
                                           early_release=early_release)
       Log("run %s", mode, indent=2)
       ops.append(op)
     self.ExecOrQueue(instance, ops)
示例#3
0
文件: burnin.py 项目: badp/ganeti
    def BurnReplaceDisks2(self):
        """Replace secondary node."""
        Log("Changing the secondary node")
        mode = constants.REPLACE_DISK_CHG

        mytor = izip(islice(cycle(self.nodes), 2, None), self.instances)
        for tnode, instance in mytor:
            Log("instance %s", instance, indent=1)
            if self.opts.iallocator:
                tnode = None
                msg = "with iallocator %s" % self.opts.iallocator
            else:
                msg = tnode
            op = opcodes.OpInstanceReplaceDisks(
                instance_name=instance,
                mode=mode,
                remote_node=tnode,
                iallocator=self.opts.iallocator,
                disks=[],
                early_release=self.opts.early_release)
            Log("run %s %s", mode, msg, indent=2)
            self.ExecOrQueue(instance, [op])
    def testSuccess(self):
        for moved in [[],
                      [
                          ("inst20153.example.com", "grp2",
                           ["nodeA4509", "nodeB2912"]),
                      ]]:
            for early_release in [False, True]:
                for use_nodes in [False, True]:
                    jobs = [
                        [opcodes.OpInstanceReplaceDisks().__getstate__()],
                        [opcodes.OpInstanceMigrate().__getstate__()],
                    ]

                    alloc_result = (moved, [], jobs)
                    assert iallocator._NEVAC_RESULT(alloc_result)

                    lu = _FakeLU()
                    result = common.LoadNodeEvacResult(lu, alloc_result,
                                                       early_release,
                                                       use_nodes)

                    if moved:
                        (_, (info_args, )) = lu.info_log.pop(0)
                        for (instname, instgroup, instnodes) in moved:
                            self.assertTrue(instname in info_args)
                            if use_nodes:
                                for i in instnodes:
                                    self.assertTrue(i in info_args)
                            else:
                                self.assertTrue(instgroup in info_args)

                    self.assertFalse(lu.info_log)
                    self.assertFalse(lu.warning_log)

                    for op in itertools.chain(*result):
                        if hasattr(op.__class__, "early_release"):
                            self.assertEqual(op.early_release, early_release)
                        else:
                            self.assertFalse(hasattr(op, "early_release"))