Skip to content

Commit

Permalink
[sonic-cfggen]: fix bug in file sonic-cfggen (sonic-net#2834)
Browse files Browse the repository at this point in the history
Fixing bug of file sonic-cfggen. Error occurs if argument --var-json is set when running sonic-cfggen,for example:

Command: sonic-cfggen -d --var-json VLAN_MEMBER
Configuration in config_db.json: 
            "VLAN_MEMBER": {
            ......
                "Vlan11|Ethernet32": {
                 "tagging_mode": "untagged"
             },
             ......
Error occurs because FormatConverter.to_serialized(data) in file sonic-cfggen doesn't serialize
keys correctly
  • Loading branch information
jihaix authored and MichelMoriniaux committed May 28, 2019
1 parent e9bfaea commit 0ce5252
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ TODO(taoyl): Current version of config db only supports BGP admin states.

@staticmethod
def to_serialized(data):
for table in data:
if type(data[table]) is dict:
data[table] = OrderedDict(natsorted(data[table].items()))
for key in data[table].keys():
new_key = ConfigDBConnector.serialize_key(key)
if new_key != key:
data[table][new_key] = data[table].pop(key)
if type(data) is dict:
data = OrderedDict(natsorted(data.items()))
for key in data.keys():
new_key = ConfigDBConnector.serialize_key(key)
if new_key != key:
data[new_key] = data.pop(key)
data[new_key] = FormatConverter.to_serialized(data[new_key])
return data

@staticmethod
Expand Down

0 comments on commit 0ce5252

Please sign in to comment.