Skip to content

Commit

Permalink
Revert "fix missing sysinfo in config override"
Browse files Browse the repository at this point in the history
This reverts commit d9a2ef3.
  • Loading branch information
wen587 committed Apr 15, 2023
1 parent d9a2ef3 commit 2b21d11
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 110 deletions.
29 changes: 0 additions & 29 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1875,33 +1875,6 @@ def override_config_by(golden_config_path):
return


def generate_sysinfo(config_input, ns=None):
# Generate required sysinfo for Golden Config.
device_metadata = config_input.get('DEVICE_METADATA')

if not device_metadata or 'localhost' not in device_metadata:
return

if ns:
asic_role = device_metadata.get('localhost', {}).get('sub_role')
switch_type = device_metadata.get('localhost', {}).get('switch_type')

if ((switch_type is not None and switch_type.lower() == "chassis-packet") or
(asic_role is not None and asic_role.lower() == "backend")):
mac = device_info.get_system_mac(namespace=ns)
else:
mac = device_info.get_system_mac()
else:
mac = device_info.get_system_mac()

platform = device_info.get_platform()

device_metadata['localhost']['mac'] = mac
device_metadata['localhost']['platform'] = platform

return


#
# 'override-config-table' command ('config override-config-table ...')
#
Expand Down Expand Up @@ -1939,10 +1912,8 @@ def override_config_table(db, input_config_db, dry_run):

if multi_asic.is_multi_asic():
ns_config_input = config_input[ns]
generate_sysinfo(ns_config_input, ns)
else:
ns_config_input = config_input
generate_sysinfo(ns_config_input)
updated_config = update_config(current_config, ns_config_input)

yang_enabled = device_info.is_yang_config_validation_enabled(config_db)
Expand Down
55 changes: 0 additions & 55 deletions tests/config_override_input/multi_asic_dm_gen_sysinfo.json

This file was deleted.

26 changes: 0 additions & 26 deletions tests/config_override_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
FINAL_CONFIG_YANG_FAILURE = os.path.join(DATA_DIR, "final_config_yang_failure.json")
MULTI_ASIC_MACSEC_OV = os.path.join(DATA_DIR, "multi_asic_macsec_ov.json")
MULTI_ASIC_DEVICE_METADATA_RM = os.path.join(DATA_DIR, "multi_asic_dm_rm.json")
MULTI_ASIC_DEVICE_METADATA_GEN_SYSINFO = os.path.join(DATA_DIR, "multi_asic_dm_gen_sysinfo.json")

# Load sonic-cfggen from source since /usr/local/bin/sonic-cfggen does not have .py extension.
sonic_cfggen = load_module_from_source('sonic_cfggen', '/usr/local/bin/sonic-cfggen')
Expand Down Expand Up @@ -319,31 +318,6 @@ def read_json_file_side_effect(filename):
for ns, config_db in cfgdb_clients.items():
assert 'DEVICE_METADATA' not in config_db.get_config()

def test_device_metadata_gen_sysinfo(self):
def read_json_file_side_effect(filename):
with open(MULTI_ASIC_DEVICE_METADATA_GEN_SYSINFO, "r") as f:
device_metadata = json.load(f)
return device_metadata
db = Db()
cfgdb_clients = db.cfgdb_clients

with mock.patch('config.main.read_json_file',
mock.MagicMock(side_effect=read_json_file_side_effect)),\
mock.patch('sonic_py_common.device_info.get_platform',
return_value="multi_asic"),\
mock.patch('sonic_py_common.device_info.get_system_mac',
return_value="11:22:33:44:55:66"):
runner = CliRunner()
result = runner.invoke(config.config.commands["override-config-table"],
['golden_config_db.json'], obj=db)
assert result.exit_code == 0

for ns, config_db in cfgdb_clients.items():
platform = config_db.get_config()['DEVICE_METADATA']['localhost'].get('platform')
mac = config_db.get_config()['DEVICE_METADATA']['localhost'].get('mac')
assert platform == "multi_asic"
assert mac == "11:22:33:44:55:66"


@classmethod
def teardown_class(cls):
Expand Down

0 comments on commit 2b21d11

Please sign in to comment.