cimproperty.value = '10000000000'
return cimproperty
- def fake_getElementNameCIMProperty(self):
+ def fake_getElementNameCIMProperty(self, name):
cimproperty = Fake_CIMProperty()
- cimproperty.value = 'OS-myhost-MV'
+ cimproperty.value = name
return cimproperty
def fake_getSupportedReplicationTypes(self):
classcimproperty = Fake_CIMProperty()
elementName = (
- classcimproperty.fake_getElementNameCIMProperty())
+ classcimproperty.fake_getElementNameCIMProperty('OS-myhost-MV'))
properties = {u'ElementName': elementName}
antecedent.properties = properties
unitname['CreationClassName'] = self.data.unit_creationclass
unitnames.append(unitname)
+ # Second masking
+ unitname2 = unitname.copy()
+ elementName2 = (
+ classcimproperty.fake_getElementNameCIMProperty('OS-fakehost-MV'))
+ properties2 = {u'ElementName': elementName2}
+
+ antecedent2 = SYMM_LunMasking()
+ antecedent2['CreationClassName'] = self.data.lunmask_creationclass2
+ antecedent2['SystemName'] = self.data.storage_system
+
+ antecedent2.properties = properties2
+ unitname2['Antecedent'] = antecedent2
+ unitnames.append(unitname2)
return unitnames
def _default_ref(self, objectpath):
def fake_is_v3(self, conn, serialNumber):
return False
+ def test_find_device_number(self):
+ host = 'myhost'
+ data = (
+ self.driver.common.find_device_number(self.data.test_volume_v2,
+ host))
+ self.assertEqual('OS-myhost-MV', data['maskingview'])
+ host = 'bogushost'
+ data = (
+ self.driver.common.find_device_number(self.data.test_volume_v2,
+ host))
+ # Empty dict
+ self.assertFalse(data)
+
def test_unbind_and_get_volume_from_storage_pool(self):
conn = self.fake_ecom_connection()
common = self.driver.common
LOG.info(_LI("Unmap volume: %(volume)s."),
{'volume': volumename})
- device_info = self.find_device_number(volume)
+ device_info = self.find_device_number(volume, connector['host'])
device_number = device_info['hostlunid']
if device_number is None:
LOG.info(_LI("Volume %s is not mapped. No volume to unmap."),
LOG.info(_LI("Initialize connection: %(volume)s."),
{'volume': volumeName})
self.conn = self._get_ecom_connection()
- deviceInfoDict = self.find_device_number(volume)
+ deviceInfoDict = self.find_device_number(volume, connector['host'])
if ('hostlunid' in deviceInfoDict and
deviceInfoDict['hostlunid'] is not None):
self.conn, maskingViewDict, extraSpecs)
# Find host lun id again after the volume is exported to the host.
- deviceInfoDict = self.find_device_number(volume)
+ deviceInfoDict = self.find_device_number(volume, connector['host'])
if 'hostlunid' not in deviceInfoDict:
# Did not successfully attach to host,
# so a rollback for FAST is required.
'initiator': foundinitiatornames})
return foundinitiatornames
- def find_device_number(self, volume):
+ def find_device_number(self, volume, host):
"""Given the volume dict find a device number.
Find a device number that a host can see
for a volume.
:param volume: the volume dict
+ :param host: host from connector
:returns: dict -- the data dict
"""
+ maskedvols = []
+ data = {}
foundNumDeviceNumber = None
foundMaskingViewName = None
volumeName = volume['name']
if properties[0] == 'ElementName':
cimProperties = properties[1]
foundMaskingViewName = cimProperties.value
- break
- break
+ devicedict = {'hostlunid': foundNumDeviceNumber,
+ 'storagesystem': storageSystemName,
+ 'maskingview': foundMaskingViewName}
+ maskedvols.append(devicedict)
- if foundNumDeviceNumber is None:
+ if not maskedvols:
LOG.debug(
"Device number not found for volume "
"%(volumeName)s %(volumeInstance)s.",
{'volumeName': volumeName,
'volumeInstance': volumeInstance.path})
+ else:
+ hoststr = ("-%(host)s-"
+ % {'host': host})
- data = {'hostlunid': foundNumDeviceNumber,
- 'storagesystem': storageSystemName,
- 'maskingview': foundMaskingViewName}
+ for maskedvol in maskedvols:
+ if hoststr.lower() in maskedvol['maskingview'].lower():
+ data = maskedvol
+ break
+ if not data:
+ LOG.warning(_LW(
+ "Volume is masked but not to host %(host)s as "
+ "expected. Returning empty dictionary."),
+ {'host': hoststr})
LOG.debug("Device info: %(data)s.", {'data': data})
-
return data
def get_target_wwns(self, storageSystem, connector):