-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ses: check for supported snic diagnostic page before querying it
Avoid useless driver warning messages in kernel logs when snic is not supported.
- Loading branch information
Showing
1 changed file
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]> | ||
# | ||
|
@@ -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: | ||
|