Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
openldap
Syncrepl monitoring tools
Commits
e89f7766
Commit
e89f7766
authored
Sep 21, 2020
by
Ondřej Kuzník
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes to cookie tracking
parent
349af5d0
Pipeline
#1048
passed with stage
in 49 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
7 deletions
+24
-7
syncmonitor/connection.py
syncmonitor/connection.py
+1
-1
syncmonitor/cookie.py
syncmonitor/cookie.py
+12
-6
syncmonitor/environment.py
syncmonitor/environment.py
+3
-0
syncmonitor/ui.py
syncmonitor/ui.py
+4
-0
syncmonitor/watchdog.py
syncmonitor/watchdog.py
+4
-0
No files found.
syncmonitor/connection.py
View file @
e89f7766
...
...
@@ -48,7 +48,7 @@ def connect_and_setup(uri, config):
conn
.
set_option
(
ldap
.
OPT_X_TLS_NEWCTX
,
0
)
if
uri
.
urlscheme
==
'ldap'
:
starttls
=
config
.
get
(
'starttls'
,
'
yes
'
)
starttls
=
config
.
get
(
'starttls'
,
'
no
'
)
if
starttls
:
try
:
conn
.
start_tls_s
()
...
...
syncmonitor/cookie.py
View file @
e89f7766
...
...
@@ -42,11 +42,6 @@ class SyncreplCookie:
if
cookie
:
self
.
update
(
cookie
)
if
self
.
rid
is
None
:
self
.
rid
=
0
if
self
.
sid
is
None
:
self
.
sid
=
0
def
_parse_csn
(
self
,
csn
):
return
csn
.
split
(
'#'
,
3
)
# time, order, sid, other
...
...
@@ -101,7 +96,7 @@ class SyncreplCookie:
def
unparse
(
self
):
"Return the cookie as a string"
cookie
=
'rid={:03},sid={:03x}'
.
format
(
self
.
rid
,
self
.
sid
)
cookie
=
'rid={:03},sid={:03x}'
.
format
(
self
.
rid
or
0
,
self
.
sid
or
0
)
if
self
.
_csnset
:
cookie
+=
',csn='
cookie
+=
';'
.
join
(
sorted
(
self
.
_csnset
.
values
()))
...
...
@@ -120,7 +115,11 @@ class SyncreplCookie:
return
self
.
_csnset
[
key
]
def
__sub__
(
self
,
cookie
):
if
cookie
is
None
:
return
self
.
copy
()
if
not
isinstance
(
cookie
,
__class__
):
logger
.
error
(
"Got a %r instead of %r"
,
type
(
cookie
),
__class__
)
raise
NotImplementedError
result
=
self
.
copy
()
...
...
@@ -134,6 +133,9 @@ class SyncreplCookie:
def
__and__
(
self
,
cookie
):
"""The highest cookie contained in both"""
if
not
cookie
:
return
cookie
if
not
isinstance
(
item
,
__class__
):
raise
NotImplementedError
...
...
@@ -153,6 +155,10 @@ class SyncreplCookie:
return
self
.
_csnset
.
keys
()
def
__contains__
(
self
,
item
):
"""Is the state described in item contained in this cookie?"""
if
item
is
None
:
return
True
if
not
isinstance
(
item
,
__class__
):
raise
NotImplementedError
...
...
syncmonitor/environment.py
View file @
e89f7766
...
...
@@ -80,6 +80,7 @@ class Provider:
cookie_updated
=
Signal
()
state_changed
=
Signal
()
sid_discovered
=
Signal
()
def
__init__
(
self
,
uri
,
config
,
searchbase
,
scope
=
ldap0
.
SCOPE_BASE
,
cookie
=
None
,
mode
=
'refreshAndPersist'
):
self
.
uri
=
uri
...
...
@@ -127,6 +128,7 @@ class Provider:
logger
.
debug
(
"Update from ourselves, cookie %s"
,
new_cookie
)
if
self
.
sid
is
None
:
self
.
sid
=
new_cookie
.
sid
self
.
sid_discovered
(
self
.
sid
)
self
.
cookie
.
update
(
new_cookie
)
self
.
cookie_updated
(
new_cookie
)
...
...
@@ -135,6 +137,7 @@ class Provider:
self
.
state_changed
(
self
.
state
)
def
_catch_up_event
(
self
,
caught_up
):
assert
self
.
catching_up_set
diff
=
self
.
cookie
-
self
.
catching_up_from
if
self
.
catching_up_set
&
diff
==
diff
:
# we have seen progress on all relevant sids
...
...
syncmonitor/ui.py
View file @
e89f7766
...
...
@@ -58,6 +58,7 @@ class ProviderEntry(urwid.LineBox):
self
.
provider
.
cookie_updated
.
connect
(
self
.
cookie_updated
)
self
.
provider
.
state_changed
.
connect
(
self
.
state_changed
)
self
.
provider
.
sid_discovered
.
connect
(
self
.
new_sid
)
def
cookie_updated
(
self
,
cookie
):
self
.
body
.
contents
[
1
:]
=
[(
urwid
.
Text
(
csn
),
self
.
body
.
options
())
for
csn
in
cookie
]
...
...
@@ -65,6 +66,9 @@ class ProviderEntry(urwid.LineBox):
def
state_changed
(
self
,
new_state
):
self
.
state
.
set_text
(
new_state
.
value
)
def
new_sid
(
self
,
sid
):
self
.
set_title
(
self
.
provider
.
uri
+
" sid=%03x"
%
self
.
provider
.
sid
)
def
stop
(
self
):
self
.
provider
.
stop
()
...
...
syncmonitor/watchdog.py
View file @
e89f7766
...
...
@@ -55,7 +55,11 @@ class Watchdog:
def
clear
(
self
,
rearm
=
False
):
if
self
.
set
:
self
.
cleared
.
emit
(
self
.
set
)
self
.
set
=
False
if
self
.
timer
:
self
.
timer
.
cancel
()
self
.
timer
=
None
if
rearm
:
self
.
rearm
(
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment