ScaleIO to get volume name from connection properties
Currently ScaleIO is doing a HTTP request to find out what is the volume id. This change will take it from the connection properties. It is more accurate and saves time. Change-Id: Id5d9445c7028141c37ce514476e501502cb8a25b
This commit is contained in:
parent
d5fe51cb54
commit
1b4aee13c6
@ -2768,6 +2768,7 @@ class ScaleIOConnector(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']
|
||||
self.server_ip = connection_properties['serverIP']
|
||||
self.server_port = connection_properties['serverPort']
|
||||
self.server_username = connection_properties['serverUsername']
|
||||
@ -2799,6 +2800,7 @@ class ScaleIOConnector(BaseLinuxConnector):
|
||||
"bandwidth limit: %(bandwidth_limit)s."
|
||||
), {
|
||||
'volume_name': self.volume_name,
|
||||
'volume_id': self.volume_id,
|
||||
'sdc_ip': self.local_sdc_ip,
|
||||
'server_ip': self.server_ip,
|
||||
'username': self.server_username,
|
||||
@ -2826,7 +2828,7 @@ class ScaleIOConnector(BaseLinuxConnector):
|
||||
guid = out
|
||||
LOG.info(_LI("Current sdc guid: %(guid)s"), {'guid': guid})
|
||||
params = {'guid': guid, 'allowMultipleMappings': 'TRUE'}
|
||||
self.volume_id = self._get_volume_id()
|
||||
self.volume_id = self.volume_id or self._get_volume_id()
|
||||
|
||||
headers = {'content-type': 'application/json'}
|
||||
request = (
|
||||
@ -2921,7 +2923,7 @@ class ScaleIOConnector(BaseLinuxConnector):
|
||||
:type device_info: dict
|
||||
"""
|
||||
self.get_config(connection_properties)
|
||||
self.volume_id = self._get_volume_id()
|
||||
self.volume_id = self.volume_id or self._get_volume_id()
|
||||
LOG.info(_LI(
|
||||
"ScaleIO disconnect volume in ScaleIO brick volume driver."
|
||||
))
|
||||
|
@ -2490,7 +2490,8 @@ class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
# Fake volume information
|
||||
vol = {
|
||||
'id': 'vol1',
|
||||
'name': 'test_volume'
|
||||
'name': 'test_volume',
|
||||
'provider_id': 'vol1'
|
||||
}
|
||||
|
||||
# Fake SDC GUID
|
||||
@ -2503,6 +2504,7 @@ class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
'hostIP': MY_IP,
|
||||
'serverIP': MY_IP,
|
||||
'scaleIO_volname': self.vol['name'],
|
||||
'scaleIO_volume_id': self.vol['provider_id'],
|
||||
'serverPort': 443,
|
||||
'serverUsername': 'test',
|
||||
'serverPassword': 'fake',
|
||||
@ -2655,6 +2657,7 @@ class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
|
||||
def test_error_id(self):
|
||||
"""Fail to connect with bad volume name"""
|
||||
self.fake_connection_properties['scaleIO_volume_id'] = 'bad_id'
|
||||
self.mock_calls[self.get_volume_api] = self.MockHTTPSResponse(
|
||||
dict(errorCode='404', message='Test volume not found'), 404)
|
||||
|
||||
@ -2662,6 +2665,7 @@ class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
|
||||
def test_error_no_volume_id(self):
|
||||
"""Faile to connect with no volume id"""
|
||||
self.fake_connection_properties['scaleIO_volume_id'] = None
|
||||
self.mock_calls[self.get_volume_api] = self.MockHTTPSResponse(
|
||||
'null', 200)
|
||||
|
||||
@ -2671,9 +2675,9 @@ class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
"""Fail to connect with bad authentication"""
|
||||
self.mock_calls[self.get_volume_api] = self.MockHTTPSResponse(
|
||||
'null', 401)
|
||||
|
||||
self.mock_calls['login'] = self.MockHTTPSResponse('null', 401)
|
||||
|
||||
self.mock_calls[self.action_format.format(
|
||||
'addMappedSdc')] = self.MockHTTPSResponse(
|
||||
dict(errorCode=401, message='bad login'), 401)
|
||||
self.assertRaises(exception.BrickException, self.test_connect_volume)
|
||||
|
||||
def test_error_bad_drv_cfg(self):
|
||||
|
Loading…
Reference in New Issue
Block a user