Revision 54155f52 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
4035 | 4035 |
else: |
4036 | 4036 |
raise errors.ProgrammerError("Unhandled disk replace mode") |
4037 | 4037 |
|
4038 |
for name in self.op.disks: |
|
4039 |
if instance.FindDisk(name) is None: |
|
4038 |
if not self.op.disks: |
|
4039 |
self.op.disks = range(len(instance.disks)) |
|
4040 |
|
|
4041 |
for disk_idx in self.op.disks: |
|
4042 |
if disk_idx < 0 or disk_idx >= len(instance.disks): |
|
4040 | 4043 |
raise errors.OpPrereqError("Disk '%s' not found for instance '%s'" % |
4041 | 4044 |
(name, instance.name)) |
4042 | 4045 |
|
... | ... | |
4079 | 4082 |
if not res or my_vg not in res: |
4080 | 4083 |
raise errors.OpExecError("Volume group '%s' not found on %s" % |
4081 | 4084 |
(my_vg, node)) |
4082 |
for dev in instance.disks:
|
|
4083 |
if not dev.iv_name in self.op.disks:
|
|
4085 |
for idx, dev in enumerate(instance.disks):
|
|
4086 |
if idx not in self.op.disks:
|
|
4084 | 4087 |
continue |
4085 | 4088 |
for node in tgt_node, oth_node: |
4086 |
info("checking %s on %s" % (dev.iv_name, node))
|
|
4089 |
info("checking disk/%d on %s" % (idx, node))
|
|
4087 | 4090 |
cfg.SetDiskID(dev, node) |
4088 | 4091 |
if not self.rpc.call_blockdev_find(node, dev): |
4089 |
raise errors.OpExecError("Can't find device %s on node %s" %
|
|
4090 |
(dev.iv_name, node))
|
|
4092 |
raise errors.OpExecError("Can't find disk/%d on node %s" %
|
|
4093 |
(idx, node))
|
|
4091 | 4094 |
|
4092 | 4095 |
# Step: check other node consistency |
4093 | 4096 |
self.proc.LogStep(2, steps_total, "check peer consistency") |
4094 |
for dev in instance.disks:
|
|
4095 |
if not dev.iv_name in self.op.disks:
|
|
4097 |
for idx, dev in enumerate(instance.disks):
|
|
4098 |
if idx not in self.op.disks:
|
|
4096 | 4099 |
continue |
4097 |
info("checking %s consistency on %s" % (dev.iv_name, oth_node))
|
|
4100 |
info("checking disk/%d consistency on %s" % (idx, oth_node))
|
|
4098 | 4101 |
if not _CheckDiskConsistency(self, dev, oth_node, |
4099 | 4102 |
oth_node==instance.primary_node): |
4100 | 4103 |
raise errors.OpExecError("Peer node (%s) has degraded storage, unsafe" |
... | ... | |
4103 | 4106 |
|
4104 | 4107 |
# Step: create new storage |
4105 | 4108 |
self.proc.LogStep(3, steps_total, "allocate new storage") |
4106 |
for dev in instance.disks:
|
|
4107 |
if not dev.iv_name in self.op.disks:
|
|
4109 |
for idx, dev in enumerate(instance.disks):
|
|
4110 |
if idx not in self.op.disks:
|
|
4108 | 4111 |
continue |
4109 | 4112 |
size = dev.size |
4110 | 4113 |
cfg.SetDiskID(dev, tgt_node) |
4111 |
lv_names = [".%s_%s" % (dev.iv_name, suf) for suf in ["data", "meta"]] |
|
4114 |
lv_names = [".disk%d_%s" % (idx, suf) |
|
4115 |
for suf in ["data", "meta"]] |
|
4112 | 4116 |
names = _GenerateUniqueNames(self, lv_names) |
4113 | 4117 |
lv_data = objects.Disk(dev_type=constants.LD_LV, size=size, |
4114 | 4118 |
logical_id=(vgname, names[0])) |
Also available in: Unified diff