Skip to content

Commit e0333b5

Browse files
wen587yxieca
authored andcommitted
Revert "[config]config reload should generate sysinfo if missing (#2778)" (#2865)
This reverts commit 88ffb16.
1 parent e7eac6b commit e0333b5

File tree

2 files changed

+1
-73
lines changed

2 files changed

+1
-73
lines changed

config/main.py

-13
Original file line numberDiff line numberDiff line change
@@ -1465,19 +1465,6 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
14651465
click.echo("The config file {} doesn't exist".format(file))
14661466
continue
14671467

1468-
if file_format == 'config_db':
1469-
file_input = read_json_file(file)
1470-
1471-
platform = file_input.get("DEVICE_METADATA", {}).\
1472-
get("localhost", {}).get("platform")
1473-
mac = file_input.get("DEVICE_METADATA", {}).\
1474-
get("localhost", {}).get("mac")
1475-
1476-
if not platform or not mac:
1477-
log.log_warning("Input file does't have platform or mac. platform: {}, mac: {}"
1478-
.format(None if platform is None else platform, None if mac is None else mac))
1479-
load_sysinfo = True
1480-
14811468
if load_sysinfo:
14821469
try:
14831470
command = "{} -j {} -v DEVICE_METADATA.localhost.hwsku".format(SONIC_CFGGEN_PATH, file)

tests/config_test.py

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

522466
def test_reload_config(self, get_cmd_module, setup_single_broadcom_asic):
523-
self.add_sysinfo_to_cfg_file()
524467
with mock.patch(
525468
"utilities_common.cli.run_command",
526469
mock.MagicMock(side_effect=mock_run_command_side_effect)
@@ -540,7 +483,6 @@ def test_reload_config(self, get_cmd_module, setup_single_broadcom_asic):
540483
== RELOAD_CONFIG_DB_OUTPUT
541484

542485
def test_config_reload_disabled_service(self, get_cmd_module, setup_single_broadcom_asic):
543-
self.add_sysinfo_to_cfg_file()
544486
with mock.patch(
545487
"utilities_common.cli.run_command",
546488
mock.MagicMock(side_effect=mock_run_command_side_effect_disabled_timer)
@@ -560,7 +502,6 @@ def test_config_reload_disabled_service(self, get_cmd_module, setup_single_broad
560502
assert "\n".join([l.rstrip() for l in result.output.split('\n')]) == reload_config_with_disabled_service_output
561503

562504
def test_reload_config_masic(self, get_cmd_module, setup_multi_broadcom_masic):
563-
self.add_sysinfo_to_cfg_file()
564505
with mock.patch(
565506
"utilities_common.cli.run_command",
566507
mock.MagicMock(side_effect=mock_run_command_side_effect)

0 commit comments

Comments
 (0)