Skip to content

Commit

Permalink
[acl_loader]: Add support for parsing input interface (sonic-net#386)
Browse files Browse the repository at this point in the history
If input_interface is set, it will be converted to IN_PORTS.

format:
"input-interface": {
  "interface-ref": {
    "config": {
      "interface": <interface_list>
    }
  }
}

It will be parsed and converted to:
"IN_PORTS": <interface_list>
as an attribute to the current ACL rule.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shuotian Cheng authored Nov 25, 2018
1 parent 46e03b7 commit 323bb0c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 323bb0c

Please sign in to comment.