|
|
b8221b |
From b2c9302e8a4ad1ab7535a557b2f9c9aa49b49629 Mon Sep 17 00:00:00 2001
|
|
|
b8221b |
From: Eric Garver <eric@garver.life>
|
|
|
b8221b |
Date: Wed, 27 Oct 2021 11:09:39 -0400
|
|
|
b8221b |
Subject: [PATCH 43/50] fix(fw_config): zone: on rename remove then add
|
|
|
b8221b |
|
|
|
b8221b |
Remove the old object before creating the new one. This avoids issues
|
|
|
b8221b |
such as conflicting configuration in the objects that check_config() may
|
|
|
b8221b |
trip over.
|
|
|
b8221b |
|
|
|
b8221b |
(cherry picked from commit 3aec1dfe449d0bcb52884341770e4def0de27f56)
|
|
|
b8221b |
(cherry picked from commit a58b45d8ee3221309ec0c6f919c266b5cfc6f89a)
|
|
|
b8221b |
---
|
|
|
b8221b |
src/firewall/core/fw_config.py | 11 +++++++----
|
|
|
b8221b |
1 file changed, 7 insertions(+), 4 deletions(-)
|
|
|
b8221b |
|
|
|
b8221b |
diff --git a/src/firewall/core/fw_config.py b/src/firewall/core/fw_config.py
|
|
|
b8221b |
index 148ce1b4e32c..a97d0b23a6ac 100644
|
|
|
b8221b |
--- a/src/firewall/core/fw_config.py
|
|
|
b8221b |
+++ b/src/firewall/core/fw_config.py
|
|
|
b8221b |
@@ -984,13 +984,16 @@ class FirewallConfig(object):
|
|
|
b8221b |
|
|
|
b8221b |
def rename_zone(self, obj, name):
|
|
|
b8221b |
self.check_builtin_zone(obj)
|
|
|
b8221b |
- new_zone = self._copy_zone(obj, name)
|
|
|
b8221b |
+ obj_conf = obj.export_config_dict()
|
|
|
b8221b |
self._remove_zone(obj)
|
|
|
b8221b |
+ try:
|
|
|
b8221b |
+ new_zone = self.new_zone_dict(name, obj_conf)
|
|
|
b8221b |
+ except:
|
|
|
b8221b |
+ # re-add original if rename failed
|
|
|
b8221b |
+ self.new_zone_dict(obj.name, obj_conf)
|
|
|
b8221b |
+ raise
|
|
|
b8221b |
return new_zone
|
|
|
b8221b |
|
|
|
b8221b |
- def _copy_zone(self, obj, name):
|
|
|
b8221b |
- return self.new_zone_dict(name, obj.export_config_dict())
|
|
|
b8221b |
-
|
|
|
b8221b |
# policy objects
|
|
|
b8221b |
|
|
|
b8221b |
def get_policy_objects(self):
|
|
|
b8221b |
--
|
|
|
b8221b |
2.27.0
|
|
|
b8221b |
|