Skip to content

Commit

Permalink
ses: check for supported snic diagnostic page before querying it
Browse files Browse the repository at this point in the history
Avoid useless driver warning messages in kernel logs when snic is
not supported.
  • Loading branch information
thiell committed Nov 12, 2021
1 parent 1f56ea1 commit 4596ac1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion sasutils/ses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2016
# Copyright (C) 2016, 2021
# The Board of Trustees of the Leland Stanford Junior University
# Written by Stephane Thiell <sthiell@stanford.edu>
#
Expand Down Expand Up @@ -31,7 +31,31 @@

def ses_get_snic_nickname(sg_name):
"""Get subenclosure nickname (SES-2) [snic]"""
support_snic = False

# SES nickname is not available through sysfs, use sg_ses tool instead
cmdargs = ['sg_ses', '--status', '/dev/' + sg_name]
LOGGER.debug('ses_get_snic_nickname: executing: %s', cmdargs)
try:
stdout, stderr = subprocess.Popen(cmdargs,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
except OSError as err:
LOGGER.warning('ses_get_snic_nickname: %s', err)
return None

for line in stderr.decode("utf-8").splitlines():
LOGGER.debug('ses_get_snic_nickname: sg_ses(stderr): %s', line)

for line in stdout.decode("utf-8").splitlines():
LOGGER.debug('ses_get_snic_nickname: sg_ses: %s', line)
if '[snic]' in line:
support_snic = True
break

if not support_snic:
return None

cmdargs = ['sg_ses', '--page=snic', '-I0', '/dev/' + sg_name]
LOGGER.debug('ses_get_snic_nickname: executing: %s', cmdargs)
try:
Expand Down

0 comments on commit 4596ac1

Please sign in to comment.