Skip to content

Commit

Permalink
v2.1.1 - Add Lun ID overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnychou committed Jul 28, 2017
1 parent 0778a07 commit 84d6cbd
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions infortrend/raidcmd_cli/common_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ class InfortrendCommon(object):
2.1.0 - Support for list manageable volume
- Support for list/manage/unmanage snapshot
- Remove unnecessary check in snapshot
2.1.1 - Add Lun ID overflow check
"""

VERSION = '2.1.0'
VERSION = '2.1.1'

constants = {
'ISCSI_PORT': 3260,
Expand Down Expand Up @@ -1097,15 +1098,22 @@ def _get_mapping_info_with_mpio(self):
def _get_minimum_common_lun_id(self, channel_dict):
"""Find the minimun common lun id in all channels."""
map_lun = []
# search for free lun id on all channels
for lun_id in range(self.constants['MAX_LUN_MAP_PER_CHL']):
has_mapped = False
lun_id_is_used = False
for controller in channel_dict.keys():
for channel_id in channel_dict[controller]:
if lun_id not in self.map_dict[controller][channel_id]:
has_mapped = True
if not has_mapped:
lun_id_is_used = True
if not lun_id_is_used:
map_lun.append(str(lun_id))
break
# check lun id overflow
elif (lun_id == self.constants['MAX_LUN_MAP_PER_CHL'] - 1):
msg = _('LUN map has reached maximum value [%(max_lun)s].') % {
'max_lun': self.constants['MAX_LUN_MAP_PER_CHL']}
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)

return map_lun

Expand Down Expand Up @@ -1158,19 +1166,26 @@ def _get_minimun_mapping_channel_id(self, controller):

def _get_common_lun_map_id(self, wwpn_channel_info):
map_lun = None

# search for free lun id on all channels
for lun_id in range(self.constants['MAX_LUN_MAP_PER_CHL']):
lun_id_exist = False
lun_id_is_used = False
for slot_name in ['slot_a', 'slot_b']:
for wwpn in wwpn_channel_info:
channel_id = wwpn_channel_info[wwpn]['channel']
if channel_id not in self.map_dict[slot_name]:
continue
elif lun_id not in self.map_dict[slot_name][channel_id]:
lun_id_exist = True
if not lun_id_exist:
lun_id_is_used = True
if not lun_id_is_used:
map_lun = str(lun_id)
break
# check lun id overflow
elif (lun_id == self.constants['MAX_LUN_MAP_PER_CHL'] - 1):
msg = _('LUN map has reached maximum value [%(max_lun)s].') % {
'max_lun': self.constants['MAX_LUN_MAP_PER_CHL']}
LOG.error(msg)
raise exception.VolumeDriverException(message=msg)

return map_lun

def _get_mcs_id(self, channel_id, controller):
Expand Down

0 comments on commit 84d6cbd

Please sign in to comment.