Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-cli-gen] fix failure "Error: digits_class" when field "digit_c… #2054

Merged
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
2 changes: 1 addition & 1 deletion sonic-utilities-data/templates/sonic-cli-gen/config.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def update_entry_validated(db, table, key, data, create_if_not_exists=False):

entry_changed = False
for attr, value in data.items():
if value == cfg[table][key][attr]:
if value == cfg[table][key].get(attr):
continue
entry_changed = True
if value is None:
Expand Down
12 changes: 6 additions & 6 deletions tests/cli_autogen_input/autogen_test/show_cmd_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@


show_device_metadata_localhost="""\
HWSKU DEFAULT BGP STATUS DOCKER ROUTING CONFIG MODE HOSTNAME PLATFORM MAC DEFAULT PFCWD STATUS BGP ASN DEPLOYMENT ID TYPE BUFFER MODEL FRR MGMT FRAMEWORK CONFIG
----------- -------------------- ---------------------------- ---------- ---------------------- ----------------- ---------------------- --------- --------------- --------- -------------- ---------------------------
ACS-MSN2100 up N/A r-sonic-01 x86_64-mlnx_msn2100-r0 ff:ff:ff:ff:ff:00 disable N/A N/A ToRRouter traditional N/A
HWSKU DEFAULT BGP STATUS DOCKER ROUTING CONFIG MODE HOSTNAME PLATFORM MAC DEFAULT PFCWD STATUS BGP ASN DEPLOYMENT ID NON EXISTING FIELD TYPE BUFFER MODEL FRR MGMT FRAMEWORK CONFIG
----------- -------------------- ---------------------------- ---------- ---------------------- ----------------- ---------------------- --------- --------------- -------------------- --------- -------------- ---------------------------
ACS-MSN2100 up N/A r-sonic-01 x86_64-mlnx_msn2100-r0 ff:ff:ff:ff:ff:00 disable N/A N/A N/A ToRRouter traditional N/A
"""


show_device_metadata_localhost_changed_buffer_model="""\
HWSKU DEFAULT BGP STATUS DOCKER ROUTING CONFIG MODE HOSTNAME PLATFORM MAC DEFAULT PFCWD STATUS BGP ASN DEPLOYMENT ID TYPE BUFFER MODEL FRR MGMT FRAMEWORK CONFIG
----------- -------------------- ---------------------------- ---------- ---------------------- ----------------- ---------------------- --------- --------------- --------- -------------- ---------------------------
ACS-MSN2100 up N/A r-sonic-01 x86_64-mlnx_msn2100-r0 ff:ff:ff:ff:ff:00 disable N/A N/A ToRRouter dynamic N/A
HWSKU DEFAULT BGP STATUS DOCKER ROUTING CONFIG MODE HOSTNAME PLATFORM MAC DEFAULT PFCWD STATUS BGP ASN DEPLOYMENT ID NON EXISTING FIELD TYPE BUFFER MODEL FRR MGMT FRAMEWORK CONFIG
----------- -------------------- ---------------------------- ---------- ---------------------- ----------------- ---------------------- --------- --------------- -------------------- --------- -------------- ---------------------------
ACS-MSN2100 up N/A r-sonic-01 x86_64-mlnx_msn2100-r0 ff:ff:ff:ff:ff:00 disable N/A N/A N/A ToRRouter dynamic N/A
"""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ module sonic-device_metadata {
type uint32;
}

leaf non_existing_field {
type uint32;
}

leaf type {
type string {
length 1..255;
Expand Down
12 changes: 12 additions & 0 deletions tests/cli_autogen_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ def test_config_device_metadata(self):
assert result.exit_code == SUCCESS
assert result.output == show_cmd_output.show_device_metadata_localhost_changed_buffer_model

def test_config_device_metadata_non_existing_field(self):
dbconnector.dedicated_dbs['CONFIG_DB'] = mock_db_path
db = Db()
runner = CliRunner()

result = runner.invoke(
config_main.config.commands['device-metadata'].commands['localhost'].commands['non-existing-field'], ['12'], obj=db
)

logger.debug("\n" + result.output)
logger.debug(result.exit_code)
assert result.exit_code == SUCCESS

@pytest.mark.parametrize("parameter,value", [
('default-bgp-status', INVALID_VALUE),
Expand Down