Skip to content

Commit 1eb018c

Browse files
jihaixVasant Patil
authored and
Vasant Patil
committed
[sonic-cfggen]: fix bug in file sonic-cfggen (sonic-net#2834)
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
1 parent d938b5d commit 1eb018c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/sonic-config-engine/sonic-cfggen

+7-7
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ TODO(taoyl): Current version of config db only supports BGP admin states.
195195

196196
@staticmethod
197197
def to_serialized(data):
198-
for table in data:
199-
if type(data[table]) is dict:
200-
data[table] = OrderedDict(natsorted(data[table].items()))
201-
for key in data[table].keys():
202-
new_key = ConfigDBConnector.serialize_key(key)
203-
if new_key != key:
204-
data[table][new_key] = data[table].pop(key)
198+
if type(data) is dict:
199+
data = OrderedDict(natsorted(data.items()))
200+
for key in data.keys():
201+
new_key = ConfigDBConnector.serialize_key(key)
202+
if new_key != key:
203+
data[new_key] = data.pop(key)
204+
data[new_key] = FormatConverter.to_serialized(data[new_key])
205205
return data
206206

207207
@staticmethod

0 commit comments

Comments
 (0)