Commit f0d22861 authored by Constantinos Venetsanopoulos's avatar Constantinos Venetsanopoulos Committed by René Nussbaumer

Allow param `modify' during gnt-instance modify

With the new gnt-instance modify syntax for addition and removal of
disks/NICs on arbitrary indexes, we hit an assertion if the user
passes `modify' as one of the disk's parameters. E.g::

 gnt-instance modify --disk 2:modify,size=3G instance1
 gnt-instance modify --disk 3:add,size=1G,modify instance2

This patch fixes the bug, by allowing `modify' to be passed as a
parameter (as happens with `add' and `remove'), as long as it is
not done alongside `add' or `remove'. If so, it is treated in the
same way as if none of modify/add/remove is passed --> modify.
Signed-off-by: default avatarConstantinos Venetsanopoulos <cven@grnet.gr>
Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent cf279f03
......@@ -1306,16 +1306,25 @@ def _ConvertNicDiskModifications(mods):
add = params.pop(constants.DDM_ADD, _MISSING)
remove = params.pop(constants.DDM_REMOVE, _MISSING)
modify = params.pop(constants.DDM_MODIFY, _MISSING)
if modify is _MISSING:
if not (add is _MISSING or remove is _MISSING):
raise errors.OpPrereqError("Cannot add and remove at the same time",
errors.ECODE_INVAL)
elif add is not _MISSING:
action = constants.DDM_ADD
elif remove is not _MISSING:
action = constants.DDM_REMOVE
else:
action = constants.DDM_MODIFY
if not (add is _MISSING or remove is _MISSING):
raise errors.OpPrereqError("Cannot add and remove at the same time",
errors.ECODE_INVAL)
elif add is not _MISSING:
action = constants.DDM_ADD
elif remove is not _MISSING:
action = constants.DDM_REMOVE
else:
action = constants.DDM_MODIFY
if add is _MISSING and remove is _MISSING:
action = constants.DDM_MODIFY
else:
raise errors.OpPrereqError("Cannot modify and add/remove at the"
" same time", errors.ECODE_INVAL)
assert not (constants.DDMS_VALUES_WITH_MODIFY & set(params.keys()))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment