On Tue, Dec 06, 2011 at 06:52:16PM +0100, Agata Murawska wrote:
> gnt-cluster verify now provides information about instances not meeting
> group's instance policy.
> 
> Signed-off-by: Agata Murawska <[email protected]>
> ---
>  lib/cmdlib.py    |   46 ++++++++++++++++++++++++++++++++++++++++++++++
>  lib/constants.py |    4 ++++
>  2 files changed, 50 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/cmdlib.py b/lib/cmdlib.py
> index d686136..a5dd605 100644
> --- a/lib/cmdlib.py
> +++ b/lib/cmdlib.py
> @@ -951,6 +951,26 @@ def _CheckInstanceState(lu, instance, req_states, 
> msg=None):
>                                   (instance.name, msg), errors.ECODE_STATE)
>  
>  
> +def _CheckMinMaxSpecs(name, ipolicy, value):
> +  """Checks if value is in the desired range.
> +
> +  @param name: name of the parameter for which we perform the check
> +  @param ipolicy: dictionary containing min, max and std values
> +  @param value: actual value that we want to use
> +  @return: None or element not meeting the criteria
> +
> +
> +  """
> +  if value in [None, constants.VALUE_AUTO]:
> +    return None
> +  max_v = ipolicy[constants.MAX_ISPECS].get(name, value)
> +  min_v = ipolicy[constants.MIN_ISPECS].get(name, value)
> +  if value > max_v or min_v > value:
> +    return ("%s value %s is not in range [%s, %s]" %
> +            (name, value, min_v, max_v))
> +  return None
> +
> +
>  def _ExpandItemName(fn, name, kind):
>    """Expand an item name.
>  
> @@ -2050,6 +2070,30 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
>            msg = "cannot reach the master IP"
>          _ErrorIf(True, constants.CV_ENODENET, node, msg)
>  
> +  def _VerifyInstancePolicy(self, instance):
> +    """Verify instance specs against instance policy set on node group level.
> +
> +
> +    """
> +    mem_count = instance.beparams.get(constants.BE_MAXMEM, None)
> +    cpu_count = instance.beparams.get(constants.BE_VCPUS, None)

Interesting choice. This will allow you to not warn if the instances
have 'bad' specs due to inheritance from the cluster, but also means
there's no warning if the cluster defaults are wrong and thus all
instances are wrong (due to inheritance).

So LGTM on this, but we need to test the cluster defaults too.

thanks,
iustin

Reply via email to