Skip to content

Commit 0c4825a

Browse files
committed
dhcp.py T6998 - make similar change for ipv6
1 parent 9215549 commit 0c4825a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/op_mode/dhcp.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig
101101
lifetime = lease['valid-lft']
102102
expiry = (lease['cltt'] + lifetime)
103103

104-
lease['start_timestamp'] = datetime.fromtimestamp(expiry - lifetime, timezone.utc)
104+
lease['start_timestamp'] = datetime.fromtimestamp(lease['cltt'], timezone.utc)
105105
lease['expire_timestamp'] = datetime.fromtimestamp(expiry, timezone.utc) if expiry else None
106106

107107
data_lease = {}
@@ -170,8 +170,8 @@ def _get_formatted_server_leases(raw_data, family='inet'):
170170
ipaddr = lease.get('ip')
171171
hw_addr = lease.get('mac')
172172
state = lease.get('state')
173-
start = datetime.fromtimestamp(lease.get('start'))
174-
end = datetime.fromtimestamp(lease.get('end')) if lease.get('end') else '-'
173+
start = datetime.fromtimestamp(lease.get('start'), timezone.utc)
174+
end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-'
175175
remain = lease.get('remaining')
176176
pool = lease.get('pool')
177177
hostname = lease.get('hostname')
@@ -185,10 +185,8 @@ def _get_formatted_server_leases(raw_data, family='inet'):
185185
for lease in raw_data:
186186
ipaddr = lease.get('ip')
187187
state = lease.get('state')
188-
start = lease.get('last_communication')
189-
start = _utc_to_local(start).strftime('%Y/%m/%d %H:%M:%S')
190-
end = lease.get('end')
191-
end = _utc_to_local(end).strftime('%Y/%m/%d %H:%M:%S')
188+
start = datetime.fromtimestamp(lease.get('last_communication'), timezone.utc)
189+
end = datetime.fromtimestamp(lease.get('end'), timezone.utc) if lease.get('end') else '-'
192190
remain = lease.get('remaining')
193191
lease_type = lease.get('type')
194192
pool = lease.get('pool')

0 commit comments

Comments
 (0)