Skip to content

Conversation

wen587
Copy link
Contributor

@wen587 wen587 commented Apr 18, 2025

Why I did it

To enable YANG based CFG table generation, the ConfigDB related macro will be generated by YANG model

How I did it

Add gen_cfg_schema.py script to generate cfg_schema.h which will be included in schema.h

Work item tracking
  • Microsoft ADO: 31676863

How to verify it

make deb build

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@wen587 wen587 changed the title Libc6 Automatically generate CFG table by YANG May 20, 2025
@wen587 wen587 changed the title Automatically generate CFG table by YANG [strict yang] Add YANG based cfg_schema.h to schema.h Jun 24, 2025
qiluo-msft and others added 6 commits August 5, 2025 12:58
…-net#1052)

This PR is a partial duplicate of sonic-net/sonic-dash-ha#84
Since crates/swss-common will be moved in this repo.

why
During investigating issue sonic-net#75, I created test case to verify zmq behaviour in handling no connection and connection loss. It is found that with the current swss-common zmq implementation with below attributes, we don't need to handle reconnect explicitly.

PUSH/PULL model
ZMQ_IMMEDIATE = 0 (default)
ZMQ_SNDHWM = 10000
what this PR does
add unit test for zmq late connect and reconnect for regression
remove unneeded code for falling back to ProducerStateTable in test environment since zmq client won't fail if zmq server is not connected.
update test_utils/README.md with missing argument to start redis in test environment
@qiluo-msft qiluo-msft requested a review from Copilot August 6, 2025 00:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables YANG-based configuration table generation by introducing an automated script to generate CFG_* macro definitions from YANG models. The changes integrate the generation of cfg_schema.h into the build process and update the schema to use this dynamically generated header instead of hardcoded table definitions.

  • Adds gen_cfg_schema.py script that dynamically generates CFG_* table macros from YANG models
  • Integrates the generation into the build system through Makefile changes and CI pipeline updates
  • Replaces hardcoded CFG_* table definitions in schema.h with inclusion of the generated cfg_schema.h

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
gen_cfg_schema.py New Python script that extracts table names from YANG models and generates CFG_* macro definitions
tests/test_gen_cfg_schema.py Unit tests for the schema generation script
common/Makefile.am Build system integration to generate cfg_schema.h before compilation
common/schema.h Replaces hardcoded CFG_* macros with include of generated cfg_schema.h
pyext/swsscommon.i Adds cfg_schema.h to SWIG interface for Python bindings
azure-pipelines.yml Updates CI to install YANG dependencies for schema generation
.azure-pipelines/*.yml Additional CI updates for YANG package installation
Comments suppressed due to low confidence (1)

tests/test_gen_cfg_schema.py:46

  • The test only covers the case where a key contains a hyphen, but doesn't test other potentially invalid characters for C macro names (e.g., spaces, dots, special symbols). Consider adding test cases for other invalid characters that could appear in YANG model names.
            # Check that memory-usage is commented out due to hyphen

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft qiluo-msft merged commit 839ddf0 into sonic-net:master Aug 8, 2025
15 checks passed
@yue-fred-gao
Copy link
Contributor

@wen587 , I tried to update swss-common submodule in sonic-buildimage with PR sonic-net/sonic-buildimage#23687. There is a compilation error

/usr/bin/python ./gen_cfg_schema.py -o common/cfg_schema.h
Traceback (most recent call last):
  File "./gen_cfg_schema.py", line 2, in <module>
    import sonic_yang
ImportError: No module named sonic_yang
make[3]: *** [Makefile:3503: common/cfg_schema.h] Error 1

Is there another dependent submodule that I need to add to sonic-buildimage?

@wen587
Copy link
Contributor Author

wen587 commented Aug 13, 2025

@wen587 , I tried to update swss-common submodule in sonic-buildimage with PR sonic-net/sonic-buildimage#23687. There is a compilation error

/usr/bin/python ./gen_cfg_schema.py -o common/cfg_schema.h
Traceback (most recent call last):
  File "./gen_cfg_schema.py", line 2, in <module>
    import sonic_yang
ImportError: No module named sonic_yang
make[3]: *** [Makefile:3503: common/cfg_schema.h] Error 1

Is there another dependent submodule that I need to add to sonic-buildimage?

Hi @yue-fred-gao , no . Investigating the compliation issue.

wen587 added a commit to wen587/sonic-swss-common that referenced this pull request Aug 13, 2025
qiluo-msft pushed a commit that referenced this pull request Aug 14, 2025
@wen587
Copy link
Contributor Author

wen587 commented Aug 14, 2025

Hi @yue-fred-gao , pr reverted. Please go ahead update your submodule.

@yue-fred-gao
Copy link
Contributor

Thanks for the quick solution!

wen587 added a commit to wen587/sonic-swss-common that referenced this pull request Sep 4, 2025
wen587 added a commit that referenced this pull request Sep 22, 2025
Comparing to #1008, change to PYTHON3 for buster build failure.
Improve the dynamic debian_version as an argument instead of static bookworm.

Why I did it
To enable YANG based CFG table generation, the ConfigDB related macro will be generated by YANG model

How I did it
Add gen_cfg_schema.py script to generate cfg_schema.h which will be included in schema.h

Work item tracking
Microsoft ADO: 31676863
How to verify it
make deb build
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.

8 participants