Skip to content

[YANG]sonic-dot1p-tc-map.yang would cause failed deployment via mgmt-framework #10386

@ljyfree

Description

@ljyfree

Description

There are nested LISTs in ./yang-models/sonic-dot1p-tc-map.yang as follows:

container sonic-dot1p-tc-map {  

        container DOT1P_TO_TC_MAP {

            description "DOT1P_TO_TC_MAP part of config_db.json";

            list DOT1P_TO_TC_MAP_LIST {
                
                key "name";

                leaf name {
                    type string {
                        pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})';
                        length 1..32 {
                            error-message "Invalid length for map name.";
                            error-app-tag map-name-invalid-length;
                        }
                    }
                }

                list DOT1P_TO_TC_MAP { //this is list inside list for storing mapping between two fields

                    key "dot1p";

                    leaf dot1p {
                        type string {
                            pattern "[0-7]?" {
                                error-message "Invalid DOT1P";
                                error-app-tag dot1p-invalid;
                            }
                        }
                    }

                    leaf tc {
                        type string {
                            pattern "[0-7]?"{
                                error-message "Invalid Traffic Class";
                                error-app-tag tc-invalid;
                            }
                        }
                    }
                }
            }
        }
    }

The target configuration into configDB as follows:

        "DOT1P_TO_TC_MAP": {
           "Dot1p_to_tc_map1": { 
              "1": "2",
              "3": "4"
            }

It means dot1p-1 maps to tc-2 and dot1p-3 maps to tc-4.
However,mgmt-framework's CVL function would check if field(here is "1" and "3") exist in the schema sourced from yang.
It would definitely failed.

Same issue for dscp-to-tc-map.

I found similar description in SONiC_YANG_Model_Guidelines , which use "map-list ".
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md#11-mapping-tables-in-redis-are-defined-using-nested-list-use-sonic-extmap-list-true-to-indicate-that-the-list-is-used-for-mapping-table-the-outer-list-is-used-for-multiple-instances-of-mapping-the-inner-list-is-used-for-mapping-entries-for-each-outer-list-instance

But "map-list" was removed in sonic-net/sonic-mgmt-common#51 .

@ohu1
@maheshwari-mayank

Steps to reproduce the issue:

1.compile mgmt-framework with ./yang-models/sonic-dot1p-tc-map.yang
2.Modify xlate_to_db.go to support nested list
3.try to deploy dot1p-to-tc

Describe the results you received:

CVL failed

Describe the results you expected:

dot1p-to-tc configuration should be

Output of show version:

(paste your output here)

Output of show techsupport:

(paste your output here or download and attach the file here )

Additional information you deem important (e.g. issue happens only occasionally):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Triagedthis issue has been triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions