Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FUSS
fuss-manager
Commits
cce3f7ac
Commit
cce3f7ac
authored
Aug 21, 2020
by
Elena Grandi
Browse files
Fix dhcp leases datasource
parent
f8aa6713
Changes
2
Hide whitespace changes
Inline
Side-by-side
manager/sources/dhcp_leases.py
View file @
cce3f7ac
...
...
@@ -57,16 +57,18 @@ class DhcpLeasesDataSource(MachineDataSourceMixin, DataSource):
async
def
parse_file
(
self
):
leases
=
isc_dhcp_leases
.
IscDhcpLeases
(
self
.
fname
)
for
l
in
leases
.
get_current
():
# do things with the lease
for
l
in
leases
.
get
():
mac
=
getattr
(
l
,
l
.
hardware
,
None
)
if
not
mac
:
continue
ip
=
getattr
(
l
,
'ip'
,
None
)
ts
=
l
.
start
.
timestamp
()
await
self
.
event_hub
.
publish
(
events
.
HostSeenEvent
(
self
,
mac
=
mac
,
ip
=
ip
,
timestamp
=
ts
,
)
)
tests/test_source_dhcpd_leases.py
View file @
cce3f7ac
...
...
@@ -44,7 +44,6 @@ class TestDhcpdLeasesDataSource(TestDataSourceMixin, AsyncTestCase):
shutil
.
copyfileobj
(
fp
,
self
.
tmpfile
)
self
.
tmpfile
.
flush
()
# Wait until changes start to be reported
await
events
.
received_first
await
self
.
event_hub
.
publish
(
StopTest
(
None
))
...
...
@@ -58,7 +57,7 @@ class TestDhcpdLeasesDataSource(TestDataSourceMixin, AsyncTestCase):
self
.
assertEqual
(
len
(
events
),
1
)
# Full checks on the 3 events for the first machine
self
.
assertEqual
(
events
[
0
].
name
,
cliente
.
school
.
lan
)
#
self.assertEqual(events[0].name,
'
cliente.school.lan
'
)
self
.
assertEqual
(
events
[
0
].
mac
,
"52:54:00:f2:f7:62"
)
self
.
assertEqual
(
events
[
0
].
ip
,
"192.168.6.100"
)
ts
=
datetime
.
datetime
.
fromtimestamp
(
events
[
0
].
timestamp
)
...
...
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