summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-06-27 21:34:14 +0200
committerChristian Breunig <christian@breunig.cc>2024-06-27 21:34:14 +0200
commit5ade35255b3d8438aa6082fe56ae459d50cdc0a5 (patch)
treefb01390cd67d4dbb25b4697c19efde4774c16535
parent7d91768a746a000bf26d737eb1612536d0454ad1 (diff)
downloadvyos-1x-5ade35255b3d8438aa6082fe56ae459d50cdc0a5.tar.gz
vyos-1x-5ade35255b3d8438aa6082fe56ae459d50cdc0a5.zip
op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode format
-rw-r--r--op-mode-definitions/dhcp.xml.in39
-rwxr-xr-xsrc/op_mode/dhcp.py10
2 files changed, 49 insertions, 0 deletions
diff --git a/op-mode-definitions/dhcp.xml.in b/op-mode-definitions/dhcp.xml.in
index 0b4a05ffe..eee6937d6 100644
--- a/op-mode-definitions/dhcp.xml.in
+++ b/op-mode-definitions/dhcp.xml.in
@@ -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>
diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py
index f6029c748..6f57f22a5 100755
--- a/src/op_mode/dhcp.py
+++ b/src/op_mode/dhcp.py
@@ -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__])