Change in vdsm[master]: replace configure_libvirt.py with python code.

mtayer at redhat.com mtayer at redhat.com
Wed May 14 11:01:08 UTC 2014


mooli tayer has posted comments on this change.

Change subject: replace configure_libvirt.py with python code.
......................................................................


Patch Set 7:

(5 comments)

http://gerrit.ovirt.org/#/c/27298/7/lib/vdsm/tool/configurator.py
File lib/vdsm/tool/configurator.py:

Line 83:     def removeSection(self, path):
Line 84:         if os.path.exists(path):
Line 85:             with ConfigFile(
Line 86:                     path,
Line 87:                     **LibvirtModuleConfigure.VDSM_CONF_SECTION
> Use self
Done
Line 88:             ) as conff:
Line 89:                 conff.removeConf()
Line 90: 
Line 91:     def addSection(self, content, context):


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'])
> It looks like you are trying to check if there is some key with diffrent va
fragment['conditions'] is a subset of context.
Line 100:         if configuration:
Line 101:             with ConfigFile(
Line 102:                     content['path'],
Line 103:                     **LibvirtModuleConfigure.VDSM_CONF_SECTION


Line 100:         if configuration:
Line 101:             with ConfigFile(
Line 102:                     content['path'],
Line 103:                     **LibvirtModuleConfigure.VDSM_CONF_SECTION
Line 104:             ) as conff:
> This apears 3 times (maybe more?) and is too long to be easy to read. You c
Done.
Line 105:                 for key, val in configuration.items():
Line 106:                     conff.addEntry(key, val)
Line 107: 
Line 108:     def prefixAndPrepend(self, content, context):


Line 117:                 conf.prependSection(src_conf.read())
Line 118: 
Line 119:     def removeFile(self, content, context):
Line 120:         if os.path.exists(content['path']):
Line 121:             os.remove(content['path'])
> This is racy. It is better to use this pattern:
Done!
Line 122: 
Line 123:     FILES = {
Line 124: 
Line 125:         # Vdsm configuration


Line 400:     def getPersistedFiles(self):
Line 401:         return [
Line 402:             cfile['path'] for cfile in self.FILES.values()
Line 403:             if cfile['configure'].__name__ == 'prefixAndPrepend' or
Line 404:             cfile['configure'].__name__ == 'addSection'
> I would have added boolean property instead of this complex condition.
OK.
Line 405:         ]
Line 406: 
Line 407:     def _sysvToUpstart(self):
Line 408:         """


-- 
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