Skip to content

Commit

Permalink
sas_counters: fix defect when snic not set
Browse files Browse the repository at this point in the history
  • Loading branch information
thiell committed Feb 20, 2017
1 parent 9783aa0 commit d17c4c3
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions sasutils/cli/sas_counters.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,8 @@ def __str__(self):

def get_scsi_device_info(self, scsi_device):
#print(scsi_device.sysfsnode.path)
dev_info_fmt = []
if True:
dev_info_fmt.append('{model}')
dev_info_fmt.append('{sas_address}')

ikeys = ('model', 'sas_address')
iargs = dict((k, scsi_device.attrs.get(k, 'N/A')) for k in ikeys)
dev_info = '.'.join(dev_info_fmt).format(**iargs)
dev_info = '.'.join((scsi_device.attrs.get('model', 'MODEL_UNKNOWN'),
scsi_device.attrs['sas_address']))

scsi_type = scsi_device.attrs.type
unknown_type = 'unknown[%s]' % scsi_type
Expand All @@ -195,10 +189,11 @@ def get_scsi_device_info(self, scsi_device):
snic = ses_get_snic_nickname(sg.name)
# automatically resolve parent expander nickname
self.parent.parent.nickname = snic
return snic
else:
return dev_info
if snic:
return '.'.join((scsi_device.attrs.get('model',
'MODEL_UNKNOWN'), snic))

return dev_info

def main():
"""console_scripts entry point for sas_counters command-line."""
Expand Down

0 comments on commit d17c4c3

Please sign in to comment.