Skip to content

Commit 2d95529

Browse files
authored
Revert "Update load minigraph to load backend acl (#2236)" (#2735)
This reverts commit 1518ca9.
1 parent c869c97 commit 2d95529

File tree

2 files changed

+2
-84
lines changed

2 files changed

+2
-84
lines changed

config/main.py

+2-41
Original file line numberDiff line numberDiff line change
@@ -1162,41 +1162,6 @@ def validate_gre_type(ctx, _, value):
11621162
except ValueError:
11631163
raise click.UsageError("{} is not a valid GRE type".format(value))
11641164

1165-
def _is_storage_device(cfg_db):
1166-
"""
1167-
Check if the device is a storage device or not
1168-
"""
1169-
device_metadata = cfg_db.get_entry("DEVICE_METADATA", "localhost")
1170-
return device_metadata.get("storage_device", "Unknown") == "true"
1171-
1172-
def _is_acl_table_present(cfg_db, acl_table_name):
1173-
"""
1174-
Check if acl table exists
1175-
"""
1176-
return acl_table_name in cfg_db.get_keys("ACL_TABLE")
1177-
1178-
def load_backend_acl(cfg_db, device_type):
1179-
"""
1180-
Load acl on backend storage device
1181-
"""
1182-
1183-
BACKEND_ACL_TEMPLATE_FILE = os.path.join('/', "usr", "share", "sonic", "templates", "backend_acl.j2")
1184-
BACKEND_ACL_FILE = os.path.join('/', "etc", "sonic", "backend_acl.json")
1185-
1186-
if device_type and device_type == "BackEndToRRouter" and _is_storage_device(cfg_db) and _is_acl_table_present(cfg_db, "DATAACL"):
1187-
if os.path.isfile(BACKEND_ACL_TEMPLATE_FILE):
1188-
clicommon.run_command(
1189-
"{} -d -t {},{}".format(
1190-
SONIC_CFGGEN_PATH,
1191-
BACKEND_ACL_TEMPLATE_FILE,
1192-
BACKEND_ACL_FILE
1193-
),
1194-
display_cmd=True
1195-
)
1196-
if os.path.isfile(BACKEND_ACL_FILE):
1197-
clicommon.run_command("acl-loader update incremental {}".format(BACKEND_ACL_FILE), display_cmd=True)
1198-
1199-
12001165
# This is our main entrypoint - the main 'config' command
12011166
@click.group(cls=clicommon.AbbreviationGroup, context_settings=CONTEXT_SETTINGS)
12021167
@click.pass_context
@@ -1774,12 +1739,6 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
17741739
if os.path.isfile('/etc/sonic/acl.json'):
17751740
clicommon.run_command("acl-loader update full /etc/sonic/acl.json", display_cmd=True)
17761741

1777-
# get the device type
1778-
device_type = _get_device_type()
1779-
1780-
# Load backend acl
1781-
load_backend_acl(db.cfgdb, device_type)
1782-
17831742
# Load port_config.json
17841743
try:
17851744
load_port_config(db.cfgdb, '/etc/sonic/port_config.json')
@@ -1789,6 +1748,8 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
17891748
# generate QoS and Buffer configs
17901749
clicommon.run_command("config qos reload --no-dynamic-buffer --no-delay", display_cmd=True)
17911750

1751+
# get the device type
1752+
device_type = _get_device_type()
17921753
if device_type != 'MgmtToRRouter' and device_type != 'MgmtTsToR' and device_type != 'BmcMgmtToRRouter' and device_type != 'EPMS':
17931754
clicommon.run_command("pfcwd start_default", display_cmd=True)
17941755

tests/config_test.py

-43
Original file line numberDiff line numberDiff line change
@@ -354,49 +354,6 @@ def test_load_minigraph_with_port_config(self, get_cmd_module, setup_single_broa
354354
port_config = [{"PORT": {"Ethernet0": {"admin_status": "up"}}}]
355355
self.check_port_config(db, config, port_config, "config interface startup Ethernet0")
356356

357-
def test_load_backend_acl(self, get_cmd_module, setup_single_broadcom_asic):
358-
db = Db()
359-
db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"})
360-
self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=True)
361-
362-
def test_load_backend_acl_not_storage(self, get_cmd_module, setup_single_broadcom_asic):
363-
db = Db()
364-
self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=False)
365-
366-
def test_load_backend_acl_storage_leaf(self, get_cmd_module, setup_single_broadcom_asic):
367-
db = Db()
368-
db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"})
369-
self.check_backend_acl(get_cmd_module, db, device_type='BackEndLeafRouter', condition=False)
370-
371-
def test_load_backend_acl_storage_no_dataacl(self, get_cmd_module, setup_single_broadcom_asic):
372-
db = Db()
373-
db.cfgdb.set_entry("DEVICE_METADATA", "localhost", {"storage_device": "true"})
374-
db.cfgdb.set_entry("ACL_TABLE", "DATAACL", None)
375-
self.check_backend_acl(get_cmd_module, db, device_type='BackEndToRRouter', condition=False)
376-
377-
def check_backend_acl(self, get_cmd_module, db, device_type='BackEndToRRouter', condition=True):
378-
def is_file_side_effect(filename):
379-
return True if 'backend_acl' in filename else False
380-
with mock.patch('os.path.isfile', mock.MagicMock(side_effect=is_file_side_effect)):
381-
with mock.patch('config.main._get_device_type', mock.MagicMock(return_value=device_type)):
382-
with mock.patch(
383-
"utilities_common.cli.run_command",
384-
mock.MagicMock(side_effect=mock_run_command_side_effect)) as mock_run_command:
385-
(config, show) = get_cmd_module
386-
runner = CliRunner()
387-
result = runner.invoke(config.config.commands["load_minigraph"], ["-y"], obj=db)
388-
print(result.exit_code)
389-
expected_output = ['Running command: acl-loader update incremental /etc/sonic/backend_acl.json',
390-
'Running command: /usr/local/bin/sonic-cfggen -d -t /usr/share/sonic/templates/backend_acl.j2,/etc/sonic/backend_acl.json'
391-
]
392-
print(result.output)
393-
assert result.exit_code == 0
394-
output = result.output.split('\n')
395-
if condition:
396-
assert set(expected_output).issubset(set(output))
397-
else:
398-
assert not(set(expected_output).issubset(set(output)))
399-
400357
def check_port_config(self, db, config, port_config, expected_output):
401358
def read_json_file_side_effect(filename):
402359
return port_config

0 commit comments

Comments
 (0)