Revision 3f78eef2 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1821 | 1821 |
for node, node_disk in inst_disk.ComputeNodeTree(instance.primary_node): |
1822 | 1822 |
cfg.SetDiskID(node_disk, node) |
1823 | 1823 |
is_primary = node == instance.primary_node |
1824 |
result = rpc.call_blockdev_assemble(node, node_disk, is_primary) |
|
1824 |
result = rpc.call_blockdev_assemble(node, node_disk, |
|
1825 |
instance.name, is_primary) |
|
1825 | 1826 |
if not result: |
1826 | 1827 |
logger.Error("could not prepare block device %s on node %s (is_pri" |
1827 | 1828 |
"mary=%s)" % (inst_disk.iv_name, node, is_primary)) |
... | ... | |
2560 | 2561 |
(instance.name, target_node)) |
2561 | 2562 |
|
2562 | 2563 |
|
2563 |
def _CreateBlockDevOnPrimary(cfg, node, device, info): |
|
2564 |
def _CreateBlockDevOnPrimary(cfg, node, instance, device, info):
|
|
2564 | 2565 |
"""Create a tree of block devices on the primary node. |
2565 | 2566 |
|
2566 | 2567 |
This always creates all devices. |
... | ... | |
2568 | 2569 |
""" |
2569 | 2570 |
if device.children: |
2570 | 2571 |
for child in device.children: |
2571 |
if not _CreateBlockDevOnPrimary(cfg, node, child, info): |
|
2572 |
if not _CreateBlockDevOnPrimary(cfg, node, instance, child, info):
|
|
2572 | 2573 |
return False |
2573 | 2574 |
|
2574 | 2575 |
cfg.SetDiskID(device, node) |
2575 |
new_id = rpc.call_blockdev_create(node, device, device.size, True, info) |
|
2576 |
new_id = rpc.call_blockdev_create(node, device, device.size, |
|
2577 |
instance.name, True, info) |
|
2576 | 2578 |
if not new_id: |
2577 | 2579 |
return False |
2578 | 2580 |
if device.physical_id is None: |
... | ... | |
2580 | 2582 |
return True |
2581 | 2583 |
|
2582 | 2584 |
|
2583 |
def _CreateBlockDevOnSecondary(cfg, node, device, force, info): |
|
2585 |
def _CreateBlockDevOnSecondary(cfg, node, instance, device, force, info):
|
|
2584 | 2586 |
"""Create a tree of block devices on a secondary node. |
2585 | 2587 |
|
2586 | 2588 |
If this device type has to be created on secondaries, create it and |
... | ... | |
2593 | 2595 |
force = True |
2594 | 2596 |
if device.children: |
2595 | 2597 |
for child in device.children: |
2596 |
if not _CreateBlockDevOnSecondary(cfg, node, child, force, info): |
|
2598 |
if not _CreateBlockDevOnSecondary(cfg, node, instance, |
|
2599 |
child, force, info): |
|
2597 | 2600 |
return False |
2598 | 2601 |
|
2599 | 2602 |
if not force: |
2600 | 2603 |
return True |
2601 | 2604 |
cfg.SetDiskID(device, node) |
2602 |
new_id = rpc.call_blockdev_create(node, device, device.size, False, info) |
|
2605 |
new_id = rpc.call_blockdev_create(node, device, device.size, |
|
2606 |
instance.name, False, info) |
|
2603 | 2607 |
if not new_id: |
2604 | 2608 |
return False |
2605 | 2609 |
if device.physical_id is None: |
... | ... | |
2754 | 2758 |
(device.iv_name, instance.name)) |
2755 | 2759 |
#HARDCODE |
2756 | 2760 |
for secondary_node in instance.secondary_nodes: |
2757 |
if not _CreateBlockDevOnSecondary(cfg, secondary_node, device, False,
|
|
2758 |
info): |
|
2761 |
if not _CreateBlockDevOnSecondary(cfg, secondary_node, instance,
|
|
2762 |
device, False, info):
|
|
2759 | 2763 |
logger.Error("failed to create volume %s (%s) on secondary node %s!" % |
2760 | 2764 |
(device.iv_name, device, secondary_node)) |
2761 | 2765 |
return False |
2762 | 2766 |
#HARDCODE |
2763 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, device, info): |
|
2767 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, |
|
2768 |
instance, device, info): |
|
2764 | 2769 |
logger.Error("failed to create volume %s on primary!" % |
2765 | 2770 |
device.iv_name) |
2766 | 2771 |
return False |
... | ... | |
3206 | 3211 |
|
3207 | 3212 |
logger.Info("adding new mirror component on secondary") |
3208 | 3213 |
#HARDCODE |
3209 |
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, new_drbd, False, |
|
3214 |
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, instance, |
|
3215 |
new_drbd, False, |
|
3210 | 3216 |
_GetInstanceInfoText(instance)): |
3211 | 3217 |
raise errors.OpExecError("Failed to create new component on secondary" |
3212 | 3218 |
" node %s" % remote_node) |
3213 | 3219 |
|
3214 | 3220 |
logger.Info("adding new mirror component on primary") |
3215 | 3221 |
#HARDCODE |
3216 |
if not _CreateBlockDevOnPrimary(self.cfg, instance.primary_node, new_drbd, |
|
3222 |
if not _CreateBlockDevOnPrimary(self.cfg, instance.primary_node, |
|
3223 |
instance, new_drbd, |
|
3217 | 3224 |
_GetInstanceInfoText(instance)): |
3218 | 3225 |
# remove secondary dev |
3219 | 3226 |
self.cfg.SetDiskID(new_drbd, remote_node) |
... | ... | |
3444 | 3451 |
logger.Info("adding new mirror component on secondary for %s" % |
3445 | 3452 |
dev.iv_name) |
3446 | 3453 |
#HARDCODE |
3447 |
if not _CreateBlockDevOnSecondary(cfg, remote_node, new_drbd, False, |
|
3454 |
if not _CreateBlockDevOnSecondary(cfg, remote_node, instance, |
|
3455 |
new_drbd, False, |
|
3448 | 3456 |
_GetInstanceInfoText(instance)): |
3449 | 3457 |
raise errors.OpExecError("Failed to create new component on" |
3450 | 3458 |
" secondary node %s\n" |
... | ... | |
3453 | 3461 |
|
3454 | 3462 |
logger.Info("adding new mirror component on primary") |
3455 | 3463 |
#HARDCODE |
3456 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, new_drbd, |
|
3464 |
if not _CreateBlockDevOnPrimary(cfg, instance.primary_node, |
|
3465 |
instance, new_drbd, |
|
3457 | 3466 |
_GetInstanceInfoText(instance)): |
3458 | 3467 |
# remove secondary dev |
3459 | 3468 |
cfg.SetDiskID(new_drbd, remote_node) |
... | ... | |
3558 | 3567 |
# _Create...OnPrimary (which forces the creation), even if we |
3559 | 3568 |
# are talking about the secondary node |
3560 | 3569 |
for new_lv in new_lvs: |
3561 |
if not _CreateBlockDevOnPrimary(cfg, tgt_node, new_lv, |
|
3570 |
if not _CreateBlockDevOnPrimary(cfg, tgt_node, instance, new_lv,
|
|
3562 | 3571 |
_GetInstanceInfoText(instance)): |
3563 | 3572 |
raise errors.OpExecError("Failed to create new LV named '%s' on" |
3564 | 3573 |
" node '%s'" % |
... | ... | |
3669 | 3678 |
# _Create...OnPrimary (which forces the creation), even if we |
3670 | 3679 |
# are talking about the secondary node |
3671 | 3680 |
for new_lv in dev.children: |
3672 |
if not _CreateBlockDevOnPrimary(cfg, new_node, new_lv, |
|
3681 |
if not _CreateBlockDevOnPrimary(cfg, new_node, instance, new_lv,
|
|
3673 | 3682 |
_GetInstanceInfoText(instance)): |
3674 | 3683 |
raise errors.OpExecError("Failed to create new LV named '%s' on" |
3675 | 3684 |
" node '%s'" % |
... | ... | |
3680 | 3689 |
logical_id=(pri_node, new_node, |
3681 | 3690 |
dev.logical_id[2]), |
3682 | 3691 |
children=dev.children) |
3683 |
if not _CreateBlockDevOnSecondary(cfg, new_node, new_drbd, False, |
|
3692 |
if not _CreateBlockDevOnSecondary(cfg, new_node, instance, |
|
3693 |
new_drbd, False, |
|
3684 | 3694 |
_GetInstanceInfoText(instance)): |
3685 | 3695 |
raise errors.OpExecError("Failed to create new DRBD on" |
3686 | 3696 |
" node '%s'" % new_node) |
Also available in: Unified diff