Skip to content

Commit 3363587

Browse files
authored
Support control character in config (#217)
Why I did it sonic-net/sonic-buildimage#16957 Above PR introduced "\n" in config_db, and current GNMI implementation does not support such config. How I did it Update yang validation part to read config from file. How to verify it Run GNMI end to end test.
1 parent 6b63a50 commit 3363587

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

sonic_data_client/mixed_db_client.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,14 +1133,16 @@ import json
11331133
11341134
yang_parser = sonic_yang.SonicYang("/usr/local/yang-models")
11351135
yang_parser.loadYangModel()
1136-
text = '''%s'''
1137-
1138-
try:
1139-
yang_parser.loadData(configdbJson=json.loads(text))
1140-
yang_parser.validate_data_tree()
1141-
except sonic_yang.SonicYangException as e:
1142-
print("Yang validation error: {}".format(str(e)))
1143-
raise
1136+
filename = "%s"
1137+
with open(filename, 'r') as fp:
1138+
text = fp.read()
1139+
1140+
try:
1141+
yang_parser.loadData(configdbJson=json.loads(text))
1142+
yang_parser.validate_data_tree()
1143+
except sonic_yang.SonicYangException as e:
1144+
print("Yang validation error: {}".format(str(e)))
1145+
raise
11441146
`
11451147

11461148
func (c *MixedDbClient) SetIncrementalConfig(delete []*gnmipb.Path, replace []*gnmipb.Update, update []*gnmipb.Update) error {

0 commit comments

Comments
 (0)