On Thu, Dec 8, 2011 at 9:19 AM, Iustin Pop <[email protected]> wrote:
> On Tue, Dec 06, 2011 at 06:52:12PM +0100, Agata Murawska wrote:
>> Cluster initialization can now take instance policy specs as arguments.
>> Sanity checks are performed to ensure, that for every policy element we
>> have min <= std <= max.
>>
>> Signed-off-by: Agata Murawska <[email protected]>
>> ---
>>  lib/bootstrap.py          |   12 +++++++++++-
>>  lib/client/gnt_cluster.py |   12 ++++++++++++
>>  2 files changed, 23 insertions(+), 1 deletions(-)
>>
>> diff --git a/lib/bootstrap.py b/lib/bootstrap.py
>> index 62d59ce..ba729be 100644
>> --- a/lib/bootstrap.py
>> +++ b/lib/bootstrap.py
>> @@ -289,7 +289,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: 
>> disable=R0913
>>                  hvparams=None, diskparams=None, enabled_hypervisors=None,
>>                  modify_etc_hosts=True, modify_ssh_setup=True,
>>                  maintain_node_health=False, drbd_helper=None, uid_pool=None,
>> -                default_iallocator=None, primary_ip_version=None,
>> +                default_iallocator=None, primary_ip_version=None, 
>> ipolicy=None,
>>                  prealloc_wipe_disks=False, use_external_mip_script=False):
>>    """Initialise the cluster.
>>
>> @@ -413,7 +413,16 @@ def InitCluster(cluster_name, mac_prefix, # pylint: 
>> disable=R0913
>>    objects.UpgradeBeParams(beparams)
>>    utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
>>    utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
>> +  for key, val in ipolicy.iteritems():
>
> items() again please.
>
> Rest LGTM.

make lint gave me R0914:285:InitCluster: Too many local variables
(52/50), which I disabled

interdiff:
diff --git a/lib/bootstrap.py b/lib/bootstrap.py
index ba729be..f154694 100644
--- a/lib/bootstrap.py
+++ b/lib/bootstrap.py
@@ -282,7 +282,7 @@ def _InitFileStorage(file_storage_dir):
   return file_storage_dir


-def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913
+def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
                 master_netmask, master_netdev, file_storage_dir,
                 shared_file_storage_dir, candidate_pool_size,
secondary_ip=None,
                 vg_name=None, beparams=None, nicparams=None, ndparams=None,
@@ -413,7 +413,7 @@ def InitCluster(cluster_name, mac_prefix, #
pylint: disable=R0913
   objects.UpgradeBeParams(beparams)
   utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES)
   utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
-  for key, val in ipolicy.iteritems():
+  for key, val in ipolicy.items():
     if key not in constants.IPOLICY_PARAMETERS:
       raise errors.OpPrereqError("'%s' is not a valid key for instance policy"
                                  " description", key)

related to renaming in the previous patch, there were some necessary changes:

diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py
index 1b5e547..aad0e41 100644
--- a/lib/client/gnt_cluster.py
+++ b/lib/client/gnt_cluster.py
@@ -140,11 +140,11 @@ def InitCluster(opts, args):

   # prepare ipolicy dict
   ipolicy_raw = 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_count,
+    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)
   ipolicy = objects.FillDictOfDicts(constants.IPOLICY_DEFAULTS, ipolicy_raw)
   for value in ipolicy.values():
     utils.ForceDictType(value, constants.ISPECS_PARAMETER_TYPES)

Reply via email to