Generate warning instead of Exception if CTNMaxCount is exceeded for a confnode
--- a/ConfigTreeNode.py Sat Feb 04 07:19:52 2023 +0800
+++ b/ConfigTreeNode.py Mon Feb 06 20:07:51 2023 +0800
@@ -558,9 +558,12 @@
ChildrenWithSameClass = self.Children.setdefault(CTNType, list())
# Check count
if getattr(CTNClass, "CTNMaxCount", None) and len(ChildrenWithSameClass) >= CTNClass.CTNMaxCount:
- raise Exception(
- _("Max count ({a1}) reached for this confnode of type {a2} ").
- format(a1=CTNClass.CTNMaxCount, a2=CTNType))
+
+ msg = _("Max count ({a1}) reached for this confnode of type {a2} ").format(
+ a1=CTNClass.CTNMaxCount, a2=CTNType)
+ self.GetCTRoot().logger.write_warning(msg)
+
+ return None
# create the final class, derived of provided confnode and template
class FinalCTNClass(CTNClass, ConfigTreeNode):