Skip to content

Commit

Permalink
Merge pull request #3742 from vyos/mergify/bp/circinus/pr-3733
Browse files Browse the repository at this point in the history
op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode format (backport #3733)
  • Loading branch information
c-po authored Jun 29, 2024
2 parents 551dfa5 + e88c3f9 commit 869b5cd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions op-mode-definitions/dhcp.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,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 @@ -510,6 +510,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

0 comments on commit 869b5cd

Please sign in to comment.