Skip to content

Commit

Permalink
Append default mask field if user has not provided one (sonic-net#972)
Browse files Browse the repository at this point in the history
* Append mask if user has not provided one
  • Loading branch information
prsunny authored Jul 1, 2020
1 parent aae89b7 commit fd52e93
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,9 @@ def add(ctx, interface_name, ip_addr, gw):
ctx.fail("'interface_name' is None!")

try:
ipaddress.ip_network(unicode(ip_addr), strict=False)
net = ipaddress.ip_network(unicode(ip_addr), strict=False)
if '/' not in ip_addr:
ip_addr = str(net)

if interface_name == 'eth0':

Expand Down Expand Up @@ -2102,7 +2104,9 @@ def remove(ctx, interface_name, ip_addr):
ctx.fail("'interface_name' is None!")

try:
ipaddress.ip_network(unicode(ip_addr), strict=False)
net = ipaddress.ip_network(unicode(ip_addr), strict=False)
if '/' not in ip_addr:
ip_addr = str(net)

if interface_name == 'eth0':
config_db.set_entry("MGMT_INTERFACE", (interface_name, ip_addr), None)
Expand Down

0 comments on commit fd52e93

Please sign in to comment.