On Tue, Dec 10, 2013 at 10:14 AM, Dimitris Aragiorgis <[email protected]> wrote:
> Disks of ext template are allowed to have arbitrary parameters
> stored in Disk object's params slot. Those parameters can be
> passed during creation of a new disk, either in LUInstanceCreate()
> or in LUInsanceSetParams(). Still those parameters can not be
> changed afterwards. With this patch we override this limitation.
>
> Signed-off-by: Dimitris Aragiorgis <[email protected]>
> ---
> lib/cmdlib/instance.py | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/lib/cmdlib/instance.py b/lib/cmdlib/instance.py
> index be30315..e01dd13 100644
> --- a/lib/cmdlib/instance.py
> +++ b/lib/cmdlib/instance.py
> @@ -2308,10 +2308,6 @@ class LUInstanceSetParams(LogicalUnit):
> if constants.IDISK_SIZE in params:
> raise errors.OpPrereqError("Disk size change not possible, use"
> " grow-disk", errors.ECODE_INVAL)
> - if len(params) > 2:
> - raise errors.OpPrereqError("Disk modification doesn't support"
> - " additional arbitrary parameters",
> - errors.ECODE_INVAL)
The OpPrereqError exception used to be raised for every template. Now,
this patch wants to prevent it to be raised for the ext template
(which is fine) but it actually removes it completely from all the
template.
Shouldn't it be something like (pseudocode):
if len(params) > 2 and template != EXT:
error "Disk modification supports additional arbitrary parameters
only for the EXT template"
?
> name = params.get(constants.IDISK_NAME, None)
> if name is not None and name.lower() == constants.VALUE_NONE:
> params[constants.IDISK_NAME] = None
> @@ -3182,8 +3178,7 @@ class LUInstanceSetParams(LogicalUnit):
> ("disk/%d" % idx, "add:size=%s,mode=%s" % (disk.size, disk.mode)),
> ])
>
> - @staticmethod
> - def _ModifyDisk(idx, disk, params, _):
> + def _ModifyDisk(self, idx, disk, params, _):
> """Modifies a disk.
>
> """
> @@ -3196,6 +3191,12 @@ class LUInstanceSetParams(LogicalUnit):
> disk.name = params.get(constants.IDISK_NAME)
> changes.append(("disk.name/%d" % idx, disk.name))
>
> + for key, value in params.iteritems():
> + if (key not in [constants.IDISK_MODE, constants.IDISK_NAME] and
> + self.instance.disk_template == constants.DT_EXT):
> + disk.params[key] = value
> + changes.append(("disk.params:%s/%d" % (key, idx), value))
> +
> return changes
>
> def _RemoveDisk(self, idx, root, _):
> --
> 1.7.10.4
>
Thanks,
Michele
--
Google Germany GmbH
Dienerstr. 12
80331 München
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores