From 30945f39d6d1f0fdba34ce1c2d887a1a6823ecbe Mon Sep 17 00:00:00 2001
From: sarthurdev <965089+sarthurdev@users.noreply.github.com>
Date: Mon, 5 Sep 2022 14:43:08 +0200
Subject: zone-policy: T2199: Migrate zone-policy to firewall node
---
src/migration-scripts/firewall/7-to-8 | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
(limited to 'src/migration-scripts')
diff --git a/src/migration-scripts/firewall/7-to-8 b/src/migration-scripts/firewall/7-to-8
index 6929e20a5..ce527acf5 100755
--- a/src/migration-scripts/firewall/7-to-8
+++ b/src/migration-scripts/firewall/7-to-8
@@ -15,6 +15,7 @@
# along with this program. If not, see .
# T2199: Migrate interface firewall nodes to firewall interfaces name/ipv6-name
+# T2199: Migrate zone-policy to firewall node
import re
@@ -34,9 +35,10 @@ with open(file_name, 'r') as f:
config_file = f.read()
base = ['firewall']
+zone_base = ['zone-policy']
config = ConfigTree(config_file)
-if not config.exists(base):
+if not config.exists(base) and not config.exists(zone_base):
# Nothing to do
exit(0)
@@ -80,6 +82,14 @@ for iftype in config.list_nodes(['interfaces']):
for vifc in config.list_nodes(['interfaces', iftype, ifname, 'vif-s', vifs, 'vif-c']):
migrate_interface(config, iftype, ifname, vifs=vifs, vifc=vifc)
+if config.exists(zone_base + ['zone']):
+ config.set(['firewall', 'zone'])
+ config.set_tag(['firewall', 'zone'])
+
+ for zone in config.list_nodes(zone_base + ['zone']):
+ config.copy(zone_base + ['zone', zone], ['firewall', 'zone', zone])
+ config.delete(zone_base)
+
try:
with open(file_name, 'w') as f:
f.write(config.to_string())
--
cgit v1.2.3