Skip to content

Commit

Permalink
Add error handling for MAC fetch process
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
  • Loading branch information
andriymoroz-mlnx committed Jul 13, 2018
1 parent 38663f4 commit 048db4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/sonic-config-engine/sonic_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ def get_system_mac():
else:
get_mac_cmd = "ip link show eth0 | grep ether | awk '{print $2}'"

proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE)
proc = subprocess.Popen(get_mac_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(mac, err) = proc.communicate()
if err:
return None

mac = mac.strip()

# Align last byte of MAC if necessary
Expand Down

0 comments on commit 048db4d

Please sign in to comment.