On Thu, Dec 8, 2011 at 9:37 AM, Iustin Pop <[email protected]> wrote:
> On Tue, Dec 06, 2011 at 06:52:19PM +0100, Agata Murawska wrote:
>> gnt-group modify can now change instance policy specs. Support for
>> 'default' value is provided and sanity checks are performed.
>>
>> Signed-off-by: Agata Murawska <[email protected]>
>> ---
>>  lib/client/gnt_group.py |   41 ++++++++++++++++++++++++++++++++++++++---
>>  lib/cmdlib.py           |   14 ++++++++++++++
>>  lib/opcodes.py          |    1 +
>>  3 files changed, 53 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
>> index 3770a00..0f80c2d 100644
>> --- a/lib/client/gnt_group.py
>> +++ b/lib/client/gnt_group.py
>> @@ -146,8 +146,10 @@ def SetGroupParams(opts, args):
>>    @return: the desired exit code
>>
>>    """
>> -  if (opts.ndparams is None and opts.alloc_policy is None
>> -      and not opts.diskparams):
>> +  if (opts.ndparams is None and opts.alloc_policy is None and
>> +     opts.mem_count_ispecs is None and opts.cpu_count_ispecs is None and
>> +     opts.disk_count_ispecs is None and opts.disk_size_ispecs is None and
>> +     opts.nic_count_ispecs is None and not opts.diskparams):
>
> Please change this to:
>        allmods = [opts.ndparams, opts.alloc_policy, …]
>        if allmods.count(None) == len(allmods):
>          ToStderr(…)
>
> Rest LGTM.
>
> thanks,
> iustin

Interdiff:

diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
index 3ac8533..e1e3925 100644
--- a/lib/client/gnt_group.py
+++ b/lib/client/gnt_group.py
@@ -146,11 +146,11 @@ def SetGroupParams(opts, args):
   @return: the desired exit code

   """
-  if (opts.ndparams is None and opts.alloc_policy is None
-      and not opts.diskparams and not opts.hv_state and not opts.disk_state and
-      opts.mem_count_ispecs is None and opts.cpu_count_ispecs is None and
-      opts.disk_count_ispecs is None and opts.disk_size_ispecs is None and
-      opts.nic_count_ispecs is None and not opts.diskparams):
+  allmods = [opts.ndparams, opts.alloc_policy, opts.diskparams, opts.hv_state,
+             opts.disk_state, opts.ispecs_mem_size, opts.ispecs_cpu_count,
+             opts.ispecs_disk_count, opts.ispecs_disk_size,
+             opts.ispecs_nic_count, opts.diskparams]
+  if allmods.count(None) == len(allmods):
     ToStderr("Please give at least one of the parameters.")
     return 1

@@ -165,11 +165,11 @@ def SetGroupParams(opts, args):

   # set the default values
   to_ipolicy = [
-    opts.mem_count_ispecs,
-    opts.cpu_count_ispecs,
-    opts.disk_count_ispecs,
-    opts.disk_size_ispecs,
-    opts.nic_count_ispecs,
+    opts.ispecs_mem_size,
+    opts.ispecs_cpu_count,
+    opts.ispecs_disk_count,
+    opts.ispecs_disk_size,
+    opts.ispecs_nic_count,
     ]
   for ispec in to_ipolicy:
     for param in ispec:
@@ -178,11 +178,11 @@ def SetGroupParams(opts, args):
           ispec[param] = constants.VALUE_DEFAULT
   # create ipolicy object
   ipolicy = objects.CreateIPolicyFromOpts(\
-    mem_count_ispecs=opts.mem_count_ispecs,
-    cpu_count_ispecs=opts.cpu_count_ispecs,
-    disk_count_ispecs=opts.disk_count_ispecs,
-    disk_size_ispecs=opts.disk_size_ispecs,
-    nic_count_ispecs=opts.nic_count_ispecs,
+    ispecs_mem_size=opts.ispecs_mem_size,
+    ispecs_cpu_count=opts.ispecs_cpu_count,
+    ispecs_disk_count=opts.ispecs_disk_count,
+    ispecs_disk_size=opts.ispecs_disk_size,
+    ispecs_nic_count=opts.ispecs_nic_count,
     group_ipolicy=True,
     allowed_values=[constants.VALUE_DEFAULT])
   for key in ipolicy.keys():
@@ -298,9 +298,7 @@ commands = {
   "modify": (
     SetGroupParams, ARGS_ONE_GROUP,
     [DRY_RUN_OPT, SUBMIT_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, HV_STATE_OPT,
-     DISK_STATE_OPT, DISK_PARAMS_OPT,
-     MEM_COUNT_SPECS_OPT, CPU_COUNT_SPECS_OPT, DISK_COUNT_SPECS_OPT,
-     DISK_SIZE_SPECS_OPT, NIC_COUNT_SPECS_OPT, DISK_PARAMS_OPT],
+     DISK_STATE_OPT, DISK_PARAMS_OPT] + INSTANCE_POLICY_OPTS,
     "<group_name>", "Alters the parameters of a node group"),
   "remove": (
     RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT],

Reply via email to