ScaleIO: Connection info backward compatibility
When we fixed bug 1823200 in Change-ID Iab54c515fe7be252df52b1a0503a251779805759 we made the ScaleIO connector incompatible with the old connection properties dictionary as it only supported the new 'config_group' and 'failed_over' parameters to get the password. This is a problem in any system that is upgraded and has attachments to the array, because the connection properties of those volumes will not contain the new fields and detaching them will result in error "KeyError: 'config_group'". This patch adds compatibility code to support the old connection properties format so we can detach those volumes. This patch includes the release note from Change Ib98043358d51426ca650104ad59a7e09911ee8e9 Related-Bug: #1823200 Change-Id: I6f01a178616b74ed9a86876ca46e7e46eb360518 (cherry picked from commit5450483082
) (cherry picked from commit31589a624f
) Conflicts: os_brick/initiator/connectors/scaleio.py (cherry picked from commitdb95b001e2
)
This commit is contained in:
parent
19f30299bb
commit
173601116e
|
@ -88,11 +88,19 @@ class ScaleIOConnector(base.BaseLinuxConnector):
|
||||||
raise exception.BrickException(message=msg)
|
raise exception.BrickException(message=msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_connector_password(config_group):
|
def _get_password_token(connection_properties):
|
||||||
|
# In old connection format we had the password and token in properties
|
||||||
|
if 'serverPassword' in connection_properties:
|
||||||
|
return (connection_properties['serverPassword'],
|
||||||
|
connection_properties['serverToken'])
|
||||||
|
|
||||||
|
# The new format reads password from file and doesn't have the token
|
||||||
LOG.info("Get ScaleIO connector password from configuration file")
|
LOG.info("Get ScaleIO connector password from configuration file")
|
||||||
try:
|
try:
|
||||||
return priv_scaleio.get_connector_password(CONNECTOR_CONF_PATH,
|
password = priv_scaleio.get_connector_password(
|
||||||
config_group)
|
CONNECTOR_CONF_PATH,
|
||||||
|
connection_properties['config_group'])
|
||||||
|
return password, None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = _("Error getting ScaleIO connector password from "
|
msg = _("Error getting ScaleIO connector password from "
|
||||||
"configuration file: %s") % e
|
"configuration file: %s") % e
|
||||||
|
@ -319,9 +327,8 @@ class ScaleIOConnector(base.BaseLinuxConnector):
|
||||||
self.server_ip = connection_properties['serverIP']
|
self.server_ip = connection_properties['serverIP']
|
||||||
self.server_port = connection_properties['serverPort']
|
self.server_port = connection_properties['serverPort']
|
||||||
self.server_username = connection_properties['serverUsername']
|
self.server_username = connection_properties['serverUsername']
|
||||||
self.server_password = self._get_connector_password(
|
self.server_password, self.server_token = self._get_password_token(
|
||||||
connection_properties['config_group'],
|
connection_properties)
|
||||||
)
|
|
||||||
self.iops_limit = connection_properties['iopsLimit']
|
self.iops_limit = connection_properties['iopsLimit']
|
||||||
self.bandwidth_limit = connection_properties['bandwidthLimit']
|
self.bandwidth_limit = connection_properties['bandwidthLimit']
|
||||||
device_info = {'type': 'block',
|
device_info = {'type': 'block',
|
||||||
|
|
|
@ -172,6 +172,26 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
|
||||||
self.connector.GET_GUID_OP_CODE)
|
self.connector.GET_GUID_OP_CODE)
|
||||||
self.get_password_mock.assert_called_once()
|
self.get_password_mock.assert_called_once()
|
||||||
|
|
||||||
|
def test_connect_volume_old_connection_properties(self):
|
||||||
|
"""Successful connect to volume"""
|
||||||
|
connection_properties = {
|
||||||
|
'hostIP': test_connector.MY_IP,
|
||||||
|
'serverIP': test_connector.MY_IP,
|
||||||
|
'scaleIO_volname': self.vol['name'],
|
||||||
|
'scaleIO_volume_id': self.vol['provider_id'],
|
||||||
|
'serverPort': 443,
|
||||||
|
'serverUsername': 'test',
|
||||||
|
'serverPassword': 'fake',
|
||||||
|
'serverToken': 'fake_token',
|
||||||
|
'iopsLimit': None,
|
||||||
|
'bandwidthLimit': None
|
||||||
|
}
|
||||||
|
|
||||||
|
self.connector.connect_volume(connection_properties)
|
||||||
|
self.get_guid_mock.assert_called_once_with(
|
||||||
|
self.connector.GET_GUID_OP_CODE)
|
||||||
|
self.get_password_mock.assert_not_called()
|
||||||
|
|
||||||
def test_connect_volume_without_volume_id(self):
|
def test_connect_volume_without_volume_id(self):
|
||||||
"""Successful connect to volume without a Volume Id"""
|
"""Successful connect to volume without a Volume Id"""
|
||||||
connection_properties = dict(self.fake_connection_properties)
|
connection_properties = dict(self.fake_connection_properties)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
`Bug #1823200 <https://bugs.launchpad.net/cinder/+bug/1823200>`_:
|
||||||
|
Prior fixes for this bug changed the connection properties but did
|
||||||
|
not take into account an upgrade scenario in which currently attached
|
||||||
|
volumes had the old format connection properties and could fail on
|
||||||
|
detatch with "KeyError: 'config_group'". This release updates the
|
||||||
|
'scaleio' connector to handle this situation. It is only applicable
|
||||||
|
to deployments using a Dell EMC PowerFlex/VxFlex OS/ScaleIO backend.
|
Loading…
Reference in New Issue