2277 |
2277 |
else:
|
2278 |
2278 |
raise errors.ProgrammerError("Unhandled operation '%s'" % op)
|
2279 |
2279 |
|
2280 |
|
@staticmethod
|
2281 |
|
def _VerifyDiskModification(op, params):
|
|
2280 |
def _VerifyDiskModification(self, op, params):
|
2282 |
2281 |
"""Verifies a disk modification.
|
2283 |
2282 |
|
2284 |
2283 |
"""
|
... | ... | |
2308 |
2307 |
if constants.IDISK_SIZE in params:
|
2309 |
2308 |
raise errors.OpPrereqError("Disk size change not possible, use"
|
2310 |
2309 |
" grow-disk", errors.ECODE_INVAL)
|
2311 |
|
if len(params) > 2:
|
2312 |
|
raise errors.OpPrereqError("Disk modification doesn't support"
|
2313 |
|
" additional arbitrary parameters",
|
2314 |
|
errors.ECODE_INVAL)
|
|
2310 |
|
|
2311 |
# Disk modification supports changing only the disk name and mode.
|
|
2312 |
# Changing arbitrary parameters is allowed only for ext disk template",
|
|
2313 |
if self.instance.disk_template != constants.DT_EXT:
|
|
2314 |
utils.ForceDictType(params, constants.MODIFIABLE_IDISK_PARAMS_TYPES)
|
|
2315 |
|
2315 |
2316 |
name = params.get(constants.IDISK_NAME, None)
|
2316 |
2317 |
if name is not None and name.lower() == constants.VALUE_NONE:
|
2317 |
2318 |
params[constants.IDISK_NAME] = None
|
... | ... | |
3182 |
3183 |
("disk/%d" % idx, "add:size=%s,mode=%s" % (disk.size, disk.mode)),
|
3183 |
3184 |
])
|
3184 |
3185 |
|
3185 |
|
@staticmethod
|
3186 |
|
def _ModifyDisk(idx, disk, params, _):
|
|
3186 |
def _ModifyDisk(self, idx, disk, params, _):
|
3187 |
3187 |
"""Modifies a disk.
|
3188 |
3188 |
|
3189 |
3189 |
"""
|
... | ... | |
3196 |
3196 |
disk.name = params.get(constants.IDISK_NAME)
|
3197 |
3197 |
changes.append(("disk.name/%d" % idx, disk.name))
|
3198 |
3198 |
|
|
3199 |
# Modify arbitrary params in case instance template is ext
|
|
3200 |
for key, value in params.iteritems():
|
|
3201 |
if (key not in constants.MODIFIABLE_IDISK_PARAMS and
|
|
3202 |
self.instance.disk_template == constants.DT_EXT):
|
|
3203 |
disk.params[key] = value
|
|
3204 |
changes.append(("disk.params:%s/%d" % (key, idx), value))
|
|
3205 |
|
3199 |
3206 |
return changes
|
3200 |
3207 |
|
3201 |
3208 |
def _RemoveDisk(self, idx, root, _):
|