Revision e2fe6369 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
3089 | 3089 |
return result |
3090 | 3090 |
|
3091 | 3091 |
|
3092 |
def _ComputeDiskSize(disk_template, disk_size, swap_size): |
|
3093 |
"""Compute disk size requirements in the volume group |
|
3094 |
|
|
3095 |
This is currently hard-coded for the two-drive layout. |
|
3096 |
|
|
3097 |
""" |
|
3098 |
# Required free disk space as a function of disk and swap space |
|
3099 |
req_size_dict = { |
|
3100 |
constants.DT_DISKLESS: None, |
|
3101 |
constants.DT_PLAIN: disk_size + swap_size, |
|
3102 |
# 256 MB are added for drbd metadata, 128MB for each drbd device |
|
3103 |
constants.DT_DRBD8: disk_size + swap_size + 256, |
|
3104 |
constants.DT_FILE: None, |
|
3105 |
} |
|
3106 |
|
|
3107 |
if disk_template not in req_size_dict: |
|
3108 |
raise errors.ProgrammerError("Disk template '%s' size requirement" |
|
3109 |
" is unknown" % disk_template) |
|
3110 |
|
|
3111 |
return req_size_dict[disk_template] |
|
3112 |
|
|
3113 |
|
|
3092 | 3114 |
class LUCreateInstance(LogicalUnit): |
3093 | 3115 |
"""Create an instance. |
3094 | 3116 |
|
... | ... | |
3224 | 3246 |
" the primary node.") |
3225 | 3247 |
self.secondaries.append(snode_name) |
3226 | 3248 |
|
3227 |
# Required free disk space as a function of disk and swap space |
|
3228 |
req_size_dict = { |
|
3229 |
constants.DT_DISKLESS: None, |
|
3230 |
constants.DT_PLAIN: self.op.disk_size + self.op.swap_size, |
|
3231 |
# 256 MB are added for drbd metadata, 128MB for each drbd device |
|
3232 |
constants.DT_DRBD8: self.op.disk_size + self.op.swap_size + 256, |
|
3233 |
constants.DT_FILE: None, |
|
3234 |
} |
|
3235 |
|
|
3236 |
if self.op.disk_template not in req_size_dict: |
|
3237 |
raise errors.ProgrammerError("Disk template '%s' size requirement" |
|
3238 |
" is unknown" % self.op.disk_template) |
|
3239 |
|
|
3240 |
req_size = req_size_dict[self.op.disk_template] |
|
3249 |
req_size = _ComputeDiskSize(self.op.disk_template, |
|
3250 |
self.op.disk_size, self.op.swap_size) |
|
3241 | 3251 |
|
3242 | 3252 |
# Check lv size requirements |
3243 | 3253 |
if req_size is not None: |
Also available in: Unified diff