Dell EMC SC: API 4.0 incompatibilities
4.0 folder paths begin with a /. Also add a check that the user formatted
the folder path correctly.
Change-Id: I9bdc17c3f0daab97c33908bf3b96fbce963aa9f2
Closes-Bug: #1719428
(cherry picked from commit d414696c66
)
This commit is contained in:
parent
b9d4b34fc8
commit
bfc740588f
@ -1699,6 +1699,8 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
self.scapi.vfname = self.configuration.dell_sc_volume_folder
|
||||
# Note that we set this to True (or not) on the replication tests.
|
||||
self.scapi.failed_over = False
|
||||
# Legacy folder names are still current so we default this to true.
|
||||
self.scapi.legacyfoldernames = True
|
||||
|
||||
self.volid = str(uuid.uuid4())
|
||||
self.volume_name = "volume" + self.volid
|
||||
@ -1871,8 +1873,7 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
self.assertIsNone(res, 'Expected None')
|
||||
|
||||
@mock.patch.object(storagecenter_api.SCApi,
|
||||
'_get_result',
|
||||
return_value=u'devstackvol/fcvm/')
|
||||
'_get_result')
|
||||
@mock.patch.object(storagecenter_api.HttpClient,
|
||||
'post',
|
||||
return_value=RESPONSE_200)
|
||||
@ -1882,12 +1883,46 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
res = self.scapi._find_folder(
|
||||
'StorageCenter/ScVolumeFolder',
|
||||
self.configuration.dell_sc_volume_folder)
|
||||
self.assertTrue(mock_post.called)
|
||||
self.scapi._find_folder('StorageCenter/ScVolumeFolder/GetList',
|
||||
'devstackvol/fcvm', 12345)
|
||||
expected_payload = {'filter': {'filterType': 'AND', 'filters': [
|
||||
{'filterType': 'Equals', 'attributeName': 'scSerialNumber',
|
||||
'attributeValue': 12345},
|
||||
{'filterType': 'Equals', 'attributeName': 'Name',
|
||||
'attributeValue': 'fcvm'},
|
||||
{'filterType': 'Equals', 'attributeName': 'folderPath',
|
||||
'attributeValue': 'devstackvol/'}]}}
|
||||
mock_post.assert_called_once_with(
|
||||
'StorageCenter/ScVolumeFolder/GetList',
|
||||
expected_payload)
|
||||
self.assertTrue(mock_get_result.called)
|
||||
self.assertEqual(u'devstackvol/fcvm/', res, 'Unexpected folder')
|
||||
|
||||
@mock.patch.object(storagecenter_api.SCApi,
|
||||
'_get_result')
|
||||
@mock.patch.object(storagecenter_api.HttpClient,
|
||||
'post',
|
||||
return_value=RESPONSE_200)
|
||||
def test_find_folder_not_legacy(self,
|
||||
mock_post,
|
||||
mock_get_result,
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
self.scapi.legacyfoldernames = False
|
||||
self.scapi._find_folder('StorageCenter/ScVolumeFolder/GetList',
|
||||
'devstackvol/fcvm', 12345)
|
||||
expected_payload = {'filter': {'filterType': 'AND', 'filters': [
|
||||
{'filterType': 'Equals', 'attributeName': 'scSerialNumber',
|
||||
'attributeValue': 12345},
|
||||
{'filterType': 'Equals', 'attributeName': 'Name',
|
||||
'attributeValue': 'fcvm'},
|
||||
{'filterType': 'Equals', 'attributeName': 'folderPath',
|
||||
'attributeValue': '/devstackvol/'}]}}
|
||||
mock_post.assert_called_once_with(
|
||||
'StorageCenter/ScVolumeFolder/GetList',
|
||||
expected_payload)
|
||||
self.assertTrue(mock_get_result.called)
|
||||
self.scapi.legacyfoldernames = True
|
||||
|
||||
@mock.patch.object(storagecenter_api.SCApi,
|
||||
'_get_result',
|
||||
|
@ -449,6 +449,7 @@ class SCApi(object):
|
||||
self.consisgroups = True
|
||||
self.protocol = 'Iscsi'
|
||||
self.apiversion = apiversion
|
||||
self.legacyfoldernames = True
|
||||
# Nothing other than Replication should care if we are direct connect
|
||||
# or not.
|
||||
self.is_direct_connect = False
|
||||
@ -659,7 +660,7 @@ class SCApi(object):
|
||||
|
||||
elif splitver[1] == '1':
|
||||
self.legacypayloadfilters = True
|
||||
return
|
||||
self.legacyfoldernames = (splitver[0] < '4')
|
||||
|
||||
except Exception:
|
||||
# Good return but not the login response we were expecting.
|
||||
@ -811,9 +812,14 @@ class SCApi(object):
|
||||
pf.append('scSerialNumber', ssn)
|
||||
basename = os.path.basename(foldername)
|
||||
pf.append('Name', basename)
|
||||
# save the user from themselves.
|
||||
folderpath = foldername.strip('/')
|
||||
folderpath = os.path.dirname(folderpath)
|
||||
# If we have any kind of path we throw it into the filters.
|
||||
folderpath = os.path.dirname(foldername)
|
||||
if folderpath != '':
|
||||
# Legacy didn't begin with a slash.
|
||||
if not self.legacyfoldernames:
|
||||
folderpath = '/' + folderpath
|
||||
# SC convention is to end with a '/' so make sure we do.
|
||||
folderpath += '/'
|
||||
pf.append('folderPath', folderpath)
|
||||
|
Loading…
Reference in New Issue
Block a user