Nir Soffer has uploaded a new change for review.
Change subject: tool: Remove duplicate names
......................................................................
tool: Remove duplicate names
The configurators modules were duplicating the module name in the class
name:
libvirt.Libvrit
This is not only ugly, but does not describe what this class is. Now all
the configurtors modules define a Configurator class instead:
libvirt.Configurator
This allows removal of repetitive code, such as when creating the
dictionary of configurators:
dict((m.Configurator.name, m.Configurator())
for m in (certificates, libvirt, sanlock))
This also has the nice property that it is now harder to import class
names into other modules, so people will import the modules instead.
Change-Id: I852019d5b5522a39c03dbf66a3f5383ccf584007
Signed-off-by: Nir Soffer <[email protected]>
---
M lib/vdsm/tool/configurator.py
M lib/vdsm/tool/configurators/certificates.py
M lib/vdsm/tool/configurators/libvirt.py
M lib/vdsm/tool/configurators/sanlock.py
M tests/toolTests.py
5 files changed, 16 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/31775/1
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index c200e4e..9466816 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -34,11 +34,8 @@
def _getConfigurers():
- return {
- certificates.Certificates.name: certificates.Certificates(),
- libvirt.Libvirt.name: libvirt.Libvirt(),
- sanlock.Sanlock.name: sanlock.Sanlock(),
- }
+ return dict((m.Configurator.name, m.Configurator())
+ for m in (certificates, libvirt, sanlock))
@expose("configure")
diff --git a/lib/vdsm/tool/configurators/certificates.py
b/lib/vdsm/tool/configurators/certificates.py
index 8690a4e..8edd7a7 100644
--- a/lib/vdsm/tool/configurators/certificates.py
+++ b/lib/vdsm/tool/configurators/certificates.py
@@ -39,7 +39,7 @@
KEY_FILE = os.path.join(PKI_DIR, 'keys/vdsmkey.pem')
-class Certificates(ModuleConfigure):
+class Configurator(ModuleConfigure):
"""
Responsible for rolling out self signed certificates if vdsm's
configuration is ssl_enabled and no certificates exist.
diff --git a/lib/vdsm/tool/configurators/libvirt.py
b/lib/vdsm/tool/configurators/libvirt.py
index 6cce75b..9ff25b9 100644
--- a/lib/vdsm/tool/configurators/libvirt.py
+++ b/lib/vdsm/tool/configurators/libvirt.py
@@ -49,7 +49,7 @@
from ovirt.node.utils.fs import Config as NodeCfg
-class Libvirt(ModuleConfigure):
+class Configurator(ModuleConfigure):
name = 'libvirt'
requires = frozenset(('certificates',))
@@ -106,7 +106,7 @@
return ret
def removeConf(self):
- for cfile, content in Libvirt.FILES.items():
+ for cfile, content in self.FILES.items():
content['removeConf'](self, content['path'])
def _getPersistedFiles(self):
diff --git a/lib/vdsm/tool/configurators/sanlock.py
b/lib/vdsm/tool/configurators/sanlock.py
index 10c7760..5df2a1c 100644
--- a/lib/vdsm/tool/configurators/sanlock.py
+++ b/lib/vdsm/tool/configurators/sanlock.py
@@ -32,7 +32,7 @@
from ... import constants
-class Sanlock(ModuleConfigure):
+class Configurator(ModuleConfigure):
SANLOCK_GROUPS = (constants.QEMU_PROCESS_GROUP, constants.VDSM_GROUP)
diff --git a/tests/toolTests.py b/tests/toolTests.py
index 2d4fb72..9ed26db 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -23,7 +23,7 @@
NOT_CONFIGURED,\
NOT_SURE
from vdsm.tool.configurators.configfile import ConfigFile, ParserWrapper
-from vdsm.tool.configurators.libvirt import Libvirt
+from vdsm.tool.configurators import libvirt
from vdsm.tool import UsageError
from vdsm.tool import upgrade
from vdsm import utils
@@ -184,7 +184,7 @@
)
for key, val in self.test_env.items():
- Libvirt.FILES[key]['path'] = val
+ libvirt.Configurator.FILES[key]['path'] = val
self._setConfig(
('QLCONF', 'libvirtd'),
@@ -198,12 +198,12 @@
lambda: 0
),
(
- Libvirt,
+ libvirt.Configurator,
'_getFile',
lambda _, x: self.test_env[x]
),
(
- Libvirt,
+ libvirt.Configurator,
'_sysvToUpstart',
lambda _: True
),
@@ -229,7 +229,7 @@
)
def testValidatePositive(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig(
('VDSM_CONF', 'vdsm_ssl'),
@@ -240,7 +240,7 @@
self.assertTrue(libvirtConfigure.validate())
def testValidateNegative(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig(
('VDSM_CONF', 'vdsm_no_ssl'),
@@ -251,7 +251,7 @@
self.assertFalse(libvirtConfigure.validate())
def testIsConfiguredPositive(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig(
('LCONF', 'lconf_ssl'),
@@ -265,7 +265,7 @@
)
def testIsConfiguredNegative(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig(
('LCONF', 'lconf_ssl'),
@@ -278,7 +278,7 @@
)
def testLibvirtConfigureToSSLTrue(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig((
'LCONF', 'empty'),
@@ -300,7 +300,7 @@
)
def testLibvirtConfigureToSSLFalse(self):
- libvirtConfigure = Libvirt()
+ libvirtConfigure = libvirt.Configurator()
self._setConfig(
('LCONF', 'empty'),
('VDSM_CONF', 'vdsm_no_ssl'),
--
To view, visit http://gerrit.ovirt.org/31775
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I852019d5b5522a39c03dbf66a3f5383ccf584007
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