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

Exposing config-check logic to CLI #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rodnymolina
Copy link
Contributor

I'm simply extending the new config verification logic to our current CLI commands so that a config-check is implicitly done whenever user executes 'config load/reload' commands. See some examples below...

As part of this PR i'm also adding a new CLI command to allow users to explicitly validate their json-file configuration.

<-- Running 'config load' with invalid configuration:

admin@lnos-x1-a-csw02:~$ sudo config load ~/config_db.json
Reload all config? [y/N]: y
Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config reload' with invalid configuration:

admin@lnos-x1-a-csw02:~$ sudo config reload ~/config_db.json
Clear current and reload all config? [y/N]: y
Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config check' with invalid configuration:

admin@lnos-x1-a-csw02:~$ sudo config check ~/config_db.json
Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config check' with valid configuration:

admin@lnos-x1-a-csw02:~$ sudo config check /etc/sonic/config_db.json
Running command: sonic-cfggen -j /etc/sonic/config_db.json --check-json
Valid configuration found in /etc/sonic/config_db.json file

Signed-off-by: Rodny Molina rmolina@linkedin.com

I'm simply extending the new config verification logic to our current CLI commands so that a config-check is implicitly done whenever user executes 'config load/reload' commands. See some examples below...

As part of this PR i'm also adding a new CLI command to allow users to explicitly validate their json-file configuration.

<-- Running 'config load' with invalid configuration:

    admin@lnos-x1-a-csw02:~$ sudo config load ~/config_db.json
    Reload all config? [y/N]: y
    Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
    DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

    Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config reload' with invalid configuration:

    admin@lnos-x1-a-csw02:~$ sudo config reload ~/config_db.json
    Clear current and reload all config? [y/N]: y
    Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
    DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

    Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config check' with invalid configuration:

    admin@lnos-x1-a-csw02:~$ sudo config check ~/config_db.json
    Running command: sonic-cfggen -j /home/admin/config_db.json --check-json
    DEVICE_NEIGHBOR port Ethernet5 not found in PORT table.

    Invalid configuration detected. No configuration changes processed. Exiting...

<-- Running 'config check' with valid configuration:

    admin@lnos-x1-a-csw02:~$ sudo config check /etc/sonic/config_db.json
    Running command: sonic-cfggen -j /etc/sonic/config_db.json --check-json
    Valid configuration found in /etc/sonic/config_db.json file

Signed-off-by: Rodny Molina <rmolina@linkedin.com>
mihirpat1 pushed a commit to mihirpat1/sonic-utilities that referenced this pull request Sep 15, 2023
When insert trasnceiver which is not QSFP-DD, "sfputil show error-status -hw" would fail
error:
  File "/usr/local/lib/python3.7/dist-packages/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py", line 211, in get_error_description
    return api.get_error_description() if api is not None else None
AttributeError: 'Sff8636Api' object has no attribute 'get_error_description'

Signed-off-by: chiourung_huang <chiourung_huang@edge-core.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant