From a950059053f7394acfb453cc0d8194aa3dc721fa Mon Sep 17 00:00:00 2001 From: kumvijaya Date: Thu, 26 Sep 2024 11:31:07 +0530 Subject: T6732: added same as vyos 1x --- src/migration-scripts/lldp/0-to-1 | 31 +++++++++++++++++++++++++++++++ src/migration-scripts/lldp/1-to-2 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/migration-scripts/lldp/0-to-1 create mode 100644 src/migration-scripts/lldp/1-to-2 (limited to 'src/migration-scripts/lldp') diff --git a/src/migration-scripts/lldp/0-to-1 b/src/migration-scripts/lldp/0-to-1 new file mode 100644 index 0000000..c16e7e8 --- /dev/null +++ b/src/migration-scripts/lldp/0-to-1 @@ -0,0 +1,31 @@ +# Copyright 2020-2024 VyOS maintainers and contributors +# +# 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 . + +# Delete "set service lldp interface location civic-based" option +# as it was broken most of the time anyways + +from vyos.configtree import ConfigTree + +base = ['service', 'lldp', 'interface'] + +def migrate(config: ConfigTree) -> None: + if not config.exists(base): + # Nothing to do + return + + # Delete nodes with abandoned CLI syntax + for interface in config.list_nodes(base): + if config.exists(base + [interface, 'location', 'civic-based']): + config.delete(base + [interface, 'location', 'civic-based']) diff --git a/src/migration-scripts/lldp/1-to-2 b/src/migration-scripts/lldp/1-to-2 new file mode 100644 index 0000000..7f233a7 --- /dev/null +++ b/src/migration-scripts/lldp/1-to-2 @@ -0,0 +1,30 @@ +# Copyright 2023-2024 VyOS maintainers and contributors +# +# 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 . + +# T5855: migrate "set service lldp snmp enable" -> `set service lldp snmp" + +from vyos.configtree import ConfigTree + +base = ['service', 'lldp'] + +def migrate(config: ConfigTree) -> None: + if not config.exists(base): + # Nothing to do + return + + if config.exists(base + ['snmp']): + enabled = config.exists(base + ['snmp', 'enable']) + config.delete(base + ['snmp']) + if enabled: config.set(base + ['snmp']) -- cgit v1.2.3