View | Details | Raw Unified | Return to bug 40605
Collapse All | Expand All

(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py (-2 / +54 lines)
Line 0    Link Here 
0
- 
1
#!/usr/bin/python2.7
2
# coding: utf-8
3
#
4
# Univention Management Console module:
5
#  System Diagnosis UMC module
6
#
7
# Copyright 2016-2017 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
from subprocess import Popen, PIPE, STDOUT
35
36
from univention.management.console.modules.diagnostic import Critical
37
38
from univention.lib.i18n import Translation
39
_ = Translation('univention-management-console-module-diagnostic').translate
40
41
title = _('Check local AD database for errors')
42
description = _('No errors found.'),
43
44
45
def run():
46
	process = Popen(['samba-tool', 'dbcheck'], stdout=PIPE, stderr=STDOUT)
47
	stdout, stderr = process.communicate()
48
	if process.returncode:
49
		raise Critical('\n'.join([description, '', stdout]))
50
51
52
if __name__ == '__main__':
53
	from univention.management.console.modules.diagnostic import main
54
	main()
1
samba_tool_dbcheck.py
55
samba_tool_dbcheck.py
2
--
3
.../diagnostic/plugins/samba_tool_dbcheck.py       | 81 ++++++++++++++++++++--
56
.../diagnostic/plugins/samba_tool_dbcheck.py       | 81 ++++++++++++++++++++--
4
1 file changed, 74 insertions(+), 7 deletions(-)
57
1 file changed, 74 insertions(+), 7 deletions(-)
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/samba_tool_dbcheck.py (-9 / +74 lines)
 Lines 31-39    Link Here 
31
# /usr/share/common-licenses/AGPL-3; if not, see
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
32
# <http://www.gnu.org/licenses/>.
33
33
34
from subprocess import Popen, PIPE, STDOUT
34
import ldap
35
import socket
36
import subprocess
35
37
36
from univention.management.console.modules.diagnostic import Critical
38
import univention.uldap
39
from univention.management.console.modules.diagnostic import Critical, ProblemFixed
37
40
38
from univention.lib.i18n import Translation
41
from univention.lib.i18n import Translation
39
_ = Translation('univention-management-console-module-diagnostic').translate
42
_ = Translation('univention-management-console-module-diagnostic').translate
 Lines 42-52   title = _('Check local AD database for errors') Link Here 
42
description = _('No errors found.'),
45
description = _('No errors found.'),
43
46
44
47
45
def run():
48
def run_samba_tool_dbcheck_fix():
46
	process = Popen(['samba-tool', 'dbcheck'], stdout=PIPE, stderr=STDOUT)
49
	if not is_service_active('Samba 4'):
47
	stdout, stderr = process.communicate()
50
		return
48
	if process.returncode:
51
49
		raise Critical('\n'.join([description, '', stdout]))
52
	cmd = ['samba-tool', 'dbcheck', '--fix', '--yes']
53
	(success, output) = run_with_output(cmd)
54
	if success:
55
		fix_log = [_('`samba-tool dbcheck --fix --yes` failed.')]
56
	else:
57
		fix_log = [_('`samba-tool dbcheck --fix --yes` succeeded.')]
58
	fix_log.append(output)
59
	run(rerun=True, fix_log='\n'.join(fix_log))
60
61
62
actions = {
63
	'run_samba_tool_dbcheck_fix': run_samba_tool_dbcheck_fix
64
}
65
66
67
def is_service_active(service):
68
	lo = univention.uldap.getMachineConnection()
69
	raw_filter = '(&(univentionService=%s)(cn=%s))'
70
	filter_expr = ldap.filter.filter_format(raw_filter, (service, socket.gethostname()))
71
	for (dn, _attr) in lo.search(filter_expr, attr=['cn']):
72
		if dn is not None:
73
			return True
74
	return False
75
76
77
def run_with_output(cmd):
78
	output = list()
79
	process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
80
	(stdout, stderr) = process.communicate()
81
	if stdout:
82
		output.append('\nSTDOUT:\n{}'.format(stdout))
83
	if stderr:
84
		output.append('\nSTDERR:\n{}'.format(stderr))
85
	return (process.returncode == 0, '\n'.join(output))
86
87
88
def run(rerun=False, fix_log=''):
89
	if not is_service_active('Samba 4'):
90
		return
91
92
	error_descriptions = list()
93
	if rerun and fix_log:
94
		error_descriptions.append(fix_log)
95
96
	buttons = [{
97
		'action': 'run_samba_tool_dbcheck_fix',
98
		'label': _('Run `samba-tool dbcheck --fix --yes`'),
99
	}]
100
101
	cmd = ['samba-tool', 'dbcheck']
102
	(success, output) = run_with_output(cmd)
103
	if not success:
104
		error = _('`samba-tool dbcheck` returned a problem with the local AD database.')
105
		error_descriptions.append(error)
106
		error_descriptions.append(output)
107
		if not rerun:
108
			fix = _('You can run `samba-tool dbcheck --fix` to fix the issue.')
109
			error_descriptions.append(fix)
110
		raise Critical(description='\n'.join(error_descriptions), buttons=buttons)
111
112
	if rerun:
113
		fixed = _('`samba-tool dbcheck` found no problems with the local AD database.')
114
		error_descriptions.append(fixed)
115
		error_descriptions.append(output)
116
		raise ProblemFixed(description='\n'.join(error_descriptions))
50
117
51
118
52
if __name__ == '__main__':
119
if __name__ == '__main__':
53
- 
54
samba_tool_dbcheck.py (po)
120
samba_tool_dbcheck.py (po)
55
--
56
.../umc/python/diagnostic/de.po                    | 36 ++++++++++++++++++++--
121
.../umc/python/diagnostic/de.po                    | 36 ++++++++++++++++++++--
57
1 file changed, 34 insertions(+), 2 deletions(-)
122
1 file changed, 34 insertions(+), 2 deletions(-)
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po (-3 / +34 lines)
 Lines 2-9    Link Here 
2
msgid ""
2
msgid ""
3
msgstr ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: \n"
6
"POT-Creation-Date: 2016-01-14 12:19+0100\n"
6
"POT-Creation-Date: 2017-06-01 18:00+0200\n"
7
"PO-Revision-Date: \n"
7
"PO-Revision-Date: \n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
 Lines 27-32   msgstr "" Link Here 
27
msgid "Adjust to suggested limits"
27
msgid "Adjust to suggested limits"
28
msgstr "An vorgeschlagene Limits anpassen"
28
msgstr "An vorgeschlagene Limits anpassen"
29
29
30
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:44
31
msgid "Check local AD database for errors"
32
msgstr "Teste die locale AD Datenbank auf Fehler"
33
30
#: umc/python/diagnostic/plugins/gateway.py:11
34
#: umc/python/diagnostic/plugins/gateway.py:11
31
msgid "Gateway is not reachable"
35
msgid "Gateway is not reachable"
32
msgstr "Gateway ist nicht erreichbar"
36
msgstr "Gateway ist nicht erreichbar"
 Lines 97-102   msgstr "" Link Here 
97
msgid "Nameserver(s) are not responsive"
101
msgid "Nameserver(s) are not responsive"
98
msgstr "Nameserver sind nicht ansprechbar"
102
msgstr "Nameserver sind nicht ansprechbar"
99
103
104
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:45
105
msgid "No errors found."
106
msgstr "Keine Fehler gefunden."
107
100
#: umc/python/diagnostic/plugins/package_status.py:11
108
#: umc/python/diagnostic/plugins/package_status.py:11
101
msgid "Package status corrupt"
109
msgid "Package status corrupt"
102
msgstr "Paketstatus korrupt"
110
msgstr "Paketstatus korrupt"
 Lines 129-134   msgstr "" Link Here 
129
msgid "Proxy server failure"
137
msgid "Proxy server failure"
130
msgstr "Proxy-Server-Fehler"
138
msgstr "Proxy-Server-Fehler"
131
139
140
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:98
141
msgid "Run `samba-tool dbcheck --fix --yes`"
142
msgstr "Führe `samba-tool dbcheck --fix --yes` aus"
143
132
#: umc/python/diagnostic/plugins/ssh_connection.py:16
144
#: umc/python/diagnostic/plugins/ssh_connection.py:16
133
msgid "SSH connection to UCS server failed!"
145
msgid "SSH connection to UCS server failed!"
134
msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!"
146
msgstr "SSH-Verbindung zu anderem UCS Server fehlgeschlagen!"
 Lines 260-265   msgstr "" Link Here 
260
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
272
"dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die "
261
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
273
"ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen."
262
274
275
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:108
276
msgid "You can run `samba-tool dbcheck --fix` to fix the issue."
277
msgstr "Sie können `samba-tool dbcheck --fix` ausführen um die Probleme zu beheben."
278
279
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:55
280
msgid "`samba-tool dbcheck --fix --yes` failed."
281
msgstr "`samba-tool dbcheck --fix --yes` ist fehlgeschlagen."
282
283
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:57
284
msgid "`samba-tool dbcheck --fix --yes` succeeded."
285
msgstr "`samba-tool dbcheck --fix --yes` war erfolgreich."
286
287
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:113
288
msgid "`samba-tool dbcheck` found no problems with the local AD database."
289
msgstr "`samba-tool dbcheck` hat keine Probleme mit der lokalen AD Datenbank gefunden."
290
291
#: umc/python/diagnostic/plugins/samba_tool_dbcheck.py:104
292
msgid "`samba-tool dbcheck` returned a problem with the local AD database."
293
msgstr "`samba-tool dbcheck` fand Probleme mit der lokalen AD Datenbank."
294
263
#: umc/python/diagnostic/plugins/package_status.py:28
295
#: umc/python/diagnostic/plugins/package_status.py:28
264
msgid "some"
296
msgid "some"
265
msgstr "einigen"
297
msgstr "einigen"
266
- 

Return to bug 40605