Revision a1f445d3 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
2460 | 2460 |
raise errors.OpPrereqError("Instance '%s' not known" % |
2461 | 2461 |
self.op.instance_name) |
2462 | 2462 |
|
2463 |
if instance.disk_template != constants.DT_REMOTE_RAID1:
|
|
2463 |
if instance.disk_template not in constants.DTS_NET_MIRROR:
|
|
2464 | 2464 |
raise errors.OpPrereqError("Instance's disk layout is not" |
2465 |
" remote_raid1.")
|
|
2465 |
" network mirrored, cannot failover.")
|
|
2466 | 2466 |
|
2467 | 2467 |
secondary_nodes = instance.secondary_nodes |
2468 | 2468 |
if not secondary_nodes: |
... | ... | |
2636 | 2636 |
return drbd_dev |
2637 | 2637 |
|
2638 | 2638 |
|
2639 |
def _GenerateDRBD8Branch(cfg, primary, secondary, size, names, iv_name): |
|
2640 |
"""Generate a drbd8 device complete with its children. |
|
2641 |
|
|
2642 |
""" |
|
2643 |
port = cfg.AllocatePort() |
|
2644 |
vgname = cfg.GetVGName() |
|
2645 |
dev_data = objects.Disk(dev_type=constants.LD_LV, size=size, |
|
2646 |
logical_id=(vgname, names[0])) |
|
2647 |
dev_meta = objects.Disk(dev_type=constants.LD_LV, size=128, |
|
2648 |
logical_id=(vgname, names[1])) |
|
2649 |
drbd_dev = objects.Disk(dev_type=constants.LD_DRBD8, size=size, |
|
2650 |
logical_id = (primary, secondary, port), |
|
2651 |
children = [dev_data, dev_meta], |
|
2652 |
iv_name=iv_name) |
|
2653 |
return drbd_dev |
|
2654 |
|
|
2639 | 2655 |
def _GenerateDiskTemplate(cfg, template_name, |
2640 | 2656 |
instance_name, primary_node, |
2641 | 2657 |
secondary_nodes, disk_sz, swap_sz): |
... | ... | |
2696 | 2712 |
md_sdb_dev = objects.Disk(dev_type=constants.LD_MD_R1, iv_name="sdb", |
2697 | 2713 |
children = [drbd_sdb_dev], size=swap_sz) |
2698 | 2714 |
disks = [md_sda_dev, md_sdb_dev] |
2715 |
elif template_name == constants.DT_DRBD8: |
|
2716 |
if len(secondary_nodes) != 1: |
|
2717 |
raise errors.ProgrammerError("Wrong template configuration") |
|
2718 |
remote_node = secondary_nodes[0] |
|
2719 |
names = _GenerateUniqueNames(cfg, [".sda_data", ".sda_meta", |
|
2720 |
".sdb_data", ".sdb_meta"]) |
|
2721 |
drbd_sda_dev = _GenerateDRBD8Branch(cfg, primary_node, remote_node, |
|
2722 |
disk_sz, names[0:2], "sda") |
|
2723 |
drbd_sdb_dev = _GenerateDRBD8Branch(cfg, primary_node, remote_node, |
|
2724 |
swap_sz, names[2:4], "sdb") |
|
2725 |
disks = [drbd_sda_dev, drbd_sdb_dev] |
|
2699 | 2726 |
else: |
2700 | 2727 |
raise errors.ProgrammerError("Invalid disk template '%s'" % template_name) |
2701 | 2728 |
return disks |
... | ... | |
2872 | 2899 |
if self.op.disk_template not in constants.DISK_TEMPLATES: |
2873 | 2900 |
raise errors.OpPrereqError("Invalid disk template name") |
2874 | 2901 |
|
2875 |
if self.op.disk_template == constants.DT_REMOTE_RAID1:
|
|
2902 |
if self.op.disk_template in constants.DTS_NET_MIRROR:
|
|
2876 | 2903 |
if getattr(self.op, "snode", None) is None: |
2877 |
raise errors.OpPrereqError("The 'remote_raid1' disk template needs"
|
|
2904 |
raise errors.OpPrereqError("The networked disk templates need"
|
|
2878 | 2905 |
" a mirror node") |
2879 | 2906 |
|
2880 | 2907 |
snode_name = self.cfg.ExpandNodeName(self.op.snode) |
... | ... | |
2897 | 2924 |
constants.DT_LOCAL_RAID1: (self.op.disk_size + self.op.swap_size) * 2, |
2898 | 2925 |
# 256 MB are added for drbd metadata, 128MB for each drbd device |
2899 | 2926 |
constants.DT_REMOTE_RAID1: self.op.disk_size + self.op.swap_size + 256, |
2927 |
constants.DT_DRBD8: self.op.disk_size + self.op.swap_size + 256, |
|
2900 | 2928 |
} |
2901 | 2929 |
|
2902 | 2930 |
if self.op.disk_template not in req_size_dict: |
... | ... | |
3006 | 3034 |
|
3007 | 3035 |
if self.op.wait_for_sync: |
3008 | 3036 |
disk_abort = not _WaitForSync(self.cfg, iobj) |
3009 |
elif iobj.disk_template == constants.DT_REMOTE_RAID1:
|
|
3037 |
elif iobj.disk_template in constants.DTS_NET_MIRROR:
|
|
3010 | 3038 |
# make sure the disks are not degraded (still sync-ing is ok) |
3011 | 3039 |
time.sleep(15) |
3012 | 3040 |
feedback_fn("* checking mirrors status") |
... | ... | |
3486 | 3514 |
""" |
3487 | 3515 |
self.cfg.SetDiskID(dev, instance.primary_node) |
3488 | 3516 |
dev_pstatus = rpc.call_blockdev_find(instance.primary_node, dev) |
3489 |
if dev.dev_type == constants.LD_DRBD7:
|
|
3517 |
if dev.dev_type in constants.LDS_DRBD:
|
|
3490 | 3518 |
# we change the snode then (otherwise we use the one passed in) |
3491 | 3519 |
if dev.logical_id[0] == instance.primary_node: |
3492 | 3520 |
snode = dev.logical_id[1] |
Also available in: Unified diff