Skip to content

Commit

Permalink
Compare network instead of raw string
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueve committed Jun 24, 2022
1 parent 1feee4d commit ecdefad
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1852,15 +1852,17 @@ def parse_device_desc_xml(filename):
results['LOOPBACK_INTERFACE'] = {('lo_v6', lo_prefix_v6): {}}

results['MGMT_INTERFACE'] = {}
if mgmt_prefix and mgmt_prefix != '0.0.0.0/0':
if mgmt_prefix:
mgmtipn = ipaddress.ip_network(UNICODE_TYPE(mgmt_prefix), False)
gwaddr = ipaddress.ip_address((next(mgmtipn.hosts())))
results['MGMT_INTERFACE'].update({('eth0', mgmt_prefix): {'gwaddr': gwaddr}})
if mgmtipn != ipaddress.ip_network(u'0.0.0.0/0', False):
gwaddr = ipaddress.ip_address((next(mgmtipn.hosts())))
results['MGMT_INTERFACE'].update({('eth0', mgmt_prefix): {'gwaddr': gwaddr}})

if mgmt_prefix_v6 and mgmt_prefix_v6 != '::/0':
if mgmt_prefix_v6:
mgmtipn_v6 = ipaddress.ip_network(UNICODE_TYPE(mgmt_prefix_v6), False)
gwaddr_v6 = ipaddress.ip_address((next(mgmtipn_v6.hosts())))
results['MGMT_INTERFACE'].update({('eth0', mgmt_prefix_v6): {'gwaddr': gwaddr_v6}})
if mgmtipn != ipaddress.ip_network(u'::/0', False):
gwaddr_v6 = ipaddress.ip_address((next(mgmtipn_v6.hosts())))
results['MGMT_INTERFACE'].update({('eth0', mgmt_prefix_v6): {'gwaddr': gwaddr_v6}})

return results

Expand Down

0 comments on commit ecdefad

Please sign in to comment.