Instance parameters: force typing
authorGuido Trotter <ultrotter@google.com>
Tue, 10 Feb 2009 15:06:24 +0000 (15:06 +0000)
committerGuido Trotter <ultrotter@google.com>
Tue, 10 Feb 2009 15:06:24 +0000 (15:06 +0000)
commita5728081faa3068dcb797a7ccccd9ce47c0b23e0
treecdc1104a6a4629b691b99072706d6fda840a9946
parentc9d443ea4ab1a6c031306afe95f5e9e92d61d693
Instance parameters: force typing

We want all the hv/be parameters to have a known type, rather than a
random mix of empty string, boolean values, and None, so we declare the
type of each variable and we enforce/convert it.

- Add some new constants for enforceable value types
- Add new constants dicts HVS_PARAMETER_TYPES and BES_PARAMETER_TYPES
  holding not only the valid parameters but also their types
- Drop the old HVS_PARAMETERS and BES_PARAMETERS constants and calculate
  the values from the type dict
- Convert all the default parameters to a valid type value
- Create a new ForceDictType utils function, to check/enforce a dict's
  element value types, with relevant unit tests
- Drop a few custom functions to check/convert the BE param types in
  utils and cli, in favor of ForceDictType
- Double-check the parameter types using ForceDictType in both scripts
  and LogicalUnits, when possible.

As a bonus:
- Remove some old commented-out code in gnt-instance
- Remove some already fixed FIXME
- Fix a bug which prevented VALUE_DEFAULT to be applied to BE parameters
  in SetInstanceParams because the value was checked for validity before
  that transformation was made
- Fix a bug which prevented initing a cluster and passing hvparams to
  work at all
- ForceDictType allows an allowed_values for exceptions, which makes us
  able to do the checking even when some values must not be
  converted/typechecked (for example the 'default' string in
  SetInstanceParameters)

Reviewed-by: iustinp
lib/bootstrap.py
lib/cli.py
lib/cmdlib.py
lib/constants.py
lib/errors.py
lib/utils.py
scripts/gnt-backup
scripts/gnt-cluster
scripts/gnt-instance
test/ganeti.utils_unittest.py