Skip to content

Commit

Permalink
Support control character in config (sonic-net#217)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ganglyu authored Apr 18, 2024
1 parent 6b63a50 commit 3363587
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions sonic_data_client/mixed_db_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1133,14 +1133,16 @@ import json
yang_parser = sonic_yang.SonicYang("/usr/local/yang-models")
yang_parser.loadYangModel()
text = '''%s'''
try:
yang_parser.loadData(configdbJson=json.loads(text))
yang_parser.validate_data_tree()
except sonic_yang.SonicYangException as e:
print("Yang validation error: {}".format(str(e)))
raise
filename = "%s"
with open(filename, 'r') as fp:
text = fp.read()
try:
yang_parser.loadData(configdbJson=json.loads(text))
yang_parser.validate_data_tree()
except sonic_yang.SonicYangException as e:
print("Yang validation error: {}".format(str(e)))
raise
`

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

0 comments on commit 3363587

Please sign in to comment.