On Fri, Sep 20, 2013 at 07:41:09PM +0200, Thomas Thrainer wrote:
> To make sure that the dynamic_params field is not serialized by accident
> to the configuration file only include it in the serialization when
> explicitly asked for.
> 
> Signed-off-by: Thomas Thrainer <[email protected]>
> ---
>  lib/objects.py | 5 ++++-
>  lib/rpc.py     | 2 +-
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/objects.py b/lib/objects.py
> index 30e9e8b..b8ca0b6 100644
> --- a/lib/objects.py
> +++ b/lib/objects.py
> @@ -743,7 +743,8 @@ class Disk(ConfigObject):
>  
>      self.dynamic_params = dyn_disk_params
>  
> -  def ToDict(self):
> +  # pylint: disable=W0221
> +  def ToDict(self, include_dynamic_params=False):
>      """Disk-specific conversion to standard python types.
>  
>      This replaces the children lists of objects with lists of
> @@ -751,6 +752,8 @@ class Disk(ConfigObject):
>  
>      """
>      bo = super(Disk, self).ToDict()
> +    if not include_dynamic_params and "dynamic_params" in bo:
> +      del bo["dynamic_params"]
>  
>      for attr in ("children",):
>        alist = bo.get(attr, None)
> diff --git a/lib/rpc.py b/lib/rpc.py
> index 0da3ab9..2167d06 100644
> --- a/lib/rpc.py
> +++ b/lib/rpc.py
> @@ -907,7 +907,7 @@ class RpcRunner(_RpcClientBase,
>  
>        disk.UpdateDynamicDiskParams(node, node_ips)
>  
> -      ret.append(disk.ToDict())
> +      ret.append(disk.ToDict(include_dynamic_params=True))
>  
>      return ret
>  
> -- 
> 1.8.4
> 

LGTM.

Thanks,
Jose

-- 
Jose Antonio Lopes
Ganeti Engineering
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
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370

Reply via email to