From 5a9ec0cdb08344c3de573de68e754c1bdc885088 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Thu, 27 Jun 2024 21:34:14 +0200 Subject: op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode format (cherry picked from commit 5ade35255b3d8438aa6082fe56ae459d50cdc0a5) --- op-mode-definitions/dhcp.xml.in | 39 +++++++++++++++++++++++++++++++++++++++ src/op_mode/dhcp.py | 10 ++++++++++ 2 files changed, 49 insertions(+) diff --git a/op-mode-definitions/dhcp.xml.in b/op-mode-definitions/dhcp.xml.in index 6114142f0..027072261 100644 --- a/op-mode-definitions/dhcp.xml.in +++ b/op-mode-definitions/dhcp.xml.in @@ -233,4 +233,43 @@ + + + Release specified variable + + + + + Release DHCP client lease + + + + + Release DHCP client lease for specified interface + + + + + sudo ${vyos_op_scripts_dir}/dhcp.py release_client_lease --family inet --interface "$4" + + + + + + Release DHCPv6 client lease + + + + + Release DHCPv6 client lease for specified interface + + + + + sudo ${vyos_op_scripts_dir}/dhcp.py release_client_lease --family inet6 --interface "$4" + + + + + diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py index 3229da4ad..dffd99de5 100755 --- a/src/op_mode/dhcp.py +++ b/src/op_mode/dhcp.py @@ -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__]) -- cgit v1.2.3