# 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 . # T5736: igmp: migrate "protocols igmp" to "protocols pim" from vyos.configtree import ConfigTree base = ['protocols', 'igmp'] pim_base = ['protocols', 'pim'] def migrate(config: ConfigTree) -> None: if not config.exists(base): # Nothing to do return for interface in config.list_nodes(base + ['interface']): base_igmp_iface = base + ['interface', interface] pim_base_iface = pim_base + ['interface', interface] # Create IGMP note under PIM interface if not config.exists(pim_base_iface + ['igmp']): config.set(pim_base_iface + ['igmp']) if config.exists(base_igmp_iface + ['join']): config.copy(base_igmp_iface + ['join'], pim_base_iface + ['igmp', 'join']) config.set_tag(pim_base_iface + ['igmp', 'join']) new_join_base = pim_base_iface + ['igmp', 'join'] for address in config.list_nodes(new_join_base): if config.exists(new_join_base + [address, 'source']): config.rename(new_join_base + [address, 'source'], 'source-address') if config.exists(base_igmp_iface + ['query-interval']): config.copy(base_igmp_iface + ['query-interval'], pim_base_iface + ['igmp', 'query-interval']) if config.exists(base_igmp_iface + ['query-max-response-time']): config.copy(base_igmp_iface + ['query-max-response-time'], pim_base_iface + ['igmp', 'query-max-response-time']) if config.exists(base_igmp_iface + ['version']): config.copy(base_igmp_iface + ['version'], pim_base_iface + ['igmp', 'version']) config.delete(base)