Skip to content

SRv6: yang validation issue for a configuration with more than one entry #21867

@Yakiv-Huryk

Description

@Yakiv-Huryk

Description
The SRv6 configuration with more than one locator/sid fails the yang validation.

Steps to reproduce
config:

{
    "SRV6_MY_LOCATORS": {
        "locator_1": {
            "prefix": "2001:1000:100::"
        },
        "locator_2": {
            "prefix": "2001:1001:200::"
        }
    },
    "SRV6_MY_SIDS": {
        "locator_1|2001:1000:100::/48": {
            "action": "uN",
            "decap_dscp_mode": "uniform"
        },
        "locator_2|2001:1001:200::/48": {
            "action": "uN",
            "decap_dscp_mode": "pipe"
        }
    }
}

Validation output:

$ config_validator.py -c srv6cfg.json
libyang[0]: Must condition "starts-with(substring-before(./ip_prefix, "::"),
                                  substring-before(/sonic-srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))" not satisfied. (path: /sonic-srv6:sonic-srv6/SRV6_MY_SIDS/SRV6_MY_SIDS_LIST[locator='locator_2'][ip_prefix='2001:1001:200::/48'])
sonic_yang(3):Data Loading Failed:Must condition "starts-with(substring-before(./ip_prefix, "::"),
                                  substring-before(/sonic-srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))" not satisfied.
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/sonic_yang_ext.py", line 1177, in loadData
    self.root = self.ctx.parse_data_mem(dumps(self.xlateJson), \
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/yang.py", line 2574, in parse_data_mem
    return _yang.Context_parse_data_mem(self, data, format, options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Must condition "starts-with(substring-before(./ip_prefix, "::"),
                                  substring-before(/sonic-srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))" not satisfied.
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/usr/local/bin/config_validator.py", line 44, in <module>
    main()
  File "/usr/local/bin/config_validator.py", line 33, in main
    yang_parser.loadData(configdbJson=config)
  File "/usr/local/lib/python3.11/dist-packages/sonic_yang_ext.py", line 1184, in loadData
    raise SonicYangException("Data Loading Failed\n{}".format(str(e)))
sonic_yang_ext.SonicYangException: Data Loading Failed
Must condition "starts-with(substring-before(./ip_prefix, "::"),
                                  substring-before(/sonic-srv6:sonic-srv6/SRV6_MY_LOCATORS/SRV6_MY_LOCATORS_LIST[current()/locator]/prefix, "::"))" not satisfied.

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions