Revision cd46491f lib/cmdlib.py
b/lib/cmdlib.py  

8639  8639 
return results 
8640  8640  
8641  8641  
8642 
def _ComputeLDParams(disk_template, disk_params): 

8643 
"""Computes Logical Disk parameters from Disk Template parameters. 

8644  
8645 
@type disk_template: string 

8646 
@param disk_template: disk template, one of L{constants.DISK_TEMPLATES} 

8647 
@type disk_params: dict 

8648 
@param disk_params: disk template parameters; dict(template_name > parameters 

8649 
@rtype: list(dict) 

8650 
@return: a list of dicts, one for each node of the disk hierarchy. Each dict 

8651 
contains the LD parameters of the node. The tree is flattened inorder. 

8652  
8653 
""" 

8654 
if disk_template not in constants.DISK_TEMPLATES: 

8655 
raise errors.ProgrammerError("Unknown disk template %s" % disk_template) 

8656  
8657 
result = list() 

8658 
dt_params = disk_params[disk_template] 

8659 
if disk_template == constants.DT_DRBD8: 

8660 
drbd_params = { 

8661 
constants.LDP_RESYNC_RATE: dt_params[constants.DRBD_RESYNC_RATE], 

8662 
constants.LDP_BARRIERS: dt_params[constants.DRBD_DISK_BARRIERS], 

8663 
constants.LDP_NO_META_FLUSH: dt_params[constants.DRBD_META_BARRIERS], 

8664 
constants.LDP_DEFAULT_METAVG: dt_params[constants.DRBD_DEFAULT_METAVG], 

8665 
constants.LDP_DISK_CUSTOM: dt_params[constants.DRBD_DISK_CUSTOM], 

8666 
constants.LDP_NET_CUSTOM: dt_params[constants.DRBD_NET_CUSTOM], 

8667 
constants.LDP_DYNAMIC_RESYNC: dt_params[constants.DRBD_DYNAMIC_RESYNC], 

8668 
constants.LDP_PLAN_AHEAD: dt_params[constants.DRBD_PLAN_AHEAD], 

8669 
constants.LDP_FILL_TARGET: dt_params[constants.DRBD_FILL_TARGET], 

8670 
constants.LDP_DELAY_TARGET: dt_params[constants.DRBD_DELAY_TARGET], 

8671 
constants.LDP_MAX_RATE: dt_params[constants.DRBD_MAX_RATE], 

8672 
constants.LDP_MIN_RATE: dt_params[constants.DRBD_MIN_RATE], 

8673 
} 

8674  
8675 
drbd_params = \ 

8676 
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_DRBD8], 

8677 
drbd_params) 

8678  
8679 
result.append(drbd_params) 

8680  
8681 
# data LV 

8682 
data_params = { 

8683 
constants.LDP_STRIPES: dt_params[constants.DRBD_DATA_STRIPES], 

8684 
} 

8685 
data_params = \ 

8686 
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], 

8687 
data_params) 

8688 
result.append(data_params) 

8689  
8690 
# metadata LV 

8691 
meta_params = { 

8692 
constants.LDP_STRIPES: dt_params[constants.DRBD_META_STRIPES], 

8693 
} 

8694 
meta_params = \ 

8695 
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], 

8696 
meta_params) 

8697 
result.append(meta_params) 

8698  
8699 
elif (disk_template == constants.DT_FILE or 

8700 
disk_template == constants.DT_SHARED_FILE): 

8701 
result.append(constants.DISK_LD_DEFAULTS[constants.LD_FILE]) 

8702  
8703 
elif disk_template == constants.DT_PLAIN: 

8704 
params = { 

8705 
constants.LDP_STRIPES: dt_params[constants.LV_STRIPES], 

8706 
} 

8707 
params = \ 

8708 
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_LV], 

8709 
params) 

8710 
result.append(params) 

8711  
8712 
elif disk_template == constants.DT_BLOCK: 

8713 
result.append(constants.DISK_LD_DEFAULTS[constants.LD_BLOCKDEV]) 

8714  
8715 
elif disk_template == constants.DT_RBD: 

8716 
params = { 

8717 
constants.LDP_POOL: dt_params[constants.RBD_POOL] 

8718 
} 

8719 
params = \ 

8720 
objects.FillDict(constants.DISK_LD_DEFAULTS[constants.LD_RBD], 

8721 
params) 

8722 
result.append(params) 

8723  
8724 
return result 

8725  
8726  
8727  8642 
def _GenerateDRBD8Branch(lu, primary, secondary, size, vgnames, names, 
8728  8643 
iv_name, p_minor, s_minor, drbd_params, data_params, 
8729  8644 
meta_params): 
Also available in: Unified diff