'name': self.FAKE_HOST
}]
}
- mock_client.getVLUN.side_effect = [
- hpexceptions.HTTPNotFound('fake')]
- mock_client.getHostVLUNs.return_value = [
- {'active': True,
- 'volumeName': self.VOLUME_3PAR_NAME,
- 'lun': 90, 'type': 0}]
+
+ mock_client.getHostVLUNs.side_effect = [
+ hpexceptions.HTTPNotFound('fake'),
+ [{'active': True,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': 90, 'type': 0}]]
+
location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" %
{'volume_name': self.VOLUME_3PAR_NAME,
'lun_id': 90,
'123456789054321']),
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
- mock.call.getVLUN(self.VOLUME_3PAR_NAME),
+ mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=True,
'name': self.FAKE_HOST
}]
}
- mock_client.getVLUN.side_effect = [
- hpexceptions.HTTPNotFound('fake')]
- mock_client.getHostVLUNs.return_value = [
- {'active': True,
- 'volumeName': self.VOLUME_3PAR_NAME,
- 'lun': 90, 'type': 0}]
+
+ mock_client.getHostVLUNs.side_effect = [
+ hpexceptions.HTTPNotFound('fake'),
+ [{'active': True,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': 90, 'type': 0}]]
+
location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" %
{'volume_name': self.VOLUME_3PAR_NAME,
'lun_id': 90,
mock.ANY,
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
- mock.call.getVLUN(self.VOLUME_3PAR_NAME),
+ mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
'name': self.FAKE_HOST
}]
}
- mock_client.getVLUN.side_effect = [
- hpexceptions.HTTPNotFound('fake')]
- mock_client.getHostVLUNs.return_value = [
- {'active': True,
- 'volumeName': self.VOLUME_3PAR_NAME,
- 'lun': 90, 'type': 0}]
+
+ mock_client.getHostVLUNs.side_effect = [
+ hpexceptions.HTTPNotFound('fake'),
+ [{'active': True,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': 90, 'type': 0}]]
+
location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" %
{'volume_name': self.VOLUME_3PAR_NAME,
'lun_id': 90,
'123456789054321']),
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
- mock.call.getVLUN(self.VOLUME_3PAR_NAME),
+ mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=True,
'name': self.FAKE_HOST
}]
}
- mock_client.getHostVLUNs.return_value = [
- {'active': True,
- 'volumeName': self.VOLUME_3PAR_NAME,
- 'lun': self.TARGET_LUN, 'type': 0}]
- mock_client.getVLUN.return_value = {
- 'hostname': self.FAKE_HOST,
- 'lun': self.TARGET_LUN,
- 'portPos': {'node': 8, 'slot': 1, 'cardPort': 1}}
+
+ mock_client.getHostVLUNs.side_effect = [
+ [{'hostname': self.FAKE_HOST,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': self.TARGET_LUN,
+ 'portPos': {'node': 8, 'slot': 1, 'cardPort': 1}}],
+ [{'active': True,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': self.TARGET_LUN, 'type': 0}]]
+
location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" %
{'volume_name': self.VOLUME_3PAR_NAME,
'lun_id': self.TARGET_LUN,
mock.call.getHost(self.FAKE_HOST),
mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
mock.call.getHost(self.FAKE_HOST),
- mock.call.getVLUN(self.VOLUME_3PAR_NAME)]
+ mock.call.getHostVLUNs(self.FAKE_HOST)]
mock_client.assert_has_calls(
self.standard_login +
'name': self.FAKE_HOST
}]
}
- mock_client.getHostVLUNs.return_value = [
- {'active': True,
- 'volumeName': self.VOLUME_3PAR_NAME,
- 'lun': self.TARGET_LUN, 'type': 0}]
- mock_client.getVLUN.return_value = {
- 'hostname': self.FAKE_HOST,
- 'lun': self.TARGET_LUN,
- 'portPos': {'node': 8, 'slot': 1, 'cardPort': 1}}
+
+ mock_client.getHostVLUNs.side_effect = [
+ [{'hostname': self.FAKE_HOST,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': self.TARGET_LUN,
+ 'portPos': {'node': 8, 'slot': 1, 'cardPort': 1}}],
+ [{'active': True,
+ 'volumeName': self.VOLUME_3PAR_NAME,
+ 'lun': self.TARGET_LUN, 'type': 0}]]
+
location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" %
{'volume_name': self.VOLUME_3PAR_NAME,
'lun_id': self.TARGET_LUN,
mock.call.getHost(self.FAKE_HOST),
mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
mock.call.getHost(self.FAKE_HOST),
- mock.call.getVLUN(self.VOLUME_3PAR_NAME)]
+ mock.call.getHostVLUNs(self.FAKE_HOST)]
mock_client.assert_has_calls(
self.standard_login +
2.0.16 - Added encrypted property to initialize_connection #1439917
2.0.17 - Python 3 fixes
2.0.18 - Improved VLUN creation and deletion logic. #1469816
+ 2.0.19 - Changed initialize_connection to use getHostVLUNs. #1475064
"""
- VERSION = "2.0.18"
+ VERSION = "2.0.19"
def __init__(self, *args, **kwargs):
super(HP3PARISCSIDriver, self).__init__(*args, **kwargs)
connector)
least_used_nsp = None
- existing_vlun = None
- try:
- vol_name = common._get_3par_vol_name(volume['id'])
- existing_vlun = common.client.getVLUN(vol_name)
+ # check if a VLUN already exists for this host
+ existing_vlun = common.find_existing_vlun(volume, host)
+
+ if existing_vlun:
# We override the nsp here on purpose to force the
# volume to be exported out the same IP as it already is.
# This happens during nova live-migration, we want to
# disable the picking of a different IP that we export
# the volume to, or nova complains.
least_used_nsp = common.build_nsp(existing_vlun['portPos'])
- except hpexceptions.HTTPNotFound:
- # ignore this error, as we will create the vlun later
- pass
if not least_used_nsp:
least_used_nsp = self._get_least_used_nsp_for_host(
host['name'])
vlun = None
- if not existing_vlun or host['name'] != existing_vlun['hostname']:
+ if existing_vlun is None:
# now that we have a host, create the VLUN
vlun = common.create_vlun(volume, host, least_used_nsp)
else: