Skip to content

Commit

Permalink
remove null value of port attribute when using sonic-cfggen to genera…
Browse files Browse the repository at this point in the history
…te port config
  • Loading branch information
zhixzhu committed Dec 11, 2024
1 parent fd25edb commit e015f1a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/sonic-config-engine/portconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ def parse_port_config_file(port_config_file):
for i, item in enumerate(tokens):
if i == name_index:
continue
if item != '-':
data[titles[i]] = item
data[titles[i]] = item
data.setdefault('alias', name)
ports[name] = data
port_alias_map[data['alias']] = name
Expand Down
9 changes: 9 additions & 0 deletions src/sonic-config-engine/sonic-cfggen
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ def main():
if ports is None:
print('Failed to get port config', file=sys.stderr)
sys.exit(1)
for port in ports.values():
null_value_attrs = []
for attr in port:
if port[attr] == '-':
null_value_attrs.append(attr)
if not null_value_attrs:
continue
for null_value_attr in null_value_attrs:
del port[null_value_attr]
deep_update(data, {'PORT': ports})

brkout_table = get_breakout_mode(hwsku, platform, args.port_config)
Expand Down

0 comments on commit e015f1a

Please sign in to comment.