[yang] Update YANG model for mirror session to support decimal value for GRE type (#10140)
#### Why I did it PR https://github.com/Azure/sonic-utilities/pull/1825 added validation for the input of `config mirror session add`, and only decimal value is accepted. An issue https://github.com/Azure/sonic-buildimage/issues/10096 was raised to suggest accepting HEX value as well, and the suggestion makes sense to me. To accept HEX value for GRE type, and keep backward compatibility as well, I updated the YANG model to support both decimal and hexadecimal input for GRE type. #### How I did it Update the regex for GRE type. #### How to verify it Verified by UT ``` platform linux -- Python 3.9.2, pytest-6.0.2, py-1.10.0, pluggy-0.13.0 rootdir: /sonic/src/sonic-yang-models plugins: pyfakefs-4.5.4, cov-2.10.1 collected 3 items tests/test_sonic_yang_models.py .. [ 66%] tests/yang_model_tests/test_yang_model.py . [100%] ========================================================================================== 3 passed in 2.53s ========================================================================================== ``` #### Description for the changelog Update YANG model for mirror session to support decimal value for GRE type.
This commit is contained in:
parent
9d2078c446
commit
fb7f046143
@ -1,6 +1,18 @@
|
||||
{
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_VALUES": {
|
||||
"desc": "Configuring ERSPAN entry with valid values."
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES": {
|
||||
"desc": "Configuring ERSPAN entry with valid heximal values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES_1": {
|
||||
"desc": "Configuring ERSPAN entry with valid heximal values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": {
|
||||
"desc": "Configuring ERSPAN entry with valid decimal values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": {
|
||||
"desc": "Configuring ERSPAN entry with valid decimal values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": {
|
||||
"desc": "Configuring ERSPAN entry with valid decimal values."
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_TYPE": {
|
||||
"desc": "Configuring ERSPAN entry with invalid type",
|
||||
@ -26,6 +38,14 @@
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_1": {
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_2": {
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "Pattern"
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_GRE_WRONG_TYPE": {
|
||||
"desc": "Configuring ERSPAN entry with invalid GRE type",
|
||||
"eStrKey" : "When"
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_VALUES": {
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
@ -15,6 +15,70 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_HEX_VALUES_1": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "0x0",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "1234",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_1": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "65535",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WITH_VALID_DEC_VALUES_2": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "0",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_TYPE": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
@ -104,7 +168,39 @@
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "0",
|
||||
"gre_type": "100000",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_1": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "-1",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"MIRROR_ERSPAN_ENTRY_WRONG_GRE_TYPE_2": {
|
||||
"sonic-mirror-session:sonic-mirror-session": {
|
||||
"MIRROR_SESSION": {
|
||||
"MIRROR_SESSION_LIST": [
|
||||
{
|
||||
"name": "erspan",
|
||||
"type": "ERSPAN",
|
||||
"dst_ip": "11.1.1.1",
|
||||
"src_ip": "10.1.1.1",
|
||||
"gre_type": "65536",
|
||||
"dscp": "10"
|
||||
}
|
||||
]
|
||||
|
@ -99,7 +99,7 @@ module sonic-mirror-session {
|
||||
leaf gre_type {
|
||||
when "current()/../type = 'ERSPAN'";
|
||||
type string {
|
||||
pattern "0[xX][0-9a-fA-F]*";
|
||||
pattern "0[xX][0-9a-fA-F]*|([0-9]|[1-5]?[0-9]{2,4}|6[1-4][0-9]{3}|65[1-4][0-9]{2}|655[1-2][0-9]|6553[0-5])";
|
||||
length 1..6 {
|
||||
error-message "Invalid GRE type";
|
||||
error-app-tag gre-type-invalid;
|
||||
|
Loading…
Reference in New Issue
Block a user