Change in vdsm[master]: replace configure_libvirt.py with python code.
nsoffer at redhat.com
nsoffer at redhat.com
Wed May 14 11:16:13 UTC 2014
Nir Soffer has posted comments on this change.
Change subject: replace configure_libvirt.py with python code.
......................................................................
Patch Set 7:
(1 comment)
http://gerrit.ovirt.org/#/c/27298/7/lib/vdsm/tool/configurator.py
File lib/vdsm/tool/configurator.py:
Line 95: for key, val in fragment['conditions'].items():
Line 96: if not context[key] == val:
Line 97: allTrue = False
Line 98: if allTrue:
Line 99: configuration.update(fragment['content'])
> fragment['conditions'] is a subset of context.
ok, than I would suggest to:
1. Rename allTrue to needsUpdate - because it seems that this is what it means.
2. When you check for inequality use != instead of not:
if context[key] != val:
needsUpdate = True
3. Even cleaner: factor out the check to separate function
def needsUpdate(a, b):
for key, val in b.iteritems():
if a[key] != val:
return True
return False
And then your loop becomes:
for fragment in content['fragments']:
if self.needsUpdate(fragment['conditions'], context):
configuration.update(fragment['content'])
4. And docstring telling what this method does cannot hurt - as you see it fooled me.
5. The method name is confusing - this is not about adding sections but about updating them, right?
Line 100: if configuration:
Line 101: with ConfigFile(
Line 102: content['path'],
Line 103: **LibvirtModuleConfigure.VDSM_CONF_SECTION
--
To view, visit http://gerrit.ovirt.org/27298
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I74bfe05bb4b5f5d09021f21b324f9b7d5d0fdaab
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer at redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alonbl at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: mooli tayer <mtayer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list