Skip to content

Commit 71d0f46

Browse files
jihaixlguohan
authored andcommitted
[sonic-cfggen]: fix bug in file sonic-cfggen (#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 7791950 commit 71d0f46

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
@@ -109,13 +109,13 @@ TODO(taoyl): Current version of config db only supports BGP admin states.
109109

110110
@staticmethod
111111
def to_serialized(data):
112-
for table in data:
113-
if type(data[table]) is dict:
114-
data[table] = OrderedDict(natsorted(data[table].items()))
115-
for key in data[table].keys():
116-
new_key = ConfigDBConnector.serialize_key(key)
117-
if new_key != key:
118-
data[table][new_key] = data[table].pop(key)
112+
if type(data) is dict:
113+
data = OrderedDict(natsorted(data.items()))
114+
for key in data.keys():
115+
new_key = ConfigDBConnector.serialize_key(key)
116+
if new_key != key:
117+
data[new_key] = data.pop(key)
118+
data[new_key] = FormatConverter.to_serialized(data[new_key])
119119
return data
120120

121121
@staticmethod

0 commit comments

Comments
 (0)