Merge "[Pure] Add missing FC host personality support"
This commit is contained in:
commit
fa8d89bc83
|
@ -3631,6 +3631,22 @@ class PureFCDriverTestCase(PureBaseSharedDriverTestCase):
|
||||||
self.array.create_host],
|
self.array.create_host],
|
||||||
self.driver._connect, self.array, vol_name, FC_CONNECTOR)
|
self.driver._connect, self.array, vol_name, FC_CONNECTOR)
|
||||||
|
|
||||||
|
self.mock_config.safe_get.return_value = 'oracle-vm-server'
|
||||||
|
|
||||||
|
# Branch where we fail due to invalid version for setting personality
|
||||||
|
self.assertRaises(pure.PureDriverException, self.driver._connect,
|
||||||
|
self.array, vol_name, FC_CONNECTOR)
|
||||||
|
self.assertTrue(self.array.create_host.called)
|
||||||
|
self.assertFalse(self.array.set_host.called)
|
||||||
|
|
||||||
|
self.array.get_rest_version.return_value = '1.14'
|
||||||
|
|
||||||
|
# Branch where personality is set
|
||||||
|
self.driver._connect(self.array, vol_name, FC_CONNECTOR)
|
||||||
|
self.assertDictEqual(result, real_result)
|
||||||
|
self.array.set_host.assert_called_with(PURE_HOST_NAME,
|
||||||
|
personality='oracle-vm-server')
|
||||||
|
|
||||||
@mock.patch(FC_DRIVER_OBJ + "._get_host", autospec=True)
|
@mock.patch(FC_DRIVER_OBJ + "._get_host", autospec=True)
|
||||||
def test_connect_already_connected(self, mock_host):
|
def test_connect_already_connected(self, mock_host):
|
||||||
vol, vol_name = self.new_fake_vol()
|
vol, vol_name = self.new_fake_vol()
|
||||||
|
|
|
@ -1904,6 +1904,38 @@ class PureBaseVolumeDriver(san.SanDriver):
|
||||||
|
|
||||||
return secondary_array.backend_id, model_updates, []
|
return secondary_array.backend_id, model_updates, []
|
||||||
|
|
||||||
|
@pure_driver_debug_trace
|
||||||
|
def get_check_personality(self, array):
|
||||||
|
personality = self.configuration.safe_get('pure_host_personality')
|
||||||
|
if personality:
|
||||||
|
api_version = array.get_rest_version()
|
||||||
|
if api_version not in PERSONALITY_REQUIRED_API_VERSIONS:
|
||||||
|
# Continuing here would mean creating a host not according
|
||||||
|
# to specificiations, possibly leading to unexpected
|
||||||
|
# behavior later on.
|
||||||
|
msg = _('Unable to set host personality with Purity REST '
|
||||||
|
'API version %(api_version)s, requires '
|
||||||
|
'%(required_versions)s.') % {
|
||||||
|
'api_version': api_version,
|
||||||
|
'required_versions': PERSONALITY_REQUIRED_API_VERSIONS
|
||||||
|
}
|
||||||
|
raise PureDriverException(reason=msg)
|
||||||
|
return personality
|
||||||
|
|
||||||
|
@pure_driver_debug_trace
|
||||||
|
def set_personality(self, array, host_name, personality):
|
||||||
|
try:
|
||||||
|
array.set_host(host_name, personality=personality)
|
||||||
|
except purestorage.PureHTTPError as err:
|
||||||
|
if (err.code == 400 and
|
||||||
|
ERR_MSG_HOST_NOT_EXIST in err.text):
|
||||||
|
# If the host disappeared out from under us that's
|
||||||
|
# ok, we will just retry and snag a new host.
|
||||||
|
LOG.debug('Unable to set host personality: %s',
|
||||||
|
err.text)
|
||||||
|
raise PureRetryableException()
|
||||||
|
return
|
||||||
|
|
||||||
def _swap_replication_state(self, current_array, secondary_array,
|
def _swap_replication_state(self, current_array, secondary_array,
|
||||||
failback=False):
|
failback=False):
|
||||||
# After failover we want our current array to be swapped for the
|
# After failover we want our current array to be swapped for the
|
||||||
|
@ -2539,21 +2571,7 @@ class PureISCSIDriver(PureBaseVolumeDriver, san.SanISCSIDriver):
|
||||||
reason=_("Unable to re-use host with unknown CHAP "
|
reason=_("Unable to re-use host with unknown CHAP "
|
||||||
"credentials configured."))
|
"credentials configured."))
|
||||||
else:
|
else:
|
||||||
personality = self.configuration.safe_get('pure_host_personality')
|
personality = self.get_check_personality(array)
|
||||||
if personality:
|
|
||||||
api_version = array.get_rest_version()
|
|
||||||
if api_version not in PERSONALITY_REQUIRED_API_VERSIONS:
|
|
||||||
# Continuing here would mean creating a host not according
|
|
||||||
# to specificiations, possibly leading to unexpected
|
|
||||||
# behavior later on.
|
|
||||||
msg = _('Unable to set host personality with Purity REST '
|
|
||||||
'API version %(api_version)s, requires '
|
|
||||||
'%(required_versions)s.') % {
|
|
||||||
'api_version': api_version,
|
|
||||||
'required_versions': PERSONALITY_REQUIRED_API_VERSIONS
|
|
||||||
}
|
|
||||||
raise PureDriverException(reason=msg)
|
|
||||||
|
|
||||||
host_name = self._generate_purity_host_name(connector["host"])
|
host_name = self._generate_purity_host_name(connector["host"])
|
||||||
LOG.info("Creating host object %(host_name)r with IQN:"
|
LOG.info("Creating host object %(host_name)r with IQN:"
|
||||||
" %(iqn)s.", {"host_name": host_name, "iqn": iqn})
|
" %(iqn)s.", {"host_name": host_name, "iqn": iqn})
|
||||||
|
@ -2569,16 +2587,7 @@ class PureISCSIDriver(PureBaseVolumeDriver, san.SanISCSIDriver):
|
||||||
raise PureRetryableException()
|
raise PureRetryableException()
|
||||||
|
|
||||||
if personality:
|
if personality:
|
||||||
try:
|
self.set_personality(array, host_name, personality)
|
||||||
array.set_host(host_name, personality=personality)
|
|
||||||
except purestorage.PureHTTPError as err:
|
|
||||||
if (err.code == 400 and
|
|
||||||
ERR_MSG_HOST_NOT_EXIST in err.text):
|
|
||||||
# If the host disappeared out from under us that's
|
|
||||||
# ok, we will just retry and snag a new host.
|
|
||||||
LOG.debug('Unable to set host personality: %s',
|
|
||||||
err.text)
|
|
||||||
raise PureRetryableException()
|
|
||||||
|
|
||||||
if self.configuration.use_chap_auth:
|
if self.configuration.use_chap_auth:
|
||||||
try:
|
try:
|
||||||
|
@ -2694,6 +2703,7 @@ class PureFCDriver(PureBaseVolumeDriver, driver.FibreChannelDriver):
|
||||||
LOG.info("Re-using existing purity host %(host_name)r",
|
LOG.info("Re-using existing purity host %(host_name)r",
|
||||||
{"host_name": host_name})
|
{"host_name": host_name})
|
||||||
else:
|
else:
|
||||||
|
personality = self.get_check_personality(array)
|
||||||
host_name = self._generate_purity_host_name(connector["host"])
|
host_name = self._generate_purity_host_name(connector["host"])
|
||||||
LOG.info("Creating host object %(host_name)r with WWN:"
|
LOG.info("Creating host object %(host_name)r with WWN:"
|
||||||
" %(wwn)s.", {"host_name": host_name, "wwn": wwns})
|
" %(wwn)s.", {"host_name": host_name, "wwn": wwns})
|
||||||
|
@ -2708,6 +2718,9 @@ class PureFCDriver(PureBaseVolumeDriver, driver.FibreChannelDriver):
|
||||||
LOG.debug('Unable to create host: %s', err.text)
|
LOG.debug('Unable to create host: %s', err.text)
|
||||||
raise PureRetryableException()
|
raise PureRetryableException()
|
||||||
|
|
||||||
|
if personality:
|
||||||
|
self.set_personality(array, host_name, personality)
|
||||||
|
|
||||||
# TODO(patrickeast): Ensure that the host has the correct preferred
|
# TODO(patrickeast): Ensure that the host has the correct preferred
|
||||||
# arrays configured for it.
|
# arrays configured for it.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Pure Storage driver: Add missing support for ``host_personality`` setting
|
||||||
|
for FC-based hosts
|
Loading…
Reference in New Issue