Nir Soffer has uploaded a new change for review. Change subject: tool: Create configurators once ......................................................................
tool: Create configurators once Commit e5e80540e8 replaced the configurators dict with a function, creating a configuration dict on each call. The code added in this commit invoke the function many times for each run on the tool, creating 10's of instances of the configurators. This change is not needed to acomplish the purpuse of that patch, and is rather pointless. This patch revent the unrelated change, keeping the configurations in a module constant. This change also simplify the tests. Change-Id: I6e0e258dc28557661bf85734f000e43f20b1e512 Signed-off-by: Nir Soffer <[email protected]> --- M lib/vdsm/tool/configurator.py M tests/toolTests.py 2 files changed, 22 insertions(+), 23 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/31739/1 diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py index 277f5d9..08395f8 100644 --- a/lib/vdsm/tool/configurator.py +++ b/lib/vdsm/tool/configurator.py @@ -33,13 +33,12 @@ sanlock -def _getConfigurers(): - return dict((m.getName(), m) for m in ( - certificates.Certificates(), - libvirt.Libvirt(), - sanlock.Sanlock(), - ) +_CONFIGURATORS = dict((m.getName(), m) for m in ( + certificates.Certificates(), + libvirt.Libvirt(), + sanlock.Sanlock() ) +) @expose("configure") @@ -177,7 +176,7 @@ while queue: next_ = queue.popleft() try: - requiredNames = _getConfigurers()[next_].getRequires() + requiredNames = _CONFIGURATORS[next_].getRequires() except KeyError: raise KeyError( "error: argument --module: " @@ -202,7 +201,7 @@ while modulesNames: for c in modulesNames: - requires = _getConfigurers()[c].getRequires() + requires = _CONFIGURATORS[c].getRequires() if requires.issubset(set(sortedModules)): modulesNames.remove(c) sortedModules.append(c) @@ -227,7 +226,7 @@ '(e.g %s).\n' 'If non is specified, operation will run for ' 'all related modules.' - % _getConfigurers().keys() + % _CONFIGURATORS.keys() ), ) if action == "configure": @@ -241,10 +240,10 @@ args = parser.parse_args(args) if not args.modules: - args.modules = _getConfigurers().keys() + args.modules = _CONFIGURATORS.keys() args.modules = _sort_modules(_add_dependencies(args.modules)) - args.modules = [_getConfigurers()[cName] for cName in args.modules] + args.modules = [_CONFIGURATORS[cName] for cName in args.modules] return args diff --git a/tests/toolTests.py b/tests/toolTests.py index bdd8a5d..28e118a 100644 --- a/tests/toolTests.py +++ b/tests/toolTests.py @@ -55,8 +55,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', set('b')), 'b': MockModuleConfigurator('b', set('a')) } @@ -70,8 +70,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', {'b', 'd'}), 'b': MockModuleConfigurator('b', {'c'}), 'c': MockModuleConfigurator('c', {'e', 'd'}), @@ -92,8 +92,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', set()), 'b': MockModuleConfigurator('b', set()), 'c': MockModuleConfigurator('c', set()) @@ -104,8 +104,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', {'b', 'c'}), 'b': MockModuleConfigurator('b', set()), 'c': MockModuleConfigurator('c', set()) @@ -123,8 +123,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', set()), 'b': MockModuleConfigurator('b', set()), 'c': MockModuleConfigurator('c', set()) @@ -143,8 +143,8 @@ @monkeypatch.MonkeyPatch( configurator, - '_getConfigurers', - lambda: { + '_CONFIGURATORS', + { 'a': MockModuleConfigurator('a', set()), } ) -- To view, visit http://gerrit.ovirt.org/31739 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6e0e258dc28557661bf85734f000e43f20b1e512 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
