Skip to content

Commit

Permalink
Fix Huawei HVS driver AttributeError
Browse files Browse the repository at this point in the history
This patch checks the iSCSI port info and raises an exception
if it can not get the port info from the configuration.

Closes-bug: #1237185
Change-Id: I341ccbe77abd25421e5ee0b2d07ace3759fbccef
  • Loading branch information
zhangchao010 committed Oct 16, 2013
1 parent b30402e commit 7aa0c1d
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions cinder/volume/drivers/huawei/rest_common.py
Expand Up @@ -1054,6 +1054,13 @@ def _get_iscsi_port_info(self, ip):
iscsi_port_info = item['LOCATION']
break

if not iscsi_port_info:
msg = (_('_get_iscsi_port_info: Failed to get iscsi port info '
'through config IP %(ip)s, please check config file.')
% {'ip': ip})
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

return iscsi_port_info

def _get_iscsi_conf(self):
Expand All @@ -1078,28 +1085,23 @@ def _get_tgt_iqn(self, iscsiip):
LOG.debug(_('_get_tgt_iqn: iSCSI IP is %s.') % iscsiip)
ip_info = self._get_iscsi_port_info(iscsiip)
iqn_prefix = self._get_iscsi_tgt_port()
LOG.debug(_('request ip info is %s.') % ip_info)

split_list = ip_info.split(".")
newstr = split_list[1] + split_list[2]
LOG.debug(_('new str info is %s.') % newstr)

if ip_info:
if newstr[0] == 'A':
ctr = "0"
elif newstr[0] == 'B':
ctr = "1"
interface = '0' + newstr[1]
port = '0' + newstr[3]
iqn_suffix = ctr + '02' + interface + port
for i in range(0, len(iqn_suffix)):
if iqn_suffix[i] != '0':
iqn_suffix = iqn_suffix[i:]
break
iqn = iqn_prefix + ':' + iqn_suffix + ':' + iscsiip
LOG.debug(_('_get_tgt_iqn: iSCSI target iqn is %s') % iqn)
return iqn
else:
return None
if newstr[0] == 'A':
ctr = "0"
elif newstr[0] == 'B':
ctr = "1"
interface = '0' + newstr[1]
port = '0' + newstr[3]
iqn_suffix = ctr + '02' + interface + port
for i in range(0, len(iqn_suffix)):
if iqn_suffix[i] != '0':
iqn_suffix = iqn_suffix[i:]
break
iqn = iqn_prefix + ':' + iqn_suffix + ':' + iscsiip
LOG.debug(_('_get_tgt_iqn: iSCSI target iqn is %s') % iqn)
return iqn

def _get_fc_target_wwpns(self, wwn):
url = (self.url +
Expand Down

0 comments on commit 7aa0c1d

Please sign in to comment.