Skip to content

Commit

Permalink
dhcpv6-server: T5992: Fix op-mode Kea DHCP lease output, migration fr…
Browse files Browse the repository at this point in the history
…om deprectaed utcfromtimestamp to fromtimestamp
  • Loading branch information
nvandamme committed Jan 8, 2025
1 parent b762a49 commit 1ccfbf1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
lifetime = lease['valid-lft']
expiry = (lease['cltt'] + lifetime)

lease['start_timestamp'] = datetime.fromtimestamp(expiry - lifetime, timezone.utc)
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, timezone.utc) if expiry else None
lease['start_timestamp'] = datetime.fromtimestamp(expiry - lifetime, tz=timezone.utc)
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, tz=timezone.utc) if expiry else None

data_lease = {}
data_lease['ip'] = lease['ip-address']
Expand Down Expand Up @@ -132,7 +132,7 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
data_lease['remaining'] = '-'

if lease['valid-lft'] > 0:
data_lease['remaining'] = lease['expire_timestamp'] - datetime.now(timezone.utc)
data_lease['remaining'] = lease['expire_timestamp'] - datetime.now(tz=timezone.utc)

if data_lease['remaining'].days >= 0:
# substraction gives us a timedelta object which can't be formatted with strftime
Expand Down

0 comments on commit 1ccfbf1

Please sign in to comment.