Revision 1cf9ade2 lib/cmdlib/instance.py
b/lib/cmdlib/instance.py | ||
---|---|---|
1221 | 1221 |
# Check disk access param to be compatible with specified hypervisor |
1222 | 1222 |
node_info = self.cfg.GetNodeInfo(self.op.pnode_uuid) |
1223 | 1223 |
node_group = self.cfg.GetNodeGroup(node_info.group) |
1224 |
disk_params = self.cfg.GetGroupDiskParams(node_group) |
|
1225 |
access_type = disk_params[self.op.disk_template].get(
|
|
1224 |
group_disk_params = self.cfg.GetGroupDiskParams(node_group)
|
|
1225 |
group_access_type = group_disk_params[self.op.disk_template].get(
|
|
1226 | 1226 |
constants.RBD_ACCESS, constants.DISK_KERNELSPACE |
1227 | 1227 |
) |
1228 |
|
|
1229 |
if not IsValidDiskAccessModeCombination(self.op.hypervisor, |
|
1230 |
self.op.disk_template, |
|
1231 |
access_type): |
|
1232 |
raise errors.OpPrereqError("Selected hypervisor (%s) cannot be" |
|
1233 |
" used with %s disk access param" % |
|
1234 |
(self.op.hypervisor, access_type), |
|
1235 |
errors.ECODE_STATE) |
|
1228 |
for dsk in self.disks: |
|
1229 |
access_type = dsk.get(constants.IDISK_ACCESS, group_access_type) |
|
1230 |
if not IsValidDiskAccessModeCombination(self.op.hypervisor, |
|
1231 |
self.op.disk_template, |
|
1232 |
access_type): |
|
1233 |
raise errors.OpPrereqError("Selected hypervisor (%s) cannot be" |
|
1234 |
" used with %s disk access param" % |
|
1235 |
(self.op.hypervisor, access_type), |
|
1236 |
errors.ECODE_STATE) |
|
1236 | 1237 |
|
1237 | 1238 |
# Verify instance specs |
1238 | 1239 |
spindle_use = self.be_full.get(constants.BE_SPINDLE_USE, None) |
... | ... | |
2368 | 2369 |
else: |
2369 | 2370 |
raise errors.ProgrammerError("Unhandled operation '%s'" % op) |
2370 | 2371 |
|
2371 |
def _VerifyDiskModification(self, op, params, excl_stor): |
|
2372 |
def _VerifyDiskModification(self, op, params, excl_stor, group_access_type):
|
|
2372 | 2373 |
"""Verifies a disk modification. |
2373 | 2374 |
|
2374 | 2375 |
""" |
... | ... | |
2391 | 2392 |
|
2392 | 2393 |
CheckSpindlesExclusiveStorage(params, excl_stor, True) |
2393 | 2394 |
|
2395 |
# Check disk access param (only for specific disks) |
|
2396 |
if self.instance.disk_template in constants.DTS_HAVE_ACCESS: |
|
2397 |
access_type = params.get(constants.IDISK_ACCESS, group_access_type) |
|
2398 |
if not IsValidDiskAccessModeCombination(self.instance.hypervisor, |
|
2399 |
self.instance.disk_template, |
|
2400 |
access_type): |
|
2401 |
raise errors.OpPrereqError("Selected hypervisor (%s) cannot be" |
|
2402 |
" used with %s disk access param" % |
|
2403 |
(self.op.hypervisor, access_type), |
|
2404 |
errors.ECODE_STATE) |
|
2405 |
|
|
2394 | 2406 |
elif op == constants.DDM_MODIFY: |
2395 | 2407 |
if constants.IDISK_SIZE in params: |
2396 | 2408 |
raise errors.OpPrereqError("Disk size change not possible, use" |
... | ... | |
2400 | 2412 |
# Changing arbitrary parameters is allowed only for ext disk template", |
2401 | 2413 |
if self.instance.disk_template != constants.DT_EXT: |
2402 | 2414 |
utils.ForceDictType(params, constants.MODIFIABLE_IDISK_PARAMS_TYPES) |
2415 |
else: |
|
2416 |
# We have to check that 'access' parameter can not be modified |
|
2417 |
if constants.IDISK_ACCESS in params: |
|
2418 |
raise errors.OpPrereqError("Disk 'access' parameter change is" |
|
2419 |
" not possible", errors.ECODE_INVAL) |
|
2403 | 2420 |
|
2404 | 2421 |
name = params.get(constants.IDISK_NAME, None) |
2405 | 2422 |
if name is not None and name.lower() == constants.VALUE_NONE: |
... | ... | |
2781 | 2798 |
self.instance.all_nodes).values() |
2782 | 2799 |
) |
2783 | 2800 |
|
2801 |
# Get the group access type |
|
2802 |
node_info = self.cfg.GetNodeInfo(self.instance.primary_node) |
|
2803 |
node_group = self.cfg.GetNodeGroup(node_info.group) |
|
2804 |
group_disk_params = self.cfg.GetGroupDiskParams(node_group) |
|
2805 |
group_access_type = group_disk_params[self.instance.disk_template].get( |
|
2806 |
constants.RBD_ACCESS, constants.DISK_KERNELSPACE |
|
2807 |
) |
|
2808 |
|
|
2784 | 2809 |
# Check disk modifications. This is done here and not in CheckArguments |
2785 | 2810 |
# (as with NICs), because we need to know the instance's disk template |
2786 |
ver_fn = lambda op, par: self._VerifyDiskModification(op, par, excl_stor) |
|
2811 |
ver_fn = lambda op, par: self._VerifyDiskModification(op, par, excl_stor, |
|
2812 |
group_access_type) |
|
2787 | 2813 |
if self.instance.disk_template == constants.DT_EXT: |
2788 | 2814 |
self._CheckMods("disk", self.op.disks, {}, ver_fn) |
2789 | 2815 |
else: |
Also available in: Unified diff