Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion acl_loader/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,31 @@ def read_tables_info(self):
Read ACL_TABLE table from configuration database
:return:
"""
self.tables_db_info = self.configdb.get_table(self.ACL_TABLE)
# get the acl table info from host config_db
host_acl_table = self.configdb.get_table(self.ACL_TABLE)
# For multi asic get only the control plane acls from the host config_db
if self.per_npu_configdb:
for table, entry in host_acl_table.items():
if entry.get('type', None) != self.ACL_TABLE_TYPE_CTRLPLANE:
continue

self.tables_db_info[table] = entry
else:
self.tables_db_info.update(host_acl_table)

# for DATAACL, EVERFLOW acls.
# update the ports from all the namespaces
if self.per_npu_configdb:
for ns, config_db in self.per_npu_configdb.items():
acl_table = config_db.get_table(self.ACL_TABLE)
for table, entry in acl_table.items():
if entry.get('type', None) == self.ACL_TABLE_TYPE_CTRLPLANE:
continue
if table not in self.tables_db_info:
self.tables_db_info[table] = entry
else:
self.tables_db_info[table]['ports'] += entry.get(
'ports', [])

def get_tables_db_info(self):
return self.tables_db_info
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/asic2/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
},
"ACL_TABLE|DATAACL_5": {
"policy_desc": "DATAACL_5",
"ports@": "Ethernet124",
"ports@": "Ethernet20",
"type": "L3",
"stage": "ingress"
}
Expand Down
10 changes: 6 additions & 4 deletions tests/show_acl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
modules_path = os.path.dirname(root_path)
scripts_path = os.path.join(modules_path, "scripts")

MASIC_SHOW_ACL_OUTPUT = """Name Type Binding Description Stage Status
--------- ------ ----------- ------------- ------- --------------------------------------
DATAACL_5 L3 Ethernet20 DATAACL_5 ingress {'asic0': 'Active', 'asic2': 'Active'}
Ethernet124
"""

@pytest.fixture()
def setup_teardown_single_asic():
Expand Down Expand Up @@ -74,10 +79,7 @@ def test_show_acl_table(self, setup_teardown_multi_asic):
}
result = runner.invoke(acl_loader_show.cli.commands['show'].commands['table'], ['DATAACL_5'], obj=context)
assert result.exit_code == 0
# We only care about the third line, which contains the 'Active'
result_top = result.output.split('\n')[2]
expected_output = "DATAACL_5 L3 Ethernet124 DATAACL_5 ingress {'asic0': 'Active', 'asic2': 'Active'}"
assert result_top == expected_output
assert result.output == MASIC_SHOW_ACL_OUTPUT

def test_show_acl_rule(self, setup_teardown_multi_asic):
runner = CliRunner()
Expand Down