Skip to content

Commit

Permalink
dhcp.py T6998 - make similar change for ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
metron2 committed Jan 6, 2025
1 parent 9215549 commit 0c4825a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ 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['start_timestamp'] = datetime.fromtimestamp(lease['cltt'], timezone.utc)
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, timezone.utc) if expiry else None

data_lease = {}
Expand Down Expand Up @@ -170,8 +170,8 @@ def _get_formatted_server_leases(raw_data, family='inet'):
ipaddr = lease.get('ip')
hw_addr = lease.get('mac')
state = lease.get('state')
start = datetime.fromtimestamp(lease.get('start'))
end = datetime.fromtimestamp(lease.get('end')) if lease.get('end') else '-'
start = datetime.fromtimestamp(lease.get('start'), timezone.utc)
end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-'
remain = lease.get('remaining')
pool = lease.get('pool')
hostname = lease.get('hostname')
Expand All @@ -185,10 +185,8 @@ def _get_formatted_server_leases(raw_data, family='inet'):
for lease in raw_data:
ipaddr = lease.get('ip')
state = lease.get('state')
start = lease.get('last_communication')
start = _utc_to_local(start).strftime('%Y/%m/%d %H:%M:%S')
end = lease.get('end')
end = _utc_to_local(end).strftime('%Y/%m/%d %H:%M:%S')
start = datetime.fromtimestamp(lease.get('last_communication'), timezone.utc)
end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-'
remain = lease.get('remaining')
lease_type = lease.get('type')
pool = lease.get('pool')
Expand Down

0 comments on commit 0c4825a

Please sign in to comment.