Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode format (backport #3733) #3741

Merged
merged 1 commit into from
Jun 30, 2024
Merged
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
39 changes: 39 additions & 0 deletions op-mode-definitions/dhcp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,43 @@
</node>
</children>
</node>
<node name="release">
<properties>
<help>Release specified variable</help>
</properties>
<children>
<node name="dhcp">
<properties>
<help>Release DHCP client lease</help>
</properties>
<children>
<tagNode name="interface">
<properties>
<help>Release DHCP client lease for specified interface</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>sudo ${vyos_op_scripts_dir}/dhcp.py release_client_lease --family inet --interface "$4"</command>
</tagNode>
</children>
</node>
<node name="dhcpv6">
<properties>
<help>Release DHCPv6 client lease</help>
</properties>
<children>
<tagNode name="interface">
<properties>
<help>Release DHCPv6 client lease for specified interface</help>
<completionHelp>
<script>${vyos_completion_dir}/list_interfaces</script>
</completionHelp>
</properties>
<command>sudo ${vyos_op_scripts_dir}/dhcp.py release_client_lease --family inet6 --interface "$4"</command>
</tagNode>
</children>
</node>
</children>
</node>
</interfaceDefinition>
10 changes: 10 additions & 0 deletions src/op_mode/dhcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@ def renew_client_lease(raw: bool, family: ArgFamily, interface: str):
else:
call(f'systemctl restart dhclient@{interface}.service')

@_verify_client
def release_client_lease(raw: bool, family: ArgFamily, interface: str):
if not raw:
v = 'v6' if family == 'inet6' else ''
print(f'Release DHCP{v} client on interface {interface}...')
if family == 'inet6':
call(f'systemctl stop dhcp6c@{interface}.service')
else:
call(f'systemctl stop dhclient@{interface}.service')

if __name__ == '__main__':
try:
res = vyos.opmode.run(sys.modules[__name__])
Expand Down
Loading