From ef19aedcd200b0d00a715cc0696c506062a793e6 Mon Sep 17 00:00:00 2001
From: hajipour <shajipour@cttc.es>
Date: Tue, 12 Mar 2024 14:45:51 +0000
Subject: [PATCH] enabling ipv4 ingress filter for acl support xml in
 ipinfusion added to acl recipe and xml renderer changed to jinja2

---
 .../service/drivers/openconfig/OpenConfigDriver.py       | 6 +++---
 .../service/drivers/openconfig/templates/__init__.py     | 4 ++++
 .../acl/interfaces/ingress/enable_ingress_filter.xml     | 9 +++++++++
 3 files changed, 16 insertions(+), 3 deletions(-)
 create mode 100644 src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/enable_ingress_filter.xml

diff --git a/src/device/service/drivers/openconfig/OpenConfigDriver.py b/src/device/service/drivers/openconfig/OpenConfigDriver.py
index 99ae1c8db..793b292c7 100644
--- a/src/device/service/drivers/openconfig/OpenConfigDriver.py
+++ b/src/device/service/drivers/openconfig/OpenConfigDriver.py
@@ -227,10 +227,10 @@ def edit_config(
                 resource_key,resource_value = resource
                 chk_string(str_resource_name + '.key', resource_key, allow_empty=False)
 
-                str_config_messages = compose_config(                                                                          # get template for configuration
-                    resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer='pyangbind')
                 # str_config_messages = compose_config(                                                                          # get template for configuration
-                #     resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer)
+                #     resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer='pyangbind')
+                str_config_messages = compose_config(                                                                          # get template for configuration
+                    resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer)
                 for str_config_message in str_config_messages:                                                                 # configuration of the received templates 
                     if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
                     logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format(
diff --git a/src/device/service/drivers/openconfig/templates/__init__.py b/src/device/service/drivers/openconfig/templates/__init__.py
index dcd3cf683..8df8fa28f 100644
--- a/src/device/service/drivers/openconfig/templates/__init__.py
+++ b/src/device/service/drivers/openconfig/templates/__init__.py
@@ -118,17 +118,21 @@ def compose_config( # template generation
         templates =[]
         if "acl_ruleset" in resource_key:                                               # MANAGING ACLs
             if True: #vendor == 'ipinfusion': #! ipinfusion proprietary netconf receipe is used temporarily
+                enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml'
                 acl_entry_path = 'acl/acl-set/acl-entry/edit_config_ipinfusion_proprietary.xml'
                 acl_ingress_path = 'acl/interfaces/ingress/edit_config_ipinfusion_proprietary.xml'
                 data : Dict[str, Any] = acl_cr_to_dict_ipinfusion_proprietary(resource_value, delete=delete)
             else:
+                enable_ingress_filter_path = 'acl/interfaces/ingress/enable_ingress_filter.xml'
                 acl_entry_path = 'acl/acl-set/acl-entry/edit_config.xml'
                 acl_ingress_path = 'acl/interfaces/ingress/edit_config.xml'
                 data : Dict[str, Any] = acl_cr_to_dict(resource_value, delete=delete)
             if delete: # unpair acl and interface before removing acl
                 templates.append(JINJA_ENV.get_template(acl_ingress_path))
                 templates.append(JINJA_ENV.get_template(acl_entry_path))
+                templates.append(JINJA_ENV.get_template(enable_ingress_filter_path))
             else:
+                templates.append(JINJA_ENV.get_template(enable_ingress_filter_path))
                 templates.append(JINJA_ENV.get_template(acl_entry_path))
                 templates.append(JINJA_ENV.get_template(acl_ingress_path))
         else:
diff --git a/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/enable_ingress_filter.xml b/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/enable_ingress_filter.xml
new file mode 100644
index 000000000..274028657
--- /dev/null
+++ b/src/device/service/drivers/openconfig/templates/acl/interfaces/ingress/enable_ingress_filter.xml
@@ -0,0 +1,9 @@
+<profiles xmlns="http://www.ipinfusion.com/yang/ocnos/ipi-platform"> 
+	<hardware-profile> 
+	<filters> 
+	<config> 
+		<ingress-ipv4-extended {% if operation == "delete" %}operation="delete"{% endif %}></ingress-ipv4-extended>
+	</config> 
+	</filters> 
+	</hardware-profile> 
+</profiles>
\ No newline at end of file
-- 
GitLab