diff options
author | Christian Breunig <christian@breunig.cc> | 2024-06-27 21:34:14 +0200 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-06-29 15:25:17 +0000 |
commit | 5a9ec0cdb08344c3de573de68e754c1bdc885088 (patch) | |
tree | 33f26ed4713804ef8000245c38576300d284a89f | |
parent | 679c474e22373d0801459c57fcde8c8c298fe21d (diff) | |
download | vyos-1x-5a9ec0cdb08344c3de573de68e754c1bdc885088.tar.gz vyos-1x-5a9ec0cdb08344c3de573de68e754c1bdc885088.zip |
op-mode: T6524: rewrite "release dhcp(v6) interface" to new op-mode format
(cherry picked from commit 5ade35255b3d8438aa6082fe56ae459d50cdc0a5)
-rw-r--r-- | op-mode-definitions/dhcp.xml.in | 39 | ||||
-rwxr-xr-x | src/op_mode/dhcp.py | 10 |
2 files changed, 49 insertions, 0 deletions
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 @@ </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 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__]) |