Irit Goihman has uploaded a new change for review. Change subject: vdsm: removed unnecessary calls to vdsm config.read ......................................................................
vdsm: removed unnecessary calls to vdsm config.read libvirt and vdscli modules had calls to config.read with vdsm default path as a parameter. This is unnecessary because when the module is imported the config is already read from the same path. Also removed VDSM_CONF from libvirt FILES dictionary since it's not needed anymore and fixed toolTests.py to match those changes. Change-Id: I965d5adf0c2d5857109cfeca936c9a3139c111cb Signed-off-by: Irit Goihman <igoih...@redhat.com> --- M lib/vdsm/tool/configurators/libvirt.py M lib/vdsm/vdscli.py M tests/toolTests.py 3 files changed, 22 insertions(+), 28 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/59513/1 diff --git a/lib/vdsm/tool/configurators/libvirt.py b/lib/vdsm/tool/configurators/libvirt.py index 97a74dd..5f07d05 100644 --- a/lib/vdsm/tool/configurators/libvirt.py +++ b/lib/vdsm/tool/configurators/libvirt.py @@ -1,4 +1,4 @@ -# Copyright 2014 Red Hat, Inc. +# Copyright 2014-2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -54,7 +54,6 @@ # Remove a previous configuration (if present) removeConf() - config.read(_getFile('VDSM_CONF')) vdsmConfiguration = { 'ssl_enabled': config.getboolean('vars', 'ssl'), 'sanlock_enabled': constants.SANLOCK_ENABLED, @@ -109,7 +108,6 @@ return True if libvirt configuration files match ssl configuration of vdsm.conf. """ - config.read(_getFile('VDSM_CONF')) ssl = config.getboolean('vars', 'ssl') lconf_p = ParserWrapper({ @@ -225,17 +223,7 @@ # be sure to update CONF_VERSION accordingly when updating FILES. FILES = { - 'VDSM_CONF': { - 'path': os.path.join( - constants.SYSCONF_PATH, - 'vdsm/vdsm.conf' - ), - 'configure': lambda x, y: True, - 'removeConf': lambda x: True, - 'persisted': False, - }, - - 'LCONF': { + 'LCONF': { 'path': os.path.join( constants.SYSCONF_PATH, 'libvirt/libvirtd.conf' diff --git a/lib/vdsm/vdscli.py b/lib/vdsm/vdscli.py index 7eb60b2..5bc91c9 100644 --- a/lib/vdsm/vdscli.py +++ b/lib/vdsm/vdscli.py @@ -1,6 +1,6 @@ # vdscli: contact vdsm running on localhost over xmlrpc easily # -# Copyright 2009-2014 Red Hat, Inc. +# Copyright 2009-2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -75,10 +75,8 @@ def __guessDefaults(): global _USE_SSL, _TRUSTED_STORE_PATH, ADDRESS, PORT - VDSM_CONF = '/etc/vdsm/vdsm.conf' try: from .config import config - config.read(VDSM_CONF) _USE_SSL = config.getboolean('vars', 'ssl') _TRUSTED_STORE_PATH = config.get('vars', 'trust_store_path') PORT = config.getint('addresses', 'management_port') diff --git a/tests/toolTests.py b/tests/toolTests.py index e964f7e..8e29722 100644 --- a/tests/toolTests.py +++ b/tests/toolTests.py @@ -1,5 +1,5 @@ # -# Copyright 2014 Red Hat, Inc. +# Copyright 2014-2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ from vdsm.tool import upgrade from vdsm import utils import monkeypatch -from testlib import VdsmTestCase, expandPermutations +from testlib import expandPermutations, make_config , VdsmTestCase from testValidation import ValidateRunningAsRoot from unittest import TestCase import tempfile @@ -35,6 +35,7 @@ dirName = os.path.dirname(os.path.realpath(__file__)) +FakeFiles = libvirt.FILES class MockModuleConfigurator(object): @@ -307,12 +308,14 @@ self.test_env['QNETWORK'] = 'NON_EXISTENT' for key, val in self.test_env.items(): - libvirt.FILES[key]['path'] = val + if not key == 'VDSM_CONF': + FakeFiles[key]['path'] = val self._setConfig( ('QLCONF', 'libvirtd'), ('LDCONF', 'qemu_sanlock'), ) + self.vdsm_cfg = make_config(()) self.patch = monkeypatch.Patch([ ( @@ -322,8 +325,13 @@ ), ( libvirt, - '_getFile', - lambda x: self.test_env[x] + 'config', + self.vdsm_cfg + ), + ( + libvirt, + 'FILES', + FakeFiles ), ( utils, @@ -350,8 +358,8 @@ testConf.write(data) def testValidatePositive(self): + self.vdsm_cfg.set('vars', 'ssl', 'true') self._setConfig( - ('VDSM_CONF', 'vdsm_ssl'), ('LCONF', 'lconf_ssl'), ('QCONF', 'qemu_ssl'), ) @@ -359,8 +367,8 @@ self.assertTrue(libvirt.validate()) def testValidateNegative(self): + self.vdsm_cfg.set('vars', 'ssl', 'false') self._setConfig( - ('VDSM_CONF', 'vdsm_no_ssl'), ('LCONF', 'lconf_ssl'), ('QCONF', 'qemu_ssl'), ) @@ -389,9 +397,9 @@ ) def testLibvirtConfigureToSSLTrue(self): - self._setConfig(( - 'LCONF', 'empty'), - ('VDSM_CONF', 'vdsm_ssl'), + self.vdsm_cfg.set('vars', 'ssl', 'true') + self._setConfig( + ('LCONF', 'empty'), ('QCONF', 'empty'), ) @@ -408,9 +416,9 @@ ) def testLibvirtConfigureToSSLFalse(self): + self.vdsm_cfg.set('vars', 'ssl', 'false') self._setConfig( ('LCONF', 'empty'), - ('VDSM_CONF', 'vdsm_no_ssl'), ('QCONF', 'empty'), ) self.assertEquals( -- To view, visit https://gerrit.ovirt.org/59513 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I965d5adf0c2d5857109cfeca936c9a3139c111cb Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Irit Goihman <igoih...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org