diff options
author | Christian Breunig <christian@breunig.cc> | 2024-08-12 22:24:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-12 22:24:37 +0200 |
commit | a21b795180b98f264468c30a33da83cc56bfe21d (patch) | |
tree | a21abb8630b1bb2b8bd9187c20ebd96145e3bb93 | |
parent | 709bbddb3ee710c45284a8927b15889811ccb0fd (diff) | |
parent | a2b6098e6f9c1915a61a9aebc8f9852bd897387c (diff) | |
download | vyos-1x-a21b795180b98f264468c30a33da83cc56bfe21d.tar.gz vyos-1x-a21b795180b98f264468c30a33da83cc56bfe21d.zip |
Merge pull request #3970 from lucasec/t6648
T6648: dhcpv6-server: align stateless DHCPv6 options with stateful
-rw-r--r-- | interface-definitions/include/dhcp/option-v6.xml.i | 12 | ||||
-rw-r--r-- | interface-definitions/include/version/dhcpv6-server-version.xml.i | 2 | ||||
-rw-r--r-- | interface-definitions/service_dhcpv6-server.xml.in | 22 | ||||
-rw-r--r-- | python/vyos/template.py | 4 | ||||
-rw-r--r-- | src/migration-scripts/dhcpv6-server/5-to-6 | 31 |
5 files changed, 47 insertions, 24 deletions
diff --git a/interface-definitions/include/dhcp/option-v6.xml.i b/interface-definitions/include/dhcp/option-v6.xml.i index 1df0c3934..e1897f52d 100644 --- a/interface-definitions/include/dhcp/option-v6.xml.i +++ b/interface-definitions/include/dhcp/option-v6.xml.i @@ -78,6 +78,18 @@ <multi/> </properties> </leafNode> + <leafNode name="info-refresh-time"> + <properties> + <help>Time (in seconds) that stateless clients should wait between refreshing the information they were given</help> + <valueHelp> + <format>u32:1-4294967295</format> + <description>DHCPv6 information refresh time</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-4294967295"/> + </constraint> + </properties> + </leafNode> <node name="vendor-option"> <properties> <help>Vendor Specific Options</help> diff --git a/interface-definitions/include/version/dhcpv6-server-version.xml.i b/interface-definitions/include/version/dhcpv6-server-version.xml.i index 1f30368a3..8b72a9c72 100644 --- a/interface-definitions/include/version/dhcpv6-server-version.xml.i +++ b/interface-definitions/include/version/dhcpv6-server-version.xml.i @@ -1,3 +1,3 @@ <!-- include start from include/version/dhcpv6-server-version.xml.i --> -<syntaxVersion component='dhcpv6-server' version='5'></syntaxVersion> +<syntaxVersion component='dhcpv6-server' version='6'></syntaxVersion> <!-- include end --> diff --git a/interface-definitions/service_dhcpv6-server.xml.in b/interface-definitions/service_dhcpv6-server.xml.in index daca7b43f..cf14388e8 100644 --- a/interface-definitions/service_dhcpv6-server.xml.in +++ b/interface-definitions/service_dhcpv6-server.xml.in @@ -63,27 +63,7 @@ </constraint> </properties> </leafNode> - <node name="common-options"> - <properties> - <help>Common options to distribute to all clients, including stateless clients</help> - </properties> - <children> - <leafNode name="info-refresh-time"> - <properties> - <help>Time (in seconds) that stateless clients should wait between refreshing the information they were given</help> - <valueHelp> - <format>u32:1-4294967295</format> - <description>DHCPv6 information refresh time</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-4294967295"/> - </constraint> - </properties> - </leafNode> - #include <include/dhcp/domain-search.xml.i> - #include <include/name-server-ipv6.xml.i> - </children> - </node> + #include <include/dhcp/option-v6.xml.i> <tagNode name="subnet"> <properties> <help>IPv6 DHCP subnet for this shared network</help> diff --git a/python/vyos/template.py b/python/vyos/template.py index 3507e0940..aa99bed5a 100644 --- a/python/vyos/template.py +++ b/python/vyos/template.py @@ -922,8 +922,8 @@ def kea6_shared_network_json(shared_networks): 'subnet6': [] } - if 'common_options' in config: - network['option-data'] = kea6_parse_options(config['common_options']) + if 'option' in config: + network['option-data'] = kea6_parse_options(config['option']) if 'interface' in config: network['interface'] = config['interface'] diff --git a/src/migration-scripts/dhcpv6-server/5-to-6 b/src/migration-scripts/dhcpv6-server/5-to-6 new file mode 100644 index 000000000..cad0a3538 --- /dev/null +++ b/src/migration-scripts/dhcpv6-server/5-to-6 @@ -0,0 +1,31 @@ +# Copyright 2024 VyOS maintainers and contributors <maintainers@vyos.io> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see <http://www.gnu.org/licenses/>. + +# T6648: Rename "common-options" to "option" at shared-network level + +from vyos.configtree import ConfigTree + +base = ['service', 'dhcpv6-server', 'shared-network-name'] + +def migrate(config: ConfigTree) -> None: + if not config.exists(base): + # Nothing to do + return + + for network in config.list_nodes(base): + if not config.exists(base + [network, 'common-options']): + continue + + config.rename(base + [network, 'common-options'], 'option') |