On Thu, Dec 8, 2011 at 9:27 AM, Iustin Pop <[email protected]> wrote:
> 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).
It's not exactly a choice. As in, we may consider it a feature, but it
was not an intended one ;)

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

Filled cluster defaults for beparams, interdiff:

diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 7eb0dc7..80c66e8 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2075,14 +2075,18 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):


     """
-    mem_count = instance.beparams.get(constants.BE_MAXMEM, None)
-    cpu_count = instance.beparams.get(constants.BE_VCPUS, None)
+    cluster = self.cfg.GetClusterInfo()
+    full_beparams = cluster.FillBE(instance)
+    ipolicy = cluster.SimpleFillIPolicy(self.group_info.ipolicy)
+
+    mem_size = full_beparams.get(constants.BE_MAXMEM, None)
+    cpu_count = full_beparams.get(constants.BE_VCPUS, None)
     disk_count = len(instance.disks)
     disk_sizes = [disk.size for disk in instance.disks]
     nic_count = len(instance.nics)
-    ipolicy = _CalculateGroupIPolicy(self.cfg, self.group_info)
+
     test_settings = [
-      (constants.MEM_COUNT_SPEC, mem_count),
+      (constants.MEM_SIZE_SPEC, mem_size),
       (constants.CPU_COUNT_SPEC, cpu_count),
       (constants.DISK_COUNT_SPEC, disk_count),
       (constants.NIC_COUNT_SPEC, nic_count),

Reply via email to