LGTM, thanks
On Wed, Mar 5, 2014 at 12:42 PM, Hrvoje Ribicic <[email protected]> wrote: > From: Petr Pudlak <[email protected]> > > When reading the configuration file from RPC JSON, values without a > floating point are parsed as 'int', not as 'float', and later the > consistency check fails. > > This patch adds an automatic conversion from 'int' to 'float' during > checking so that the improper JSON parsing is fixed. > > Signed-off-by: Petr Pudlak <[email protected]> > Reviewed-by: Klaus Aehlig <[email protected]> > > Cherry-picked from 710a2863775b75905526ce60eb0ed82a9715fa9e to fix > downgrades to 2.11. > > Signed-off-by: Hrvoje Ribicic <[email protected]> > --- > lib/config.py | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/lib/config.py b/lib/config.py > index e7f2aaa..981130e 100644 > --- a/lib/config.py > +++ b/lib/config.py > @@ -659,8 +659,18 @@ class ConfigWriter(object): > # FIXME: assuming list type > if key in constants.IPOLICY_PARAMETERS: > exp_type = float > + # if the value is int, it can be converted into float > + convertible_types = [int] > else: > exp_type = list > + convertible_types = [] > + # Try to convert from allowed types, if necessary. > + if any(isinstance(value, ct) for ct in convertible_types): > + try: > + value = exp_type(value) > + ipolicy[key] = value > + except ValueError: > + pass > if not isinstance(value, exp_type): > result.append("%s has invalid instance policy: for %s," > " expecting %s, got %s" % > -- > 1.9.0.279.gdc9e3eb > > -- -- Helga Velroyen | Software Engineer | [email protected] | 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
