Change in vdsm[master]: sslutils: add info to SSLHandshake errors
by Code Review
From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has uploaded a new change for review.
Change subject: sslutils: add info to SSLHandshake errors
......................................................................
sslutils: add info to SSLHandshake errors
Include name of peer and its full certificate if they do not match,
in order to understand which non-legitimate client attempts to connect.
Change-Id: I0cb2d7e0c6c86ca12a34be13b07bc960e3ad313e
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/sslutils.py
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/76221/1
diff --git a/lib/vdsm/sslutils.py b/lib/vdsm/sslutils.py
index 10fc172..8c349ca 100644
--- a/lib/vdsm/sslutils.py
+++ b/lib/vdsm/sslutils.py
@@ -219,9 +219,12 @@
if self._is_handshaking:
self._handshake(dispatcher)
else:
- if not self._verify_host(dispatcher.socket.getpeercert(),
- dispatcher.socket.getpeername()[0]):
- self.log.error("peer certificate does not match host name")
+ peercert = dispatcher.socket.getpeercert()
+ peername = dispatcher.socket.getpeername()[0]
+ if not self._verify_host(peercert, peername):
+ self.log.error(
+ "peer certificate '%s' does not match host name '%s'",
+ peercert, peername)
dispatcher.socket.close()
return
--
To view, visit https://gerrit.ovirt.org/76221
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0cb2d7e0c6c86ca12a34be13b07bc960e3ad313e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
6 years, 9 months
Change in vdsm[master]: storage: move storageServer to lib/vdsm
by Code Review
From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has uploaded a new change for review.
Change subject: storage: move storageServer to lib/vdsm
......................................................................
storage: move storageServer to lib/vdsm
Change-Id: I0fba9e9da91354a2e28fdf0ce754836ae61c7094
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/storage/Makefile.am
R lib/vdsm/storage/storageServer.py
M tests/storage_storageserver_test.py
M vdsm.spec.in
M vdsm/storage/Makefile.am
M vdsm/storage/hsm.py
6 files changed, 10 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/73116/1
diff --git a/lib/vdsm/storage/Makefile.am b/lib/vdsm/storage/Makefile.am
index 47bb7fb..096d903 100644
--- a/lib/vdsm/storage/Makefile.am
+++ b/lib/vdsm/storage/Makefile.am
@@ -52,6 +52,7 @@
resourceManager.py \
rwlock.py \
securable.py \
+ storageServer.py \
task.py \
taskManager.py \
threadPool.py \
diff --git a/vdsm/storage/storageServer.py b/lib/vdsm/storage/storageServer.py
similarity index 99%
rename from vdsm/storage/storageServer.py
rename to lib/vdsm/storage/storageServer.py
index 28c93d1..e6e80d4 100644
--- a/vdsm/storage/storageServer.py
+++ b/lib/vdsm/storage/storageServer.py
@@ -17,6 +17,7 @@
#
# Refer to the README and COPYING files for full details of the license
#
+from __future__ import absolute_import
import errno
import logging
diff --git a/tests/storage_storageserver_test.py b/tests/storage_storageserver_test.py
index ce0a8e7..40fba98 100644
--- a/tests/storage_storageserver_test.py
+++ b/tests/storage_storageserver_test.py
@@ -21,13 +21,13 @@
from monkeypatch import MonkeyPatch
from testlib import permutations, expandPermutations
from testlib import VdsmTestCase
-from storage.storageServer import GlusterFSConnection
-from storage.storageServer import IscsiConnection
-from storage.storageServer import MountConnection
-from storage import storageServer
from vdsm.gluster import cli as gluster_cli
from vdsm.gluster import exception as ge
+from vdsm.storage.storageServer import GlusterFSConnection
+from vdsm.storage.storageServer import IscsiConnection
+from vdsm.storage.storageServer import MountConnection
+from vdsm.storage import storageServer
class FakeSupervdsm(object):
diff --git a/vdsm.spec.in b/vdsm.spec.in
index b832882..7109533 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -941,7 +941,6 @@
%{_datadir}/%{vdsm_name}/storage/sd.py*
%{_datadir}/%{vdsm_name}/storage/sp.py*
%{_datadir}/%{vdsm_name}/storage/spbackends.py*
-%{_datadir}/%{vdsm_name}/storage/storageServer.py*
%{_datadir}/%{vdsm_name}/storage/volume.py*
%{_datadir}/%{vdsm_name}/storage/imageRepository/__init__.py*
%{_datadir}/%{vdsm_name}/storage/imageRepository/formatConverter.py*
@@ -1208,6 +1207,7 @@
%{python_sitelib}/%{vdsm_name}/storage/resourceManager.py*
%{python_sitelib}/%{vdsm_name}/storage/rwlock.py*
%{python_sitelib}/%{vdsm_name}/storage/securable.py*
+%{python_sitelib}/%{vdsm_name}/storage/storageServer.py*
%{python_sitelib}/%{vdsm_name}/storage/task.py*
%{python_sitelib}/%{vdsm_name}/storage/taskManager.py*
%{python_sitelib}/%{vdsm_name}/storage/threadPool.py*
diff --git a/vdsm/storage/Makefile.am b/vdsm/storage/Makefile.am
index 29a45a4..29450dc 100644
--- a/vdsm/storage/Makefile.am
+++ b/vdsm/storage/Makefile.am
@@ -42,8 +42,8 @@
sd.py \
sp.py \
spbackends.py \
- storageServer.py \
- volume.py
+ volume.py \
+ $(NULL)
dist_vdsmexec_SCRIPTS = \
curl-img-wrap \
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 216dfd3..ccce68e 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -58,6 +58,7 @@
from vdsm.storage import multipath
from vdsm.storage import outOfProcess as oop
from vdsm.storage import resourceManager as rm
+from vdsm.storage import storageServer
from vdsm.storage import taskManager
from vdsm.storage import types
from vdsm.storage.constants import STORAGE
@@ -78,7 +79,6 @@
from sdc import sdCache
import image
import merge
-import storageServer
import sdm.api.create_volume
--
To view, visit https://gerrit.ovirt.org/73116
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fba9e9da91354a2e28fdf0ce754836ae61c7094
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
6 years, 10 months
Change in vdsm[master]: storage: validateDirAccess: move to fileUtils
by Code Review
From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has uploaded a new change for review.
Change subject: storage: validateDirAccess: move to fileUtils
......................................................................
storage: validateDirAccess: move to fileUtils
validateDirAccess is the only thing keeping storageServer out of
lib/vdsm.
fileUtils is not a perfect location for it, but I did not find a better
place.
Change-Id: I21ead1cb635f8224cb09f7319ffcb55eebe2a9e3
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/storage/fileUtils.py
M vdsm/storage/fileSD.py
M vdsm/storage/localFsSD.py
M vdsm/storage/nfsSD.py
M vdsm/storage/storageServer.py
5 files changed, 27 insertions(+), 28 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/73115/1
diff --git a/lib/vdsm/storage/fileUtils.py b/lib/vdsm/storage/fileUtils.py
index 2e84d5f..71c7bef 100644
--- a/lib/vdsm/storage/fileUtils.py
+++ b/lib/vdsm/storage/fileUtils.py
@@ -37,7 +37,11 @@
import six
from vdsm import constants
+from vdsm import supervdsm
from vdsm.common.network import address
+
+from . import exception as se
+from . import outOfProcess
log = logging.getLogger('storage.fileUtils')
@@ -139,6 +143,25 @@
raise OSError(errno.EACCES, os.strerror(errno.EACCES))
+def validateDirAccess(dirPath):
+ try:
+ outOfProcess.getGlobalProcPool().fileUtils.validateAccess(dirPath)
+ supervdsm.getProxy().validateAccess(
+ constants.VDSM_USER,
+ (constants.VDSM_GROUP,), dirPath,
+ (os.R_OK | os.W_OK | os.X_OK))
+ supervdsm.getProxy().validateAccess(
+ constants.QEMU_PROCESS_USER,
+ (constants.DISKIMAGE_GROUP, constants.METADATA_GROUP), dirPath,
+ (os.R_OK | os.X_OK))
+ except OSError as e:
+ if e.errno == errno.EACCES:
+ raise se.StorageServerAccessPermissionError(dirPath)
+ raise
+
+ return True
+
+
def validateQemuReadable(targetPath):
"""
Validate that qemu process can read file
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index ab9ae21..9d76c3c 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -41,7 +41,6 @@
from vdsm import constants
from vdsm.utils import stripNewLines
from vdsm.storage.constants import LEASE_FILEEXT
-from vdsm import supervdsm
REMOTE_PATH = "REMOTE_PATH"
@@ -64,27 +63,6 @@
ST_BYTES_PER_BLOCK = 512
_MOUNTLIST_IGNORE = ('/' + sd.BLOCKSD_DIR, '/' + sd.GLUSTERSD_DIR)
-
-getProcPool = oop.getGlobalProcPool
-
-
-def validateDirAccess(dirPath):
- try:
- getProcPool().fileUtils.validateAccess(dirPath)
- supervdsm.getProxy().validateAccess(
- constants.VDSM_USER,
- (constants.VDSM_GROUP,), dirPath,
- (os.R_OK | os.W_OK | os.X_OK))
- supervdsm.getProxy().validateAccess(
- constants.QEMU_PROCESS_USER,
- (constants.DISKIMAGE_GROUP, constants.METADATA_GROUP), dirPath,
- (os.R_OK | os.X_OK))
- except OSError as e:
- if e.errno == errno.EACCES:
- raise se.StorageServerAccessPermissionError(dirPath)
- raise
-
- return True
def validateFileSystemFeatures(sdUUID, mountDir):
diff --git a/vdsm/storage/localFsSD.py b/vdsm/storage/localFsSD.py
index 94db70d..a724a3d 100644
--- a/vdsm/storage/localFsSD.py
+++ b/vdsm/storage/localFsSD.py
@@ -59,7 +59,7 @@
if os.path.abspath(typeSpecificArg) != typeSpecificArg:
raise se.StorageDomainIllegalRemotePath(typeSpecificArg)
- fileSD.validateDirAccess(domPath)
+ fileUtils.validateDirAccess(domPath)
fileSD.validateFileSystemFeatures(sdUUID, domPath)
sd.validateDomainVersion(version)
diff --git a/vdsm/storage/nfsSD.py b/vdsm/storage/nfsSD.py
index 8c41952..fc020de 100644
--- a/vdsm/storage/nfsSD.py
+++ b/vdsm/storage/nfsSD.py
@@ -46,7 +46,7 @@
if not mount.isMounted(domPath):
raise se.StorageDomainFSNotMounted(domPath)
- fileSD.validateDirAccess(domPath)
+ fileUtils.validateDirAccess(domPath)
fileSD.validateFileSystemFeatures(sdUUID, domPath)
# Make sure there are no remnants of other domain
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index dc3fd80..28c93d1 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -40,8 +40,6 @@
from vdsm.storage import mount
from vdsm.storage.mount import MountError
-import fileSD
-
IscsiConnectionParameters = namedtuple("IscsiConnectionParameters",
"target, iface, credentials")
@@ -163,7 +161,7 @@
six.reraise(t, v, tb)
else:
try:
- fileSD.validateDirAccess(
+ fileUtils.validateDirAccess(
self.getMountObj().getRecord().fs_file)
except se.StorageServerAccessPermissionError:
t, v, tb = sys.exc_info()
@@ -566,7 +564,7 @@
def checkTarget(self):
if not os.path.isdir(self._path):
raise se.StorageServerLocalNotDirError(self._path)
- fileSD.validateDirAccess(self._path)
+ fileUtils.validateDirAccess(self._path)
return True
def checkLink(self):
--
To view, visit https://gerrit.ovirt.org/73115
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I21ead1cb635f8224cb09f7319ffcb55eebe2a9e3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
6 years, 10 months
Change in vdsm[master]: check-merged: adding virtTests
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: check-merged: adding virtTests
......................................................................
check-merged: adding virtTests
Change-Id: Ibdd67ff59beb20a13c187087e9cfa148ba705eb6
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M automation/check-merged.sh
1 file changed, 19 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/70837/1
diff --git a/automation/check-merged.sh b/automation/check-merged.sh
index e6933b9..c913610 100755
--- a/automation/check-merged.sh
+++ b/automation/check-merged.sh
@@ -65,6 +65,20 @@
return $res
}
+function run_virt_tests {
+ local res=0
+ lago shell "$VM_NAME" -c \
+ " \
+ cd /usr/share/vdsm/tests
+ ./run_tests.sh \
+ --with-xunit \
+ --xunit-file=/tmp/nosetests-${DISTRO}.xml \
+ -s \
+ functional/virtTests.py \
+ " || res=$?
+ return $res
+}
+
function run_network_tests {
local res=0
lago shell "$VM_NAME" -c \
@@ -113,9 +127,13 @@
function run_all_tests {
run_infra_tests | tee "$EXPORTS/functional_tests_stdout.$DISTRO.log"
- failed="${PIPESTATUS[0]}"
+ local failed="${PIPESTATUS[0]}"
run_network_tests | tee -a "$EXPORTS/functional_tests_stdout.$DISTRO.log"
+ local res="${PIPESTATUS[0]}"
+ [ "$res" -ne 0 ] && failed="$res"
+
+ run_virt_tests | tee -a "$EXPORTS/functional_tests_stdout.$DISTRO.log"
res="${PIPESTATUS[0]}"
[ "$res" -ne 0 ] && failed="$res"
}
--
To view, visit https://gerrit.ovirt.org/70837
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdd67ff59beb20a13c187087e9cfa148ba705eb6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[master]: ci: align with new ci junit suffix for nose xml output
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: ci: align with new ci junit suffix for nose xml output
......................................................................
ci: align with new ci junit suffix for nose xml output
Change-Id: I76b1df84eaaa053cc6c3acfafc630454edacedf2
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M automation/check-merged.sh
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/75221/1
diff --git a/automation/check-merged.sh b/automation/check-merged.sh
index 742681d..98045f3 100755
--- a/automation/check-merged.sh
+++ b/automation/check-merged.sh
@@ -139,7 +139,7 @@
mkdir "$EXPORTS"/lago-logs
lago copy-from-vm "$VM_NAME" \
"/tmp/nosetests-${DISTRO}.xml" \
- "$EXPORTS/nosetests-${DISTRO}.xml" || :
+ "$EXPORTS/nosetests-${DISTRO}.junit.xml" || :
lago collect --output "$EXPORTS"/lago-logs
cp "$PREFIX"/current/logs/*.log "$EXPORTS"/lago-logs
}
--
To view, visit https://gerrit.ovirt.org/75221
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I76b1df84eaaa053cc6c3acfafc630454edacedf2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[ovirt-4.1]: Adding "abrt-cli list" output to sos plugin
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding "abrt-cli list" output to sos plugin
......................................................................
Adding "abrt-cli list" output to sos plugin
Change-Id: Id0c45c11a441c23551633f3bcb779d476f8da9e5
Bug-Url: https://bugzilla.redhat.com/917062
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M vdsm/sos/vdsm.py.in
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/75661/1
diff --git a/vdsm/sos/vdsm.py.in b/vdsm/sos/vdsm.py.in
index 9875b51..73784d6 100644
--- a/vdsm/sos/vdsm.py.in
+++ b/vdsm/sos/vdsm.py.in
@@ -130,6 +130,7 @@
self.collectExtOutput("/sbin/iscsiadm -m node")
self.collectExtOutput("/sbin/iscsiadm -m session")
self.collectExtOutput("/usr/sbin/nodectl info")
+ self.collectExtOutput("/usr/bin/abrt-cli list")
try:
cli = client.connect('localhost')
--
To view, visit https://gerrit.ovirt.org/75661
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0c45c11a441c23551633f3bcb779d476f8da9e5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.1
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[ovirt-4.1]: Adding abrt dependency and introduce configurator for it
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding abrt dependency and introduce configurator for it
......................................................................
Adding abrt dependency and introduce configurator for it
- Adding spec requirement for abrt addons to replace current coredump
kernel reports (see RFE for more info)
- Adding abrt conf files
- Removing logrotate config for coredump folder - assuming that abrt
takes care for not flooding in reports (need to be verified)
- Adding tests
Change-Id: I1ca5e66c9f029be75483b86414e328d074c7e454
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=917062
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M init/systemd/85-vdsmd.preset
M init/vdsmd_init_common.sh.in
M lib/vdsm/tool/configurators/Makefile.am
A lib/vdsm/tool/configurators/abrt.py
M static/usr/lib/systemd/system/vdsmd.service.in
M tests/Makefile.am
M tests/toolTests.py
A tests/toolTests_CCPP.conf
A tests/toolTests_abrt-action-save-package-data.conf
A tests/toolTests_abrt.conf
A tests/toolTests_vmcore.conf
M vdsm.spec.in
M vdsm/vdsm-logrotate
13 files changed, 268 insertions(+), 64 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/60/75660/1
diff --git a/init/systemd/85-vdsmd.preset b/init/systemd/85-vdsmd.preset
index 6da4332c..482d0ea 100644
--- a/init/systemd/85-vdsmd.preset
+++ b/init/systemd/85-vdsmd.preset
@@ -6,6 +6,8 @@
enable vdsm-network.service
enable vdsm-network-init.service
enable mom-vdsm.service
+enable abrt-vmcore
+enable kdump
disable ksmtuned.service
diff --git a/init/vdsmd_init_common.sh.in b/init/vdsmd_init_common.sh.in
index c935cb9..f00666b 100755
--- a/init/vdsmd_init_common.sh.in
+++ b/init/vdsmd_init_common.sh.in
@@ -1,5 +1,6 @@
#!/bin/sh
# Copyright 2013 IBM, Inc.
+# Copyright 2017 Redhat, 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
@@ -35,13 +36,7 @@
}
task_configure_coredump() {
- local conf_file="@CONFDIR(a)/vdsm.conf"
- local getconfitem="@VDSMDIR@/get-conf-item"
-
- if "${getconfitem}" "${conf_file}" vars core_dump_enable false |
- tr A-Z a-z | grep -q true; then
- echo "/var/log/core/core.%p.%t.dump" > /proc/sys/kernel/core_pattern
- fi
+ echo "|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t %e %i" > /proc/sys/kernel/core_pattern
}
task_configure_vdsm_logs() {
diff --git a/lib/vdsm/tool/configurators/Makefile.am b/lib/vdsm/tool/configurators/Makefile.am
index ad23bac..0d2be52 100644
--- a/lib/vdsm/tool/configurators/Makefile.am
+++ b/lib/vdsm/tool/configurators/Makefile.am
@@ -1,5 +1,5 @@
#
-# Copyright 2014 Red Hat, Inc.
+# Copyright 2014-2017 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
@@ -21,6 +21,7 @@
dist_configurators_PYTHON = \
__init__.py \
+ abrt.py \
certificates.py \
libvirt.py \
multipath.py \
diff --git a/lib/vdsm/tool/configurators/abrt.py b/lib/vdsm/tool/configurators/abrt.py
new file mode 100644
index 0000000..f843b16
--- /dev/null
+++ b/lib/vdsm/tool/configurators/abrt.py
@@ -0,0 +1,128 @@
+# Copyright 2017 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from __future__ import absolute_import
+import sys
+import os
+
+from . import MAYBE, NO
+from vdsm.tool import confutils
+from vdsm import constants
+
+CONF_VERSION = '4.20.0'
+
+
+def configure():
+ confutils.remove_conf(FILES, CONF_VERSION)
+ for conf_file, content in FILES.items():
+ content['configure'](content, CONF_VERSION)
+
+
+def isconfigured():
+ """
+ Check if abrt is already configured for vdsm
+ """
+ ret = MAYBE
+
+ for path in (confutils.get_persisted_files(FILES)):
+ if not confutils.open_config(path, CONF_VERSION).hasConf():
+ ret = NO
+
+ if ret == MAYBE:
+ sys.stdout.write("abrt is already configured for vdsm\n")
+ else:
+ sys.stdout.write("abrt is not configured for vdsm\n")
+ return ret
+
+
+FILES = {
+ 'ABRT_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/abrt.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'DumpLocation': '/var/tmp/abrt',
+ 'AutoreportingEvent': 'report_uReport',
+ 'MaxCrashReportsSize': '1000',
+ 'AutoreportingEnabled': 'yes'
+ },
+ },
+ ]
+ },
+ 'CCPP_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/plugins/CCpp.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'MakeCompatCore': 'no',
+ 'SaveBinaryImage': 'no',
+ 'CreateCoreBacktrace': 'yes',
+ 'SaveFullCore': 'no',
+ },
+ },
+ ]
+ },
+ 'VMCORE_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/plugins/vmcore.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'CopyVMcore': 'no',
+ },
+ },
+ ]
+ },
+ 'PKG_CONF': {
+ 'path': os.path.join(
+ constants.SYSCONF_PATH,
+ 'abrt/abrt-action-save-package-data.conf'
+ ),
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
+ 'persisted': True,
+ 'fragments': [
+ {
+ 'conditions': {},
+ 'content': {
+ 'OpenGPGCheck': 'no'
+ },
+ },
+ ]
+ }
+}
diff --git a/static/usr/lib/systemd/system/vdsmd.service.in b/static/usr/lib/systemd/system/vdsmd.service.in
index 659f8ce..828d9ce 100644
--- a/static/usr/lib/systemd/system/vdsmd.service.in
+++ b/static/usr/lib/systemd/system/vdsmd.service.in
@@ -6,7 +6,7 @@
After=multipathd.service libvirtd.service iscsid.service rpcbind.service \
supervdsmd.service sanlock.service vdsm-network.service
Conflicts=libvirt-guests.service
-Wants=mom-vdsm.service ovirt-imageio-daemon.service
+Wants=mom-vdsm.service ovirt-imageio-daemon.service abrtd.service
[Service]
Type=simple
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1970b7b..00c31c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -329,6 +329,9 @@
lvs_3386c6f2-926f-42c4-839c-38287fac8998.out \
lvs_f9e55e18-67c4-4377-8e39-5833ca422bef.out \
mem_info.out \
+ toolTests_abrt-action-save-package-data.conf \
+ toolTests_abrt.conf \
+ toolTests_CCPP.conf \
toolTests_empty.conf \
toolTests_lconf_ssl.conf \
toolTests_libvirtd.conf \
@@ -336,6 +339,7 @@
toolTests_qemu_ssl.conf \
toolTests_vdsm_no_ssl.conf \
toolTests_vdsm_ssl.conf \
+ toolTests_vmcore.conf \
$(NULL)
dist_vdsmtests_PYTHON = \
diff --git a/tests/toolTests.py b/tests/toolTests.py
index 0f065db..ff722f1 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -20,6 +20,7 @@
from vdsm.tool import configurator
from vdsm.tool.configurators import YES, NO, MAYBE, InvalidConfig, InvalidRun
from vdsm.tool.configfile import ConfigFile, ParserWrapper
+from vdsm.tool.configurators import abrt
from vdsm.tool.configurators import libvirt
from vdsm.tool import UsageError
from vdsm.tool import upgrade
@@ -36,7 +37,20 @@
dirName = os.path.dirname(os.path.realpath(__file__))
-FakeFiles = libvirt.FILES
+FakeLibvirtFiles = libvirt.FILES
+FakeAbrtFiles = abrt.FILES
+
+
+# helpers
+def _setConfig(obj, *configurations):
+ for file_, type_ in configurations:
+ with open(os.path.join(dirName,
+ 'toolTests_%s.conf' % type_)) as template:
+ data = template.read()
+ data = data % {
+ 'LATEST_CONF_VERSION': libvirt.CONF_VERSION}
+ with open(obj.test_env[file_], 'w') as testConf:
+ testConf.write(data)
class MockModuleConfigurator(object):
@@ -293,6 +307,68 @@
"remove-config")
+class AbrtModuleConfigureTests(TestCase):
+ srcPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ test_env = {}
+
+ def setUp(self):
+ self._test_dir = tempfile.mkdtemp()
+ self.test_env['ABRT_CONF'] = self._test_dir + '/abrt.conf'
+ self.test_env['CCPP_CONF'] = self._test_dir + '/CCPP.conf'
+ self.test_env['VMCORE_CONF'] = self._test_dir + '/vmcore.conf'
+ self.test_env['PKG_CONF'] = self._test_dir + \
+ '/abrt-action-save-package-data.conf'
+
+ for key, val in self.test_env.items():
+ FakeAbrtFiles[key]['path'] = val
+
+ self.patch = monkeypatch.Patch([
+ (
+ abrt,
+ 'FILES',
+ FakeAbrtFiles
+ )
+ ])
+
+ self.patch.apply()
+
+ def tearDown(self):
+ self.patch.revert()
+ utils.rmTree(self._test_dir)
+
+ def testIsConfiguredNegative(self):
+ _setConfig(self,
+ ('ABRT_CONF', 'abrt'),
+ ('CCPP_CONF', 'CCPP'),
+ ('VMCORE_CONF', 'empty'),
+ ('PKG_CONF', 'abrt-action-save-package-data'),
+ )
+ self.assertEqual(
+ abrt.isconfigured(),
+ NO
+ )
+
+ def testAbrtConfigure(self):
+ _setConfig(self,
+ ('ABRT_CONF', 'empty'),
+ ('CCPP_CONF', 'empty'),
+ ('VMCORE_CONF', 'empty'),
+ ('PKG_CONF', 'empty'),
+ )
+
+ self.assertEqual(
+ abrt.isconfigured(),
+ NO
+ )
+
+ abrt.configure()
+
+ self.assertEqual(
+ abrt.isconfigured(),
+ MAYBE
+ )
+
+
class LibvirtModuleConfigureTests(TestCase):
test_env = {}
@@ -311,12 +387,12 @@
for key, val in self.test_env.items():
if not key == 'VDSM_CONF':
- FakeFiles[key]['path'] = val
+ FakeLibvirtFiles[key]['path'] = val
- self._setConfig(
- ('QLCONF', 'libvirtd'),
- ('LDCONF', 'qemu_sanlock'),
- )
+ _setConfig(self,
+ ('QLCONF', 'libvirtd'),
+ ('LDCONF', 'qemu_sanlock'),
+ )
self.vdsm_cfg = make_config(())
self.patch = monkeypatch.Patch([
@@ -333,7 +409,7 @@
(
libvirt,
'FILES',
- FakeFiles
+ FakeLibvirtFiles
)
])
@@ -343,51 +419,39 @@
self.patch.revert()
utils.rmTree(self._test_dir)
- # helpers
- def _setConfig(self, *configurations):
- for file_, type_ in configurations:
- with open(os.path.join(dirName,
- 'toolTests_%s.conf' % type_)) as template:
- data = template.read()
- data = data % {
- 'LATEST_CONF_VERSION': libvirt.CONF_VERSION}
- with open(self.test_env[file_], 'w') as testConf:
- testConf.write(data)
-
def testValidatePositive(self):
self.vdsm_cfg.set('vars', 'ssl', 'true')
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertTrue(libvirt.validate())
def testValidateNegative(self):
self.vdsm_cfg.set('vars', 'ssl', 'false')
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertFalse(libvirt.validate())
def testIsConfiguredPositive(self):
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'qemu_ssl'),
-
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'qemu_ssl'),
+ )
self.assertEqual(
libvirt.isconfigured(),
MAYBE
)
def testIsConfiguredNegative(self):
- self._setConfig(
- ('LCONF', 'lconf_ssl'),
- ('QCONF', 'empty'),
- )
+ _setConfig(self,
+ ('LCONF', 'lconf_ssl'),
+ ('QCONF', 'empty'),
+ )
self.assertEqual(
libvirt.isconfigured(),
NO
@@ -395,10 +459,10 @@
def testLibvirtConfigureToSSLTrue(self):
self.vdsm_cfg.set('vars', 'ssl', 'true')
- self._setConfig(
- ('LCONF', 'empty'),
- ('QCONF', 'empty'),
- )
+ _setConfig(self,
+ ('LCONF', 'empty'),
+ ('QCONF', 'empty'),
+ )
self.assertEqual(
libvirt.isconfigured(),
diff --git a/tests/toolTests_CCPP.conf b/tests/toolTests_CCPP.conf
new file mode 100644
index 0000000..f0233e9
--- /dev/null
+++ b/tests/toolTests_CCPP.conf
@@ -0,0 +1,6 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+MakeCompatCore=no
+SaveBinaryImage=no
+CreateCoreBacktrace=yes
+SaveFullCore=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_abrt-action-save-package-data.conf b/tests/toolTests_abrt-action-save-package-data.conf
new file mode 100644
index 0000000..a75d738
--- /dev/null
+++ b/tests/toolTests_abrt-action-save-package-data.conf
@@ -0,0 +1,3 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+OpenGPGCheck=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_abrt.conf b/tests/toolTests_abrt.conf
new file mode 100644
index 0000000..17e5c4b
--- /dev/null
+++ b/tests/toolTests_abrt.conf
@@ -0,0 +1,6 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+DumpLocation=/var/tmp/abrt
+AutoreportingEvent=report_uReport
+MaxCrashReportsSize=1000
+AutoreportingEnabled=yes
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/tests/toolTests_vmcore.conf b/tests/toolTests_vmcore.conf
new file mode 100644
index 0000000..1177d02
--- /dev/null
+++ b/tests/toolTests_vmcore.conf
@@ -0,0 +1,3 @@
+## beginning of configuration section by vdsm-%(LATEST_CONF_VERSION)s
+CopyVMcore=no
+## end of configuration section by vdsm-%(LATEST_CONF_VERSION)s
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2cd7c92..e27945d 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -109,6 +109,9 @@
Requires: nfs-utils
Requires: m2crypto
Requires: libnl3
+Requires: abrt-addon-vmcore
+Requires: abrt-addon-ccpp
+Requires: abrt-addon-python
Requires: curl
Requires: %{name}-xmlrpc = %{version}-%{release}
Requires: %{name}-jsonrpc = %{version}-%{release}
@@ -804,13 +807,6 @@
/etc/sysctl.conf
fi
-# hack until we replace core dump with abrt
-if /usr/sbin/selinuxenabled; then
- /usr/sbin/semanage fcontext -a -t virt_cache_t '/var/log/core(/.*)?'
-fi
-/sbin/restorecon -R /var/log/core >/dev/null 2>&1
-# hack until we replace core dump with abrt
-
# VDSM installs vdsm-modules-load.d.conf file - the following command will
# refresh vdsm kernel modules requirements to start on boot
/bin/systemctl restart systemd-modules-load.service >/dev/null 2>&1 || :
@@ -1282,6 +1278,7 @@
%{python_sitelib}/%{vdsm_name}/tool/nwfilter.py*
%{python_sitelib}/%{vdsm_name}/tool/configurator.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/__init__*
+%{python_sitelib}/%{vdsm_name}/tool/configurators/abrt.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/certificates.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/libvirt.py*
%{python_sitelib}/%{vdsm_name}/tool/configurators/lvm.py*
@@ -1373,6 +1370,10 @@
%{_datadir}/%{vdsm_name}/tests/network/netmaskconversions
%{_datadir}/%{vdsm_name}/tests/network/tc_filter_show.out
%{_datadir}/%{vdsm_name}/tests/run_tests.sh
+%{_datadir}/%{vdsm_name}/tests/toolTests_abrt-action-save-package-data.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_abrt.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_CCPP.conf
+%{_datadir}/%{vdsm_name}/tests/toolTests_vmcore.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_empty.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_lconf_ssl.conf
%{_datadir}/%{vdsm_name}/tests/toolTests_libvirtd.conf
diff --git a/vdsm/vdsm-logrotate b/vdsm/vdsm-logrotate
index 120c18c..aa391cc 100755
--- a/vdsm/vdsm-logrotate
+++ b/vdsm/vdsm-logrotate
@@ -17,15 +17,6 @@
errors=$((errors+1))
fi
-if [ -d /var/log/core ] ; then
- /usr/bin/find /var/log/core -type f -name '*xz' -mtime +7 -exec /bin/rm -f '{}' \;
- EXITVALUE=$?
- if [ $EXITVALUE != 0 ]; then
- /usr/bin/logger -t vdsm-logrotate "ALERT clean old core files exited abnormally with [$EXITVALUE]"
- errors=$((errors+1))
- fi
-fi
-
if [ -d /var/log/vdsm/import ] ; then
/usr/bin/find /var/log/vdsm/import -type f -mtime +30 -exec /bin/rm -f '{}' \;
EXITVALUE=$?
--
To view, visit https://gerrit.ovirt.org/75660
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ca5e66c9f029be75483b86414e328d074c7e454
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.1
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[ovirt-4.1]: configfile: comment out old configuration when attribute is ...
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: configfile: comment out old configuration when attribute is set by vdsm
......................................................................
configfile: comment out old configuration when attribute is set by vdsm
When vdsm configures a key that already exists in conf file, the new key
will be created in vdsm-config-section. oldentries is a variable that tried to
do the opposite and leave keys instead of overriding with vdsm content if the
attribute is already set - the intention should be to use vdsm configuration
after calling vdsm-tool configure. This patch comment-out fields that
vdsm adds with a comment above those comments.
Change-Id: Id1dba75449b712432e0c2bc5b128cc996ede0153
Related-To: https://bugzilla.redhat.com/917062
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M lib/vdsm/tool/configfile.py
M tests/toolTests.py
2 files changed, 58 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/75659/1
diff --git a/lib/vdsm/tool/configfile.py b/lib/vdsm/tool/configfile.py
index bad0759..0121074 100644
--- a/lib/vdsm/tool/configfile.py
+++ b/lib/vdsm/tool/configfile.py
@@ -21,7 +21,6 @@
import functools
import os
import tempfile
-import re
import selinux
from six.moves import configparser
import io
@@ -112,9 +111,7 @@
return self
def _getOldContent(self):
- confpat = re.compile(r'^\s*(?P<key>[^=\s#]*)\s*=')
oldlines = []
- oldentries = set()
with io.open(self._filename, 'r', encoding='utf8') as f:
for line in f:
if self._remove:
@@ -135,13 +132,10 @@
line = line[len(self._prefix):]
if self._prefixAdd:
line = self._prefix + line
- m = confpat.match(line.rstrip())
- if m:
- oldentries.add(m.group('key'))
# remove this if at 4.0. see 'Backward compatibility'
if not self._remove or self._lineComment not in line:
oldlines.append(line)
- return oldlines, oldentries
+ return oldlines
def _start(self):
return u"%s-%s\n" % (self._sectionStart, self._version)
@@ -154,26 +148,33 @@
f.write(self._section)
f.write(self._end())
- def _writeEntries(self, f, oldentries):
+ def _writeEntries(self, f):
f.write(self._start())
for key, val in sorted(self._entries.items()):
- if key not in oldentries:
- f.write(u"{k}={v}\n".format(k=key, v=val))
+ f.write(u"{k}={v}\n".format(k=key, v=val))
f.write(self._end())
def __exit__(self, exec_ty, exec_val, tb):
-
self._context = False
if exec_ty is None:
fd, tname = tempfile.mkstemp(dir=os.path.dirname(self._filename))
try:
- oldlines, oldentries = self._getOldContent()
+ oldlines = self._getOldContent()
with io.open(fd, 'w', encoding='utf8') as f:
if self._section:
self._writeSection(f)
- f.writelines(oldlines)
+ # if oldlines includes something that we have in
+ # self._entries we need to write only the new value!
+ for fullline in oldlines:
+ line = fullline.replace(' ', '')
+ key = line.split("=")[0]
+ if key not in self._entries:
+ f.write(fullline)
+ else:
+ f.write(u'## commented out by vdsm\n')
+ f.write(u'# %s\n' % (fullline))
if self._entries:
- self._writeEntries(f, oldentries)
+ self._writeEntries(f)
os.rename(tname, self._filename)
diff --git a/tests/toolTests.py b/tests/toolTests.py
index 4bf51a8..0f065db 100644
--- a/tests/toolTests.py
+++ b/tests/toolTests.py
@@ -446,7 +446,7 @@
def testAddExistingConf(self):
self._writeConf("key1=val1\n"
- " key2 =val2\n"
+ "key2=val2"
"#key3=val4")
with ConfigFile(self.tname,
version='3.4.4',
@@ -457,9 +457,50 @@
with open(self.tname, 'r') as f:
self.assertEqual(f.read(), "key1=val1\n"
- " key2 =val2\n"
+ "## commented out by vdsm\n"
+ "# key2=val2"
+ "#key3=val4\n"
+ "# start conf-3.4.4\n"
+ "key2=val3\n"
+ "key3=val3\n"
+ "# end conf-3.4.4\n")
+
+ def testAddCommentedoutConf(self):
+ self._writeConf("key1=val1\n"
+ "#key3=val4")
+ with ConfigFile(self.tname,
+ version='3.4.4',
+ sectionStart="# start conf",
+ sectionEnd="# end conf") as conf:
+ conf.addEntry("key3", "val3")
+ conf.addEntry("key2", "val3")
+
+ with open(self.tname, 'r') as f:
+ self.assertEqual(f.read(), "key1=val1\n"
"#key3=val4"
"# start conf-3.4.4\n"
+ "key2=val3\n"
+ "key3=val3\n"
+ "# end conf-3.4.4\n")
+
+ def testAddExistingConfWithWhitespaces(self):
+ self._writeConf("key1=val1\n"
+ " key2 =val2"
+ "#key3=val4")
+ with ConfigFile(self.tname,
+ version='3.4.4',
+ sectionStart="# start conf",
+ sectionEnd="# end conf") as conf:
+ conf.addEntry("key3", "val3")
+ conf.addEntry("key2", "val3")
+
+ with open(self.tname, 'r') as f:
+ self.assertEqual(f.read(), "key1=val1\n"
+ "## commented out by vdsm\n"
+ "# key2 =val2"
+ "#key3=val4\n"
+ "# start conf-3.4.4\n"
+ "key2=val3\n"
"key3=val3\n"
"# end conf-3.4.4\n")
--
To view, visit https://gerrit.ovirt.org/75659
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1dba75449b712432e0c2bc5b128cc996ede0153
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.1
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[ovirt-4.1]: Add confutil to manage properties files easily
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Add confutil to manage properties files easily
......................................................................
Add confutil to manage properties files easily
In addition to confmeta [1], this util allows easy to manage files in
the format of
key = value
key2 = value
..
This uses configfile and add functionality for easy add and remove
sections inside the file.
Those function moved from libvirt configurator and are not introduced in
this patch. configurators/libvirt.py was the first usage until
abrt.conf. For later configurators this util might be useful.
See internal comments to understand usages.
[1] https://gerrit.ovirt.org/70583
Related-To: https://bugzilla.redhat.com/917062
Change-Id: Id67a0f51adb2d543c0542a48c020d34a13d1f2ed
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M lib/vdsm/tool/Makefile.am
M lib/vdsm/tool/configurators/libvirt.py
A lib/vdsm/tool/confutils.py
M vdsm.spec.in
4 files changed, 145 insertions(+), 91 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/75658/1
diff --git a/lib/vdsm/tool/Makefile.am b/lib/vdsm/tool/Makefile.am
index 45ec477..83cdc73 100644
--- a/lib/vdsm/tool/Makefile.am
+++ b/lib/vdsm/tool/Makefile.am
@@ -24,6 +24,7 @@
dist_vdsmtool_PYTHON = \
__init__.py \
confmeta.py \
+ confutils.py \
dummybr.py \
dump_bonding_opts.py \
dump_volume_chains.py \
diff --git a/lib/vdsm/tool/configurators/libvirt.py b/lib/vdsm/tool/configurators/libvirt.py
index 46e73d5..c756a93 100644
--- a/lib/vdsm/tool/configurators/libvirt.py
+++ b/lib/vdsm/tool/configurators/libvirt.py
@@ -1,4 +1,4 @@
-# Copyright 2014-2016 Red Hat, Inc.
+# Copyright 2014-2017 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
@@ -17,7 +17,6 @@
# Refer to the README and COPYING files for full details of the license
#
from __future__ import absolute_import
-import errno
import os
import uuid
import sys
@@ -25,7 +24,9 @@
from vdsm.config import config
from . import NO, MAYBE
-from vdsm.tool.configfile import ConfigFile, ParserWrapper
+
+from vdsm.tool import confutils
+from vdsm.tool.configfile import ParserWrapper
from vdsm import constants
@@ -34,13 +35,9 @@
services = ("vdsmd", "supervdsmd", "libvirtd")
-def _getFile(fname):
- return FILES[fname]['path']
-
-
def configure():
# Remove a previous configuration (if present)
- removeConf()
+ confutils.remove_conf(FILES, CONF_VERSION)
vdsmConfiguration = {
'ssl_enabled': config.getboolean('vars', 'ssl'),
@@ -50,7 +47,7 @@
# write configuration
for cfile, content in FILES.items():
- content['configure'](content, vdsmConfiguration)
+ content['configure'](content, CONF_VERSION, vdsmConfiguration)
def validate():
@@ -65,8 +62,8 @@
Check if libvirt is already configured for vdsm
"""
ret = MAYBE
- for path in (_getPersistedFiles()):
- if not _openConfig(path).hasConf():
+ for path in (confutils.get_persisted_files(FILES)):
+ if not confutils.open_config(path, CONF_VERSION).hasConf():
ret = NO
if ret == MAYBE:
@@ -74,21 +71,6 @@
else:
sys.stdout.write("libvirt is not configured for vdsm yet\n")
return ret
-
-
-def removeConf():
- for cfile, content in FILES.items():
- content['removeConf'](content['path'])
-
-
-def _getPersistedFiles():
- """
- get files where vdsm is expected to add a section.
- """
- return [
- cfile['path'] for cfile in FILES.values()
- if cfile['persisted']
- ]
def _isSslConflict():
@@ -103,12 +85,12 @@
'auth_tcp': 'sasl',
'listen_tls': '1',
})
- lconf_p.read(_getFile('LCONF'))
+ lconf_p.read(confutils.get_file_path('LCONF', FILES))
listen_tcp = lconf_p.getint('listen_tcp')
auth_tcp = lconf_p.get('auth_tcp')
listen_tls = lconf_p.getint('listen_tls')
qconf_p = ParserWrapper({'spice_tls': '0'})
- qconf_p.read(_getFile('QCONF'))
+ qconf_p.read(confutils.get_file_path('QCONF', FILES))
spice_tls = qconf_p.getboolean('spice_tls')
ret = True
if ssl:
@@ -144,59 +126,6 @@
return ret
-def _isApplicable(fragment, vdsmConfiguration):
- """
- Return true if 'fragment' should be included for current
- configuration. An applicable fragment is a fragment who's list
- of conditions are met according to vdsmConfiguration.
- """
- applyFragment = True
- for key, booleanValue in fragment['conditions'].items():
- if vdsmConfiguration[key] != booleanValue:
- applyFragment = False
- return applyFragment
-
-
-def _openConfig(path):
- return ConfigFile(path, CONF_VERSION)
-
-
-def _addSection(content, vdsmConfiguration):
- """
- Add a 'configuration section by vdsm' part to a config file.
- This section contains only keys not originally defined
- The section headers will include the current configuration version.
- """
- configuration = {}
- for fragment in content['fragments']:
- if _isApplicable(fragment, vdsmConfiguration):
- configuration.update(fragment['content'])
- if configuration:
- with _openConfig(content['path']) as conff:
- for key, val in configuration.items():
- conff.addEntry(key, val)
-
-
-def _removeFile(content, vdsmConfiguration):
- """
- delete a file if it exists.
- """
- try:
- os.unlink(content['path'])
- except OSError as e:
- if e.errno != errno.ENOENT:
- raise
-
-
-def _removeSection(path):
- """
- remove entire 'configuration section by vdsm' section.
- section is removed regardless of it's version.
- """
- if os.path.exists(path):
- with _openConfig(path) as conff:
- conff.removeConf()
-
# version != PACKAGE_VERSION since we do not want to update configuration
# on every update. see 'configuration versioning:' at Configfile.py for
# details.
@@ -212,8 +141,8 @@
constants.SYSCONF_PATH,
'libvirt/libvirtd.conf'
),
- 'configure': _addSection,
- 'removeConf': _removeSection,
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
'persisted': True,
'fragments': [
{
@@ -257,8 +186,8 @@
constants.SYSCONF_PATH,
'libvirt/qemu.conf',
),
- 'configure': _addSection,
- 'removeConf': _removeSection,
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
'persisted': True,
'fragments': [
{
@@ -318,8 +247,8 @@
constants.SYSCONF_PATH,
'sysconfig/libvirtd',
),
- 'configure': _addSection,
- 'removeConf': _removeSection,
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
'persisted': True,
'fragments': [
{
@@ -337,8 +266,8 @@
constants.SYSCONF_PATH,
'libvirt/qemu-sanlock.conf',
),
- 'configure': _addSection,
- 'removeConf': _removeSection,
+ 'configure': confutils.add_section,
+ 'removeConf': confutils.remove_section,
'persisted': True,
'fragments': [
{
@@ -367,8 +296,8 @@
constants.SYSCONF_PATH,
'libvirt/qemu/networks/autostart/default.xml',
),
- 'configure': _removeFile,
- 'removeConf': lambda x: True,
+ 'configure': confutils.remove_file,
+ 'removeConf': lambda x, y: True,
'persisted': False,
}
}
diff --git a/lib/vdsm/tool/confutils.py b/lib/vdsm/tool/confutils.py
new file mode 100644
index 0000000..d73ce2e
--- /dev/null
+++ b/lib/vdsm/tool/confutils.py
@@ -0,0 +1,123 @@
+# Copyright 2017 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from __future__ import absolute_import
+import errno
+import os
+
+from vdsm.tool.configfile import ConfigFile
+
+'''
+The following function are being used for property conf file configuration
+For example, in libvirt and abrt configurators we use those helper functions
+to manage the files in the following way:
+
+FILES = {
+ [file_name]: {
+ path: [path_to_file],
+ configure: [function that configures this file],
+ removeConf: [function that removes vdsm config from the file],
+ persisted: [True or False if we want to save changes],
+ fragments: [dict content of the configurations],
+ }
+}
+
+'''
+
+
+def get_file_path(fname, files):
+ """
+ Helper func to get 'path' key for specific file key.
+ """
+ return files[fname]['path']
+
+
+def remove_conf(files, version):
+ """
+ calling removeConf func for all files in dict with conf version to remove
+ """
+ for cfile, content in files.items():
+ content['removeConf'](content['path'], version)
+
+
+def add_section(content, version, vdsmConfiguration={}):
+ """
+ Add a 'configuration section by vdsm' part to a config file.
+ This section contains only keys not originally defined
+ The section headers will include the current configuration version.
+ """
+ configuration = {}
+ for fragment in content['fragments']:
+ if vdsmConfiguration:
+ if is_applicable(fragment, vdsmConfiguration):
+ configuration.update(fragment['content'])
+ else:
+ configuration.update(fragment['content'])
+ if configuration:
+ with open_config(content['path'], version) as conff:
+ for key, val in configuration.items():
+ conff.addEntry(key, val)
+
+
+def remove_section(path, version):
+ """
+ remove entire 'configuration section by vdsm' section.
+ section is removed regardless of it's version.
+ """
+ if os.path.exists(path):
+ with open_config(path, version) as conff:
+ conff.removeConf()
+
+
+def remove_file(content, version, vdsmConfiguration):
+ """
+ Helper configure func that removes a file if exists.
+ This being used once - TODO: consider if to leave it in libvirt.py
+ """
+ try:
+ os.unlink(content['path'])
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+
+
+def get_persisted_files(files):
+ """
+ get files where vdsm is expected to add a section.
+ """
+ return [
+ cfile['path'] for cfile in files.values()
+ if cfile['persisted']
+ ]
+
+
+def open_config(path, conf_version):
+ return ConfigFile(path, conf_version)
+
+
+def is_applicable(fragment, vdsmConfiguration):
+ """
+ Return true if 'fragment' should be included for current
+ configuration. An applicable fragment is a fragment who's list
+ of conditions are met according to vdsmConfiguration.
+ """
+ applyFragment = True
+ for key, booleanValue in fragment['conditions'].items():
+ if vdsmConfiguration[key] != booleanValue:
+ applyFragment = False
+ return applyFragment
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 2a26d24..2cd7c92 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1276,6 +1276,7 @@
%{python_sitelib}/%{vdsm_name}/tool/__init__.py*
%{python_sitelib}/%{vdsm_name}/tool/configfile.py*
%{python_sitelib}/%{vdsm_name}/tool/confmeta.py*
+%{python_sitelib}/%{vdsm_name}/tool/confutils.py*
%{python_sitelib}/%{vdsm_name}/tool/dummybr.py*
%{python_sitelib}/%{vdsm_name}/tool/dump_bonding_opts.py*
%{python_sitelib}/%{vdsm_name}/tool/nwfilter.py*
--
To view, visit https://gerrit.ovirt.org/75658
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id67a0f51adb2d543c0542a48c020d34a13d1f2ed
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.1
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 11 months
Change in vdsm[master]: net, virt net: Relocate network.libvirt to virt.libvirtnetwork
by Code Review
From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has posted comments on this change.
Change subject: net, virt net: Relocate network.libvirt to virt.libvirtnetwork
......................................................................
Patch Set 3: Code-Review+1
--
To view, visit https://gerrit.ovirt.org/76164
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I6d910f8313f7fb6abcc966e7e0419a720809bdb7
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwardh(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
Gerrit-HasComments: No
6 years, 12 months