Skip to content

Commit 8c291d3

Browse files
committed
statd: fix EXPIRES column alignment in 'show dhcp-server'
The EXPIRES column was misaligned due to multiple issues: - Column header used width 10 while data rows used width 9 - Expiry values had leading space intended for the narrower width - CLIENT ID column width (19) was too narrow for typical client IDs like "01:00:a0:85:00:01:05" (20 chars), causing overflow Fixed by using consistent width for EXPIRES, removing the leading space from expiry values, and widening CLIENT ID column to 22. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 6c19400 commit 8c291d3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/statd/python/cli_pretty/cli_pretty.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class PadDhcpServer:
154154
ip = 17
155155
mac = 19
156156
host = 21
157-
cid = 19
157+
cid = 22
158158
exp = 10
159159

160160

@@ -720,11 +720,11 @@ def __init__(self, data):
720720
now = datetime.now(timezone.utc)
721721
for lease in get_json_data([], self.data, 'leases', 'lease'):
722722
if lease["expires"] == "never":
723-
exp = " never"
723+
exp = "never"
724724
else:
725725
dt = datetime.strptime(lease['expires'], '%Y-%m-%dT%H:%M:%S%z')
726726
seconds = int((dt - now).total_seconds())
727-
exp = f" {self.format_duration(seconds)}"
727+
exp = self.format_duration(seconds)
728728
self.leases.append({
729729
"ip": lease["address"],
730730
"mac": lease["phys-address"],
@@ -775,7 +775,7 @@ def print(self):
775775
row += f"{mac:<{PadDhcpServer.mac}}"
776776
row += f"{host:<{PadDhcpServer.host}}"
777777
row += f"{cid:<{PadDhcpServer.cid}}"
778-
row += f"{exp:>{PadDhcpServer.exp - 1}}"
778+
row += f"{exp:>{PadDhcpServer.exp}}"
779779
print(row)
780780

781781
def print_stats(self):

0 commit comments

Comments
 (0)