Skip to content

Commit f126846

Browse files
committed
Revert "[config]config reload should generate sysinfo if missing (sonic-net#2778)"
This reverts commit 88ffb16.
1 parent b5c1032 commit f126846

2 files changed

Lines changed: 1 addition & 73 deletions

File tree

config/main.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,19 +1538,6 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
15381538
click.echo("The config file {} doesn't exist".format(file))
15391539
continue
15401540

1541-
if file_format == 'config_db':
1542-
file_input = read_json_file(file)
1543-
1544-
platform = file_input.get("DEVICE_METADATA", {}).\
1545-
get("localhost", {}).get("platform")
1546-
mac = file_input.get("DEVICE_METADATA", {}).\
1547-
get("localhost", {}).get("mac")
1548-
1549-
if not platform or not mac:
1550-
log.log_warning("Input file does't have platform or mac. platform: {}, mac: {}"
1551-
.format(None if platform is None else platform, None if mac is None else mac))
1552-
load_sysinfo = True
1553-
15541541
if load_sysinfo:
15551542
try:
15561543
command = [SONIC_CFGGEN_PATH, "-j", file, '-v', "DEVICE_METADATA.localhost.hwsku"]

tests/config_test.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -451,66 +451,9 @@ def setup_class(cls):
451451
print("SETUP")
452452
import config.main
453453
importlib.reload(config.main)
454-
455-
def add_sysinfo_to_cfg_file(self):
456-
with open(self.dummy_cfg_file, 'w') as f:
457-
device_metadata = {
458-
"DEVICE_METADATA": {
459-
"localhost": {
460-
"platform": "some_platform",
461-
"mac": "02:42:f0:7f:01:05"
462-
}
463-
}
464-
}
465-
f.write(json.dumps(device_metadata))
466-
467-
def test_reload_config_invalid_input(self, get_cmd_module, setup_single_broadcom_asic):
468-
open(self.dummy_cfg_file, 'w').close()
469-
with mock.patch(
470-
"utilities_common.cli.run_command",
471-
mock.MagicMock(side_effect=mock_run_command_side_effect)
472-
) as mock_run_command:
473-
(config, show) = get_cmd_module
474-
runner = CliRunner()
475-
476-
result = runner.invoke(
477-
config.config.commands["reload"],
478-
[self.dummy_cfg_file, '-y', '-f'])
479-
480-
print(result.exit_code)
481-
print(result.output)
482-
traceback.print_tb(result.exc_info[2])
483-
assert result.exit_code != 0
484-
485-
def test_reload_config_no_sysinfo(self, get_cmd_module, setup_single_broadcom_asic):
486-
with open(self.dummy_cfg_file, 'w') as f:
487-
device_metadata = {
488-
"DEVICE_METADATA": {
489-
"localhost": {
490-
"hwsku": "some_hwsku"
491-
}
492-
}
493-
}
494-
f.write(json.dumps(device_metadata))
495-
496-
with mock.patch(
497-
"utilities_common.cli.run_command",
498-
mock.MagicMock(side_effect=mock_run_command_side_effect)
499-
) as mock_run_command:
500-
(config, show) = get_cmd_module
501-
runner = CliRunner()
502-
503-
result = runner.invoke(
504-
config.config.commands["reload"],
505-
[self.dummy_cfg_file, '-y', '-f'])
506-
507-
print(result.exit_code)
508-
print(result.output)
509-
traceback.print_tb(result.exc_info[2])
510-
assert result.exit_code == 0
454+
open(cls.dummy_cfg_file, 'w').close()
511455

512456
def test_reload_config(self, get_cmd_module, setup_single_broadcom_asic):
513-
self.add_sysinfo_to_cfg_file()
514457
with mock.patch(
515458
"utilities_common.cli.run_command",
516459
mock.MagicMock(side_effect=mock_run_command_side_effect)
@@ -530,7 +473,6 @@ def test_reload_config(self, get_cmd_module, setup_single_broadcom_asic):
530473
== RELOAD_CONFIG_DB_OUTPUT
531474

532475
def test_config_reload_disabled_service(self, get_cmd_module, setup_single_broadcom_asic):
533-
self.add_sysinfo_to_cfg_file()
534476
with mock.patch(
535477
"utilities_common.cli.run_command",
536478
mock.MagicMock(side_effect=mock_run_command_side_effect_disabled_timer)
@@ -550,7 +492,6 @@ def test_config_reload_disabled_service(self, get_cmd_module, setup_single_broad
550492
assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == reload_config_with_disabled_service_output
551493

552494
def test_reload_config_masic(self, get_cmd_module, setup_multi_broadcom_masic):
553-
self.add_sysinfo_to_cfg_file()
554495
with mock.patch(
555496
"utilities_common.cli.run_command",
556497
mock.MagicMock(side_effect=mock_run_command_side_effect)

0 commit comments

Comments
 (0)