Skip to content

Commit

Permalink
Use common lib function
Browse files Browse the repository at this point in the history
Signed-off-by: maipbui <maibui@microsoft.com>
  • Loading branch information
maipbui committed Sep 18, 2022
1 parent 20e2cd7 commit a16ed29
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions platform/mellanox/mlnx-platform-api/sonic_platform/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import tempfile
import subprocess
from sonic_py_common import device_info
from sonic_py_common.general import check_output_pipe
if sys.version_info[0] > 2:
import configparser
else:
Expand Down Expand Up @@ -171,19 +172,7 @@ def __mount_onie_fs(self):
cmd1 = ['fdisk', '-l']
cmd2 = ['grep', 'ONIE boot']
cmd3 = ['awk', '{print $1}']
with subprocess.Popen(cmd1, universal_newlines=True, stdout=subprocess.PIPE) as p1:
with subprocess.Popen(cmd2, universal_newlines=True, stdin=p1.stdout, stdout=subprocess.PIPE) as p2:
with subprocess.Popen(cmd3, universal_newlines=True, stdin=p2.stdout, stdout=subprocess.PIPE) as p3:
fs_path = p3.communicate()[0].rstrip('\n')
p1.wait()
p2.wait()
if p1.returncode != 0 and p2.returncode != 0 and p3.returncode != 0:
if p1.returncode != 0:
raise subprocess.CalledProcessError(returncode=p1.returncode, cmd=cmd1, output=p1.stdout)
elif p2.returncode != 0:
raise subprocess.CalledProcessError(returncode=p2.returncode, cmd=cmd2, output=p2.stdout)
elif p3.returncode != 0:
raise subprocess.CalledProcessError(returncode=p3.returncode, cmd=cmd, output=fs_path)
fs_path = check_output_pipe(cmd1, cmd2, cmd3)

os.mkdir(fs_mountpoint)
cmd = ["mount", "-n", "-r", "-t", "ext4", fs_path, fs_mountpoint]
Expand Down

0 comments on commit a16ed29

Please sign in to comment.