diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-02-05 23:10:59 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-02-05 23:10:59 +0100 |
commit | d7a84dc144951f698ae17111ed50d6dbd2f65fe7 (patch) | |
tree | 3d1998a19ed20625d14335e817e55808c7ee3bf0 /src/migration-scripts/interfaces | |
parent | f55fe07dc1894e22eda522d65cb4b1364da16c38 (diff) | |
parent | 96d51fa69fbe072fe5c9e8efd4fa6a89d8a2771a (diff) | |
download | vyos-1x-d7a84dc144951f698ae17111ed50d6dbd2f65fe7.tar.gz vyos-1x-d7a84dc144951f698ae17111ed50d6dbd2f65fe7.zip |
Merge branch 't2450-vrf' of github.com:c-po/vyos-1x into current
* 't2450-vrf' of github.com:c-po/vyos-1x:
xml: add new common "interface-name" validator
xml: include: accel: add missing file include comments
smoketest: static: improve static route testing
route: static: T2450: provide full protocol support in XML and Python with new CLI
vrf: T2450: provide full protocol support in XML and Python with new CLI
migrator: ospf: T3267: cleanup empty interface "ip" nodes
Diffstat (limited to 'src/migration-scripts/interfaces')
-rwxr-xr-x | src/migration-scripts/interfaces/18-to-19 | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/migration-scripts/interfaces/18-to-19 b/src/migration-scripts/interfaces/18-to-19 index e24421c90..965b76a04 100755 --- a/src/migration-scripts/interfaces/18-to-19 +++ b/src/migration-scripts/interfaces/18-to-19 @@ -14,7 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from sys import exit, argv +from sys import argv +from sys import exit from vyos.configtree import ConfigTree if __name__ == '__main__': @@ -41,6 +42,11 @@ if __name__ == '__main__': config.copy(ip_ospf, ['protocols', 'ospf', 'interface', interface]) config.delete(ip_ospf) + # if "ip ospf" was the only setting, we can clean out the empty + # ip node afterwards + if len(config.list_nodes(ip_ospf[:-1])) == 0: + config.delete(ip_ospf[:-1]) + vif_path = ['interfaces', type, interface, 'vif'] if config.exists(vif_path): for vif in config.list_nodes(vif_path): @@ -51,6 +57,11 @@ if __name__ == '__main__': config.copy(vif_ospf_path, ['protocols', 'ospf', 'interface', f'{interface}.{vif}']) config.delete(vif_ospf_path) + # if "ip ospf" was the only setting, we can clean out the empty + # ip node afterwards + if len(config.list_nodes(vif_ospf_path[:-1])) == 0: + config.delete(vif_ospf_path[:-1]) + vif_s_path = ['interfaces', type, interface, 'vif-s'] if config.exists(vif_s_path): for vif_s in config.list_nodes(vif_s_path): @@ -70,8 +81,18 @@ if __name__ == '__main__': config.copy(vif_c_ospf_path, ['protocols', 'ospf', 'interface', f'{interface}.{vif_s}.{vif_c}']) config.delete(vif_c_ospf_path) + # if "ip ospf" was the only setting, we can clean out the empty + # ip node afterwards + if len(config.list_nodes(vif_c_ospf_path[:-1])) == 0: + config.delete(vif_c_ospf_path[:-1]) + config.delete(vif_s_ospf_path) + # if "ip ospf" was the only setting, we can clean out the empty + # ip node afterwards + if len(config.list_nodes(vif_s_ospf_path[:-1])) == 0: + config.delete(vif_s_ospf_path[:-1]) + try: with open(file_name, 'w') as f: f.write(config.to_string()) |