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

[202012][minigraph] Consume golden_config_db.json while loading minigraph #2227

Merged
merged 2 commits into from
Jun 23, 2022

Conversation

wen587
Copy link
Contributor

@wen587 wen587 commented Jun 22, 2022

What I did

This PR is to cherry-pick changes in PR #2140 to 202012 branch after resolving conflicts.
This PR is for supporting consume golden_config_db.json while loading minigraph. User can put the golden_config_db.json with minigraph file to override configDB after reload minigraph.
The golden_config_db.json looks just like a config_db.json and it will be placed on /etc/sonic/golden_config_db.json.
Step1: Load minigraph to configDB
Step2: If golden_config_db.json exists and contains some Table configuration, that Table in configDB will be overriden by the config in golden_config_db.json. Other config that not included in golden_config_db.json will keep the same as minigraph.
For example, assume below ACL_TABLE is loaded from minigraph:
config from minigraph:

        "ACL_TABLE": {
            "DATAACL": {
                "policy_desc": "DATAACL",
                "ports": [
                    "Ethernet4"
                ],
                "stage": "ingress",
                "type": "L3"
            },
            "NTP_ACL": {
                "policy_desc": "NTP_ACL",
                "services": [
                    "NTP"
                ],
                "stage": "ingress",
                "type": "CTRLPLANE"
            }
        },

The golden_config_db.json also contains ACL_TABLE as below.
config from golden_config_db.json

"ACL_TABLE": {
            "EVERFLOWV6": {
                "policy_desc": "EVERFLOWV6",
                "ports": [
                    "Ethernet12"
                ],
                "stage": "ingress",
                "type": "MIRRORV6"
            }
        },

During load_minigraph, the final config will be the same with golden_config_db.json because ACL_TABLE will be overriden by golden_config_db.json.
configDB ACL_TABLE final state:

"ACL_TABLE": {
            "EVERFLOWV6": {
                "policy_desc": "EVERFLOWV6",
                "ports": [
                    "Ethernet12"
                ],
                "stage": "ingress",
                "type": "MIRRORV6"
            }
        },

How I did it

Add code config override-config-table command to let it consume golden_config_db.json

How to verify it

Add UT tests and run.

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

admin@vlab-01:~$ sudo config override-config-table -h
Usage: config override-config-table [OPTIONS] INPUT_CONFIG_DB

  Override current configDB with input config.

Options:
  --dry_run TEXT  Dry run, writes config to the given file
  -h, -?, --help  Show this message and exit.

@wen587 wen587 requested a review from qiluo-msft June 22, 2022 07:13
@qiluo-msft qiluo-msft changed the title [cherry-pick][202012][minigraph] Consume golden_config_db.json while loading minigraph [202012][minigraph] Consume golden_config_db.json while loading minigraph Jun 22, 2022
@wen587 wen587 merged commit d5f8f5a into sonic-net:202012 Jun 23, 2022
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.

2 participants