Revision 796cab27
b/lib/cmdlib.py | ||
---|---|---|
3699 | 3699 |
""" |
3700 | 3700 |
if device.children: |
3701 | 3701 |
for child in device.children: |
3702 |
if not _CreateBlockDevOnPrimary(lu, node, instance, child, info): |
|
3703 |
return False |
|
3702 |
_CreateBlockDevOnPrimary(lu, node, instance, child, info) |
|
3704 | 3703 |
|
3705 | 3704 |
lu.cfg.SetDiskID(device, node) |
3706 | 3705 |
new_id = lu.rpc.call_blockdev_create(node, device, device.size, |
3707 | 3706 |
instance.name, True, info) |
3708 | 3707 |
if new_id.failed or not new_id.data: |
3709 |
return False |
|
3708 |
raise errors.OpExecError("Can't create block device %s on primary" |
|
3709 |
" node %s" % (device, node)) |
|
3710 | 3710 |
if device.physical_id is None: |
3711 | 3711 |
device.physical_id = new_id |
3712 |
return True |
|
3713 | 3712 |
|
3714 | 3713 |
|
3715 | 3714 |
def _CreateBlockDevOnSecondary(lu, node, instance, device, force, info): |
... | ... | |
3723 | 3722 |
""" |
3724 | 3723 |
if device.CreateOnSecondary(): |
3725 | 3724 |
force = True |
3725 |
|
|
3726 | 3726 |
if device.children: |
3727 | 3727 |
for child in device.children: |
3728 |
if not _CreateBlockDevOnSecondary(lu, node, instance, |
|
3729 |
child, force, info): |
|
3730 |
return False |
|
3728 |
_CreateBlockDevOnSecondary(lu, node, instance, child, force, info) |
|
3731 | 3729 |
|
3732 | 3730 |
if not force: |
3733 |
return True |
|
3731 |
return |
|
3732 |
|
|
3734 | 3733 |
lu.cfg.SetDiskID(device, node) |
3735 | 3734 |
new_id = lu.rpc.call_blockdev_create(node, device, device.size, |
3736 | 3735 |
instance.name, False, info) |
3737 | 3736 |
if new_id.failed or not new_id.data: |
3738 |
return False |
|
3737 |
raise errors.OpExecError("Can't create block device %s on secondary" |
|
3738 |
" node %s" % (device, node)) |
|
3739 | 3739 |
if device.physical_id is None: |
3740 | 3740 |
device.physical_id = new_id |
3741 |
return True |
|
3742 | 3741 |
|
3743 | 3742 |
|
3744 | 3743 |
def _GenerateUniqueNames(lu, exts): |
... | ... | |
3866 | 3865 |
file_storage_dir) |
3867 | 3866 |
|
3868 | 3867 |
if result.failed or not result.data: |
3869 |
logging.error("Could not connect to node '%s'", instance.primary_node)
|
|
3870 |
return False
|
|
3868 |
raise errors.OpExecError("Could not connect to node '%s'" %
|
|
3869 |
instance.primary_node)
|
|
3871 | 3870 |
|
3872 | 3871 |
if not result.data[0]: |
3873 |
logging.error("Failed to create directory '%s'", file_storage_dir)
|
|
3874 |
return False
|
|
3872 |
raise errors.OpExecError("Failed to create directory '%s'" %
|
|
3873 |
file_storage_dir)
|
|
3875 | 3874 |
|
3876 | 3875 |
# Note: this needs to be kept in sync with adding of disks in |
3877 | 3876 |
# LUSetInstanceParams |
... | ... | |
3880 | 3879 |
device.iv_name, instance.name) |
3881 | 3880 |
#HARDCODE |
3882 | 3881 |
for secondary_node in instance.secondary_nodes: |
3883 |
if not _CreateBlockDevOnSecondary(lu, secondary_node, instance, |
|
3884 |
device, False, info): |
|
3885 |
logging.error("Failed to create volume %s (%s) on secondary node %s!", |
|
3886 |
device.iv_name, device, secondary_node) |
|
3887 |
return False |
|
3882 |
_CreateBlockDevOnSecondary(lu, secondary_node, instance, |
|
3883 |
device, False, info) |
|
3888 | 3884 |
#HARDCODE |
3889 |
if not _CreateBlockDevOnPrimary(lu, instance.primary_node, |
|
3890 |
instance, device, info): |
|
3891 |
logging.error("Failed to create volume %s on primary!", device.iv_name) |
|
3892 |
return False |
|
3893 |
|
|
3894 |
return True |
|
3885 |
_CreateBlockDevOnPrimary(lu, instance.primary_node, |
|
3886 |
instance, device, info) |
|
3895 | 3887 |
|
3896 | 3888 |
|
3897 | 3889 |
def _RemoveDisks(lu, instance): |
... | ... | |
4448 | 4440 |
) |
4449 | 4441 |
|
4450 | 4442 |
feedback_fn("* creating instance disks...") |
4451 |
if not _CreateDisks(self, iobj): |
|
4452 |
_RemoveDisks(self, iobj) |
|
4453 |
self.cfg.ReleaseDRBDMinors(instance) |
|
4454 |
raise errors.OpExecError("Device creation failed, reverting...") |
|
4443 |
try: |
|
4444 |
_CreateDisks(self, iobj) |
|
4445 |
except errors.OpExecError: |
|
4446 |
self.LogWarning("Device creation failed, reverting...") |
|
4447 |
try: |
|
4448 |
_RemoveDisks(self, iobj) |
|
4449 |
finally: |
|
4450 |
self.cfg.ReleaseDRBDMinors(instance) |
|
4451 |
raise |
|
4455 | 4452 |
|
4456 | 4453 |
feedback_fn("adding instance %s to cluster config" % instance) |
4457 | 4454 |
|
... | ... | |
4827 | 4824 |
# _Create...OnPrimary (which forces the creation), even if we |
4828 | 4825 |
# are talking about the secondary node |
4829 | 4826 |
for new_lv in new_lvs: |
4830 |
if not _CreateBlockDevOnPrimary(self, tgt_node, instance, new_lv, |
|
4831 |
_GetInstanceInfoText(instance)): |
|
4832 |
raise errors.OpExecError("Failed to create new LV named '%s' on" |
|
4833 |
" node '%s'" % |
|
4834 |
(new_lv.logical_id[1], tgt_node)) |
|
4827 |
_CreateBlockDevOnPrimary(self, tgt_node, instance, new_lv, |
|
4828 |
_GetInstanceInfoText(instance)) |
|
4835 | 4829 |
|
4836 | 4830 |
# Step: for each lv, detach+rename*2+attach |
4837 | 4831 |
self.proc.LogStep(4, steps_total, "change drbd configuration") |
... | ... | |
4998 | 4992 |
# _Create...OnPrimary (which forces the creation), even if we |
4999 | 4993 |
# are talking about the secondary node |
5000 | 4994 |
for new_lv in dev.children: |
5001 |
if not _CreateBlockDevOnPrimary(self, new_node, instance, new_lv, |
|
5002 |
_GetInstanceInfoText(instance)): |
|
5003 |
raise errors.OpExecError("Failed to create new LV named '%s' on" |
|
5004 |
" node '%s'" % |
|
5005 |
(new_lv.logical_id[1], new_node)) |
|
4995 |
_CreateBlockDevOnPrimary(self, new_node, instance, new_lv, |
|
4996 |
_GetInstanceInfoText(instance)) |
|
5006 | 4997 |
|
5007 | 4998 |
# Step 4: dbrd minors and drbd setups changes |
5008 | 4999 |
# after this, we must manually remove the drbd minors on both the |
... | ... | |
5033 | 5024 |
new_drbd = objects.Disk(dev_type=constants.LD_DRBD8, |
5034 | 5025 |
logical_id=new_alone_id, |
5035 | 5026 |
children=dev.children) |
5036 |
if not _CreateBlockDevOnSecondary(self, new_node, instance, |
|
5037 |
new_drbd, False, |
|
5038 |
_GetInstanceInfoText(instance)): |
|
5027 |
try: |
|
5028 |
_CreateBlockDevOnSecondary(self, new_node, instance, new_drbd, False, |
|
5029 |
_GetInstanceInfoText(instance)) |
|
5030 |
except error.BlockDeviceError: |
|
5039 | 5031 |
self.cfg.ReleaseDRBDMinors(instance.name) |
5040 |
raise errors.OpExecError("Failed to create new DRBD on" |
|
5041 |
" node '%s'" % new_node) |
|
5032 |
raise |
|
5042 | 5033 |
|
5043 | 5034 |
for idx, dev in enumerate(instance.disks): |
5044 | 5035 |
# we have new devices, shutdown the drbd on the old secondary |
... | ... | |
5699 | 5690 |
# Note: this needs to be kept in sync with _CreateDisks |
5700 | 5691 |
#HARDCODE |
5701 | 5692 |
for secondary_node in instance.secondary_nodes: |
5702 |
if not _CreateBlockDevOnSecondary(self, secondary_node, instance, |
|
5703 |
new_disk, False, info): |
|
5693 |
try: |
|
5694 |
_CreateBlockDevOnSecondary(self, secondary_node, instance, |
|
5695 |
new_disk, False, info) |
|
5696 |
except error.OpExecError, err: |
|
5704 | 5697 |
self.LogWarning("Failed to create volume %s (%s) on" |
5705 |
" secondary node %s!",
|
|
5706 |
new_disk.iv_name, new_disk, secondary_node) |
|
5698 |
" secondary node %s: %s",
|
|
5699 |
new_disk.iv_name, new_disk, secondary_node, err)
|
|
5707 | 5700 |
#HARDCODE |
5708 |
if not _CreateBlockDevOnPrimary(self, instance.primary_node, |
|
5709 |
instance, new_disk, info): |
|
5710 |
self.LogWarning("Failed to create volume %s on primary!", |
|
5711 |
new_disk.iv_name) |
|
5701 |
try: |
|
5702 |
_CreateBlockDevOnPrimary(self, instance.primary_node, |
|
5703 |
instance, new_disk, info) |
|
5704 |
except errors.OpExecError, err: |
|
5705 |
self.LogWarning("Failed to create volume %s on primary: %s", |
|
5706 |
new_disk.iv_name, err) |
|
5712 | 5707 |
result.append(("disk/%d" % disk_idx_base, "add:size=%s,mode=%s" % |
5713 | 5708 |
(new_disk.size, new_disk.mode))) |
5714 | 5709 |
else: |
Also available in: Unified diff