From 0ce5252ff32bc34cba1983d78936edbe38fbe667 Mon Sep 17 00:00:00 2001 From: xiongjihai Date: Sun, 19 May 2019 01:40:57 +0800 Subject: [PATCH] [sonic-cfggen]: fix bug in file sonic-cfggen (#2834) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/sonic-config-engine/sonic-cfggen | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index a711ca1301e0..3f7951248c61 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -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