Wednesday, May 31, 2017

[389-commits] [lib389] 02/02: Ticket 62 - dirsrv offline log

This is an automated email from the git hooks/post-receive script.

firstyear pushed a commit to branch master
in repository lib389.

commit 934741a64b8a8c4d50109c99790c2ec12d100b00
Author: William Brown <firstyear@redhat.com>
Date: Wed May 31 11:16:37 2017 +1000

Ticket 62 - dirsrv offline log

Bug Description: dirsrv log would use the online ldap server to lookup
the access and error path, but this does not work when instance is
offline.

Fix Description: Convert this to use the ds_paths module that does
correctly account for this. Improve offline state handling so that
we can check this properly.

https://pagure.io/lib389/issue/62

Author: wibrown

Review by: spichugi (Thanks!)
---
lib389/__init__.py | 7 ++++++-
lib389/dirsrv_log.py | 19 +++++++++----------
2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib389/__init__.py b/lib389/__init__.py
index 1967f57..d96a937 100644
--- a/lib389/__init__.py
+++ b/lib389/__init__.py
@@ -1269,11 +1269,16 @@ class DirSrv(SimpleLDAPObject, object):
pid = pid_from_file(self.ds_paths.pid_file)
if pid is None:
# No pidfile yet ...
+ self.state = DIRSRV_STATE_OFFLINE
return False
if pid == 0:
+ self.state = DIRSRV_STATE_OFFLINE
raise ValueError
# Wait
- return pid_exists(pid)
+ if not pid_exists(pid):
+ self.state = DIRSRV_STATE_OFFLINE
+ return False
+ return True

def restart(self, timeout=120, post_open=True):
'''
diff --git a/lib389/dirsrv_log.py b/lib389/dirsrv_log.py
index bf7f301..3b452fc 100644
--- a/lib389/dirsrv_log.py
+++ b/lib389/dirsrv_log.py
@@ -15,7 +15,6 @@ from datetime import datetime
from dateutil.parser import parse as dt_parse
from glob import glob
from lib389._constants import DN_CONFIG
-from lib389.properties import LOG_ACCESS_PATH, LOG_ERROR_PATH
from lib389.utils import ensure_bytes, ensure_str


@@ -50,15 +49,9 @@ class DirsrvLog(object):
self.prog_timestamp = re.compile('\[(?P<day>\d*)\/(?P<month>\w*)\/(?P<year>\d*):(?P<hour>\d*):(?P<minute>\d*):(?P<second>\d*)(.(?P<nanosecond>\d*))+\s(?P<tz>[\+\-]\d*)') # noqa
self.prog_datetime = re.compile('^(?P<timestamp>\[.*\])')

- def _get_log_attr(self, attr):
- """Get a logging configfurable attribute value
- @param attr - a logging configuration attribute
- """
- return self.dirsrv.getEntry(DN_CONFIG).__getattr__(attr)
-
def _get_log_path(self):
"""Return the current log file location"""
- return self._get_log_attr(self.log_path_attr)
+ raise Exception("Log type not defined.")

def _get_all_log_paths(self):
"""Return all the log paths"""
@@ -185,7 +178,6 @@ class DirsrvAccessLog(DirsrvLog):
@param dirsrv - A DirSrv object
"""
super(DirsrvAccessLog, self).__init__(dirsrv)
- self.log_path_attr = LOG_ACCESS_PATH
## We precompile our regex for parse_line to make it faster.
self.prog_m1 = re.compile('^(?P<timestamp>\[.*\])\sconn=(?P<conn>\d*)\sop=(?P<op>\d*)\s(?P<action>\w*)\s(?P<rem>.*)')
self.prog_con = re.compile('^(?P<timestamp>\[.*\])\sconn=(?P<conn>\d*)\sfd=(?P<fd>\d*)\sslot=(?P<slot>\d*)\sconnection\sfrom\s(?P<remote>[^\s]*)\sto\s(?P<local>[^\s]*)')
@@ -199,6 +191,10 @@ class DirsrvAccessLog(DirsrvLog):
self.result_regexs = [self.prog_notes, self.prog_repl,
self.prog_result]

+ def _get_log_path(self):
+ """Return the current log file location"""
+ return self.dirsrv.ds_paths.access_log
+
def parse_line(self, line):
"""
This knows how to break up an access log line into the specific fields.
@@ -249,9 +245,12 @@ class DirsrvErrorLog(DirsrvLog):
@param diursrv - A DirSrv object
"""
super(DirsrvErrorLog, self).__init__(dirsrv)
- self.log_path_attr = LOG_ERROR_PATH
self.prog_m1 = re.compile('^(?P<timestamp>\[.*\])\s(?P<message>.*)')

+ def _get_log_path(self):
+ """Return the current log file location"""
+ return self.dirsrv.ds_paths.error_log
+
def parse_line(self, line):
"""Parse an errors log line
@line - a text string from an errors log

--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org

No comments:

Post a Comment