From f5efe8939530ba9767bcd92e5a688b2275c5f151 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Tue, 20 Apr 2021 10:29:23 -0700 Subject: [PATCH] [acl] Use a list instead of a comma-separated string for ACL port list (#1519) Signed-off-by: Danny Allen --- config/main.py | 4 ++-- tests/acl_config_test.py | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/config/main.py b/config/main.py index e5a3cf6d0fa4..44bf799287f9 100644 --- a/config/main.py +++ b/config/main.py @@ -3339,7 +3339,7 @@ def parse_acl_table_info(table_name, table_type, description, ports, stage): if ports: for port in ports.split(","): port_list += expand_vlan_ports(port) - port_list = set(port_list) + port_list = list(set(port_list)) # convert to set first to remove duplicate ifaces else: port_list = valid_acl_ports @@ -3347,7 +3347,7 @@ def parse_acl_table_info(table_name, table_type, description, ports, stage): if port not in valid_acl_ports: raise ValueError("Cannot bind ACL to specified port {}".format(port)) - table_info["ports@"] = ",".join(port_list) + table_info["ports"] = port_list table_info["stage"] = stage diff --git a/tests/acl_config_test.py b/tests/acl_config_test.py index 63f92b787be1..ff397e760d98 100644 --- a/tests/acl_config_test.py +++ b/tests/acl_config_test.py @@ -25,9 +25,7 @@ def test_parse_table_with_vlan_expansion(self): assert table_info["type"] == "L3" assert table_info["policy_desc"] == "TEST" assert table_info["stage"] == "egress" - - port_list = table_info["ports@"].split(",") - assert set(port_list) == {"Ethernet4", "Ethernet8", "Ethernet12", "Ethernet16"} + assert set(table_info["ports"]) == {"Ethernet4", "Ethernet8", "Ethernet12", "Ethernet16"} def test_parse_table_with_vlan_and_duplicates(self): table_info = parse_acl_table_info("TEST", "L3", None, "Ethernet4,Vlan1000", "egress") @@ -36,9 +34,9 @@ def test_parse_table_with_vlan_and_duplicates(self): assert table_info["stage"] == "egress" # Since Ethernet4 is a member of Vlan1000 we should not include it twice in the output - port_list = table_info["ports@"].split(",") - assert len(port_list) == 4 - assert set(port_list) == {"Ethernet4", "Ethernet8", "Ethernet12", "Ethernet16"} + port_set = set(table_info["ports"]) + assert len(port_set) == 4 + assert set(port_set) == {"Ethernet4", "Ethernet8", "Ethernet12", "Ethernet16"} def test_parse_table_with_empty_vlan(self): with pytest.raises(ValueError):