diff --git a/os_brick/initiator/connectors/scaleio.py b/os_brick/initiator/connectors/scaleio.py index 9d798eb6d..30215fbfc 100644 --- a/os_brick/initiator/connectors/scaleio.py +++ b/os_brick/initiator/connectors/scaleio.py @@ -66,6 +66,17 @@ class ScaleIOConnector(base.BaseLinuxConnector): self.iops_limit = None self.bandwidth_limit = None + def _get_password_token(self, 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 + password = self._get_connector_password( + connection_properties['config_group']) + return password, None + @staticmethod def get_connector_properties(root_helper, *args, **kwargs): """The ScaleIO connector properties.""" @@ -299,9 +310,8 @@ class ScaleIOConnector(base.BaseLinuxConnector): self.server_ip = connection_properties['serverIP'] self.server_port = connection_properties['serverPort'] self.server_username = connection_properties['serverUsername'] - self.server_password = self._get_connector_password( - connection_properties['config_group'], - ) + self.server_password, self.server_token = self._get_password_token( + connection_properties) self.iops_limit = connection_properties['iopsLimit'] self.bandwidth_limit = connection_properties['bandwidthLimit'] device_info = {'type': 'block', diff --git a/os_brick/tests/initiator/connectors/test_scaleio.py b/os_brick/tests/initiator/connectors/test_scaleio.py index 45f807b8d..8f6b31746 100644 --- a/os_brick/tests/initiator/connectors/test_scaleio.py +++ b/os_brick/tests/initiator/connectors/test_scaleio.py @@ -175,6 +175,24 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase): self.connector.connect_volume(self.fake_connection_properties) 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_password_mock.assert_not_called() + def test_connect_with_bandwidth_limit(self): """Successful connect to volume with bandwidth limit""" self.fake_connection_properties['bandwidthLimit'] = '500' diff --git a/releasenotes/notes/bug-1823200-scaleio-upgrade-3e83b5c9dd148714.yaml b/releasenotes/notes/bug-1823200-scaleio-upgrade-3e83b5c9dd148714.yaml new file mode 100644 index 000000000..ccce93f89 --- /dev/null +++ b/releasenotes/notes/bug-1823200-scaleio-upgrade-3e83b5c9dd148714.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + `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.