NEC driver: Return non-random iscsi portal in initialize

Returns same set of portals in initialize, this will
suits for both single-path and multipath situations.

Change-Id: Ifd241a9fa34957a3bfc8b3a768d18a781519eefe
Closes-Bug: #1742587
This commit is contained in:
Dongcan Ye 2018-06-19 07:06:27 +00:00
parent 7dbe92ea7f
commit b6cf3dd2a6
2 changed files with 9 additions and 9 deletions

View File

@ -903,6 +903,7 @@ class ExportTest(volume_helper.MStorageDSVDriver, test.TestCase):
self.assertEqual('iscsi', info['driver_volume_type'])
self.assertEqual('iqn.2010-10.org.openstack:volume-00000001',
info['data']['target_iqn'])
self.assertEqual('1.1.1.1:3260', info['data']['target_portal'])
self.assertEqual(88, info['data']['target_lun'])
self.assertEqual('iqn.2010-10.org.openstack:volume-00000001',
info['data']['target_iqns'][0])

View File

@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import random
import re
import traceback
@ -289,8 +288,8 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
break
if (self._properties['portal_number'] > 0 and
len(dirportal) > self._properties['portal_number']):
nominated.extend(random.sample(
dirportal, self._properties['portal_number']))
nominated.extend(
dirportal[0:self._properties['portal_number']])
else:
nominated.extend(dirportal)
@ -1110,12 +1109,12 @@ class MStorageDriver(volume_common.MStorageVolumeCommon):
provider_location = volume.provider_location
provider_location = provider_location.split()
info = {'driver_volume_type': 'iscsi',
'data': {'target_portal': random.choice(
provider_location[0][0:-2].split(";")),
'target_iqn': provider_location[1],
'target_lun': int(provider_location[2]),
'target_discovered': False,
'volume_id': volume.id}
'data': {'target_portal':
provider_location[0][0:-2].split(";")[0],
'target_iqn': provider_location[1],
'target_lun': int(provider_location[2]),
'target_discovered': False,
'volume_id': volume.id}
}
if connector.get('multipath'):
portals_len = len(provider_location[0][0:-2].split(";"))