Fix ScaleIO KeyError after upgrade
A long time ago the driver was changed to store volume_id in the nova database and use that. Previously it would use the volume_name and make a call to get the volume_id. Both should be supported, but as the code path currently throws a KeyError it will never reach the backwards compatible code. This makes sure that the driver works even after an upgrade from Mitaka. Depends-On: https://review.openstack.org/#/c/643130/ Change-Id: Iab6a3ca6bf92dc5606c7723dc6c62bf07fa1d934 Closes-Bug: #1648629
This commit is contained in:
parent
3cfdf89837
commit
05b6c9f9fa
|
@ -267,7 +267,10 @@ class ScaleIOConnector(base.BaseLinuxConnector):
|
|||
def get_config(self, connection_properties):
|
||||
self.local_sdc_ip = connection_properties['hostIP']
|
||||
self.volume_name = connection_properties['scaleIO_volname']
|
||||
self.volume_id = connection_properties['scaleIO_volume_id']
|
||||
# instances which were created before Newton release don't have
|
||||
# 'scaleIO_volume_id' property, in such cases connector will resolve
|
||||
# volume_id from volname
|
||||
self.volume_id = connection_properties.get('scaleIO_volume_id')
|
||||
self.server_ip = connection_properties['serverIP']
|
||||
self.server_port = connection_properties['serverPort']
|
||||
self.server_username = connection_properties['serverUsername']
|
||||
|
|
|
@ -171,6 +171,13 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
|
|||
"""Successful connect to volume"""
|
||||
self.connector.connect_volume(self.fake_connection_properties)
|
||||
|
||||
def test_connect_volume_without_volume_id(self):
|
||||
"""Successful connect to volume without a Volume Id"""
|
||||
connection_properties = dict(self.fake_connection_properties)
|
||||
connection_properties.pop('scaleIO_volume_id')
|
||||
|
||||
self.connector.connect_volume(connection_properties)
|
||||
|
||||
def test_connect_with_bandwidth_limit(self):
|
||||
"""Successful connect to volume with bandwidth limit"""
|
||||
self.fake_connection_properties['bandwidthLimit'] = '500'
|
||||
|
@ -191,6 +198,13 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
|
|||
"""Successful disconnect from volume"""
|
||||
self.connector.disconnect_volume(self.fake_connection_properties, None)
|
||||
|
||||
def test_disconnect_volume_without_volume_id(self):
|
||||
"""Successful disconnect from volume without a Volume Id"""
|
||||
connection_properties = dict(self.fake_connection_properties)
|
||||
connection_properties.pop('scaleIO_volume_id')
|
||||
|
||||
self.connector.disconnect_volume(connection_properties, None)
|
||||
|
||||
def test_error_id(self):
|
||||
"""Fail to connect with bad volume name"""
|
||||
self.fake_connection_properties['scaleIO_volume_id'] = 'bad_id'
|
||||
|
|
Loading…
Reference in New Issue