Merge "Dell EMC SC: Find volume folder API call fails on root folders"
This commit is contained in:
commit
eee1d29e0a
@ -1924,6 +1924,58 @@ class DellSCSanAPITestCase(test.TestCase):
|
||||
self.assertTrue(mock_get_result.called)
|
||||
self.scapi.legacyfoldernames = True
|
||||
|
||||
@mock.patch.object(storagecenter_api.SCApi,
|
||||
'_get_result')
|
||||
@mock.patch.object(storagecenter_api.HttpClient,
|
||||
'post',
|
||||
return_value=RESPONSE_200)
|
||||
def test_find_folder_legacy_root(self,
|
||||
mock_post,
|
||||
mock_get_result,
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
self.scapi._find_folder('StorageCenter/ScVolumeFolder/GetList',
|
||||
'devstackvol', 12345)
|
||||
expected_payload = {'filter': {'filterType': 'AND', 'filters': [
|
||||
{'filterType': 'Equals', 'attributeName': 'scSerialNumber',
|
||||
'attributeValue': 12345},
|
||||
{'filterType': 'Equals', 'attributeName': 'Name',
|
||||
'attributeValue': 'devstackvol'},
|
||||
{'filterType': 'Equals', 'attributeName': 'folderPath',
|
||||
'attributeValue': ''}]}}
|
||||
mock_post.assert_called_once_with(
|
||||
'StorageCenter/ScVolumeFolder/GetList',
|
||||
expected_payload)
|
||||
self.assertTrue(mock_get_result.called)
|
||||
|
||||
@mock.patch.object(storagecenter_api.SCApi,
|
||||
'_get_result')
|
||||
@mock.patch.object(storagecenter_api.HttpClient,
|
||||
'post',
|
||||
return_value=RESPONSE_200)
|
||||
def test_find_folder_non_legacy_root(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', 12345)
|
||||
expected_payload = {'filter': {'filterType': 'AND', 'filters': [
|
||||
{'filterType': 'Equals', 'attributeName': 'scSerialNumber',
|
||||
'attributeValue': 12345},
|
||||
{'filterType': 'Equals', 'attributeName': 'Name',
|
||||
'attributeValue': 'devstackvol'},
|
||||
{'filterType': 'Equals', 'attributeName': 'folderPath',
|
||||
'attributeValue': '/'}]}}
|
||||
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',
|
||||
return_value=u'devstackvol/fcvm/')
|
||||
|
@ -816,13 +816,15 @@ class SCApi(object):
|
||||
# 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.
|
||||
# Put our path into the filters
|
||||
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 += '/'
|
||||
elif not self.legacyfoldernames:
|
||||
folderpath = '/'
|
||||
pf.append('folderPath', folderpath)
|
||||
folder = None
|
||||
r = self.client.post(url, pf.payload)
|
||||
|
Loading…
Reference in New Issue
Block a user