Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frr] fix pfx_filter in sonic-cfggen #2994

Merged
merged 1 commit into from
Jun 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ minigraph file, config DB, json file(s), yaml files(s), command line input,
and write the data into DB, print as json, or render a jinja2 config template.

Examples:
Render template with minigraph:
Render template with minigraph:
sonic-cfggen -m -t /usr/share/template/bgpd.conf.j2
Dump config DB content into json file:
Dump config DB content into json file:
sonic-cfggen -d --print-data > db_dump.json
Load content of json file into config DB:
sonic-cfggen -j db_dump.json --write-to-db
Expand Down Expand Up @@ -93,6 +93,10 @@ def pfx_filter(value):
For eg - VLAN_INTERFACE|Vlan1000 vs VLAN_INTERFACE|Vlan1000|192.168.0.1/21
"""
table = OrderedDict()

if not value:
return table

for key,val in value.items():
if not isinstance(key, tuple):
continue
Expand All @@ -104,7 +108,7 @@ class FormatConverter:
We will move to DB schema and remove this class when the config templates are modified.

TODO(taoyl): Current version of config db only supports BGP admin states.
All other configuration are still loaded from minigraph. Plan to remove
All other configuration are still loaded from minigraph. Plan to remove
minigraph and move everything into config db in a later commit.
"""
@staticmethod
Expand Down Expand Up @@ -214,7 +218,7 @@ def main():

for yaml_file in args.yaml:
with open(yaml_file, 'r') as stream:
additional_data = yaml.load(stream)
additional_data = yaml.load(stream)
deep_update(data, FormatConverter.to_deserialized(additional_data))

for json_file in args.json:
Expand All @@ -223,7 +227,7 @@ def main():

if args.additional_data != None:
deep_update(data, json.loads(args.additional_data))

if args.from_db:
configdb = ConfigDBConnector(**db_kwargs)
configdb.connect()
Expand Down