Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions op-mode-definitions/dhcp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start state</list>
<list>client_id end hostname ip mac pool remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf '' --origin $6 --sort $8</command>
Expand All @@ -137,7 +137,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac remaining start state</list>
<list>client_id end hostname ip mac remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf '' --pool $6 --sort $8</command>
Expand All @@ -148,7 +148,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start state</list>
<list>client_id end hostname ip mac pool remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf '' --sort $6</command>
Expand All @@ -166,7 +166,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start</list>
<list>client_id end hostname ip mac pool remaining start</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf '' --state $6 --sort $8</command>
Expand Down Expand Up @@ -256,7 +256,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start state</list>
<list>client_id end hostname ip mac pool remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf $5 --origin $8 --sort $10</command>
Expand All @@ -276,7 +276,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac remaining start state</list>
<list>client_id end hostname ip mac remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf $5 --pool $8 --sort $10</command>
Expand All @@ -287,7 +287,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start state</list>
<list>client_id end hostname ip mac pool remaining start state</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf $5 --sort $8</command>
Expand All @@ -305,7 +305,7 @@
<properties>
<help>Show DHCP server leases sorted by the specified key</help>
<completionHelp>
<list>end hostname ip mac pool remaining start</list>
<list>client_id end hostname ip mac pool remaining start</list>
</completionHelp>
</properties>
<command>${vyos_op_scripts_dir}/dhcp.py show_server_leases --family inet --vrf $5 --state $8 --sort $10</command>
Expand Down
9 changes: 9 additions & 0 deletions python/vyos/kea.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,15 @@ def kea_get_server_leases(

if inet == '4':
data_lease['start'] = lease['start_time'].timestamp()
# DHCPv4 option 61. Kea returns it already colon separated, so
# unlike the DHCPv6 DUID below it must not go through
# _format_hex_string() -- that would insert a second colon after
# every existing one.
#
# `or` rather than a get() default: Lease4::toElement() omits the
# key for a client that sent no option 61, but this way an empty
# string reads as '-' too, matching 'hostname' two lines above.
data_lease['client_id'] = lease.get('client-id') or '-'

if inet == '6':
data_lease['last_communication'] = lease['start_time'].timestamp()
Expand Down
16 changes: 15 additions & 1 deletion src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'backup',
]
sort_valid_inet = [
'client_id',
'end',
'mac',
'hostname',
Expand Down Expand Up @@ -111,8 +112,20 @@ def _get_formatted_server_leases(raw_data, family='inet'):
pool = lease.get('pool')
hostname = lease.get('hostname')
origin = lease.get('origin')
client_id = lease.get('client_id')
data_entries.append(
[ipaddr, hw_addr, state, start, end, remain, pool, hostname, origin]
[
ipaddr,
hw_addr,
state,
start,
end,
remain,
pool,
hostname,
origin,
client_id,
]
)

headers = [
Expand All @@ -125,6 +138,7 @@ def _get_formatted_server_leases(raw_data, family='inet'):
'Pool',
'Hostname',
'Origin',
'Client ID',
]

if family == 'inet6':
Expand Down
Loading