# Copyright (C) VyOS Inc. # # 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 . # T9606: "parameters rfc1583-compatibility" moves to "compatible rfc1583", # matching FRR's "compatible" command family. from vyos.configtree import ConfigTree def compatible_migration(config: ConfigTree, ospf_base: list) -> None: if not config.exists(ospf_base): return parameters = ospf_base + ['parameters'] if config.exists(parameters + ['rfc1583-compatibility']): config.delete(parameters + ['rfc1583-compatibility']) # do not leave an empty "parameters" node behind if config.list_nodes(parameters) == []: config.delete(parameters) config.set(ospf_base + ['compatible', 'rfc1583']) def migrate(config: ConfigTree) -> None: # OSPF in the default VRF compatible_migration(config, ['protocols', 'ospf']) # OSPF in every VRF if config.exists(['vrf', 'name']): for name in config.list_nodes(['vrf', 'name']): compatible_migration(config, ['vrf', 'name', name, 'protocols', 'ospf'])