From 323bb0c87cbf6552c9f4699c530bf43338172e9a Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Sat, 24 Nov 2018 20:43:12 -0800 Subject: [PATCH] [acl_loader]: Add support for parsing input interface (#386) If input_interface is set, it will be converted to IN_PORTS. format: "input-interface": { "interface-ref": { "config": { "interface": } } } It will be parsed and converted to: "IN_PORTS": as an attribute to the current ACL rule. Signed-off-by: Shu0T1an ChenG --- acl_loader/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/acl_loader/main.py b/acl_loader/main.py index fd8e70832b03..41aa937cf0d7 100644 --- a/acl_loader/main.py +++ b/acl_loader/main.py @@ -305,7 +305,7 @@ def convert_port(self, port): else: return port, False - def convert_transport(self, table_name, rule_idx, rule): + def convert_transport(self, table_name, rule_idx, rule): rule_props = {} if rule.transport.config.source_port: @@ -340,6 +340,14 @@ def convert_transport(self, table_name, rule_idx, rule): return rule_props + def convert_input_interface(self, table_name, rule_idx, rule): + rule_props = {} + + if rule.input_interface.interface_ref.config.interface: + rule_props["IN_PORTS"] = rule.input_interface.interface_ref.config.interface + + return rule_props + def convert_rule_to_db_schema(self, table_name, rule): """ Convert rules format from openconfig ACL to Config DB schema @@ -357,6 +365,7 @@ def convert_rule_to_db_schema(self, table_name, rule): deep_update(rule_props, self.convert_l2(table_name, rule_idx, rule)) deep_update(rule_props, self.convert_ip(table_name, rule_idx, rule)) deep_update(rule_props, self.convert_transport(table_name, rule_idx, rule)) + deep_update(rule_props, self.convert_input_interface(table_name, rule_idx, rule)) return rule_data