Merge "Fix HDS HNAS manage incorrect share size"
This commit is contained in:
commit
e9f2dcc471
@ -658,12 +658,16 @@ class HNASSSHBackend(object):
|
||||
'No quotas matching' not in items[i]):
|
||||
if 'Limit' in items[i] and 'Hard' in items[i]:
|
||||
quota = float(items[i].split(' ')[12])
|
||||
|
||||
# If the quota is 1 or more TB, converts to GB
|
||||
if items[i].split(' ')[13] == 'TB':
|
||||
return quota * units.Ki
|
||||
|
||||
return quota
|
||||
size_unit = items[i].split(' ')[13]
|
||||
if size_unit in ('TB', 'GB'):
|
||||
# If the quota is 1 or more TB, converts to GB
|
||||
if size_unit == 'TB':
|
||||
return quota * units.Ki
|
||||
return quota
|
||||
else:
|
||||
msg = (_("Share %s does not support quota values "
|
||||
"below 1GB.") % share_id)
|
||||
raise exception.HNASBackendException(msg=msg)
|
||||
else:
|
||||
# Returns None if the quota is unset
|
||||
return None
|
||||
|
@ -122,6 +122,22 @@ Generate Events : Disabled
|
||||
Global id : 28a3c9f8-ae05-11d0-9025-836896aada5d
|
||||
Last modified : 2015-06-23 22:37:17.363660800+00:00 """
|
||||
|
||||
HNAS_RESULT_quota_mb = """Type : Explicit
|
||||
Target : ViVol: vvol_test
|
||||
Usage : 0 B
|
||||
Limit : 500 MB (Hard)
|
||||
Warning : Unset
|
||||
Critical : Unset
|
||||
Reset : 5% (51.2 MB)
|
||||
File Count : 1
|
||||
Limit : Unset
|
||||
Warning : Unset
|
||||
Critical : Unset
|
||||
Reset : 5% (0)
|
||||
Generate Events : Disabled
|
||||
Global id : 28a3c9f8-ae05-11d0-9025-836896aada5d
|
||||
Last modified : 2015-06-23 22:37:17.363660800+00:00 """
|
||||
|
||||
HNAS_RESULT_quota_unset = """Type : Explicit
|
||||
Target : ViVol: vvol_test
|
||||
Usage : 0 B
|
||||
@ -922,6 +938,21 @@ class HNASSSHTestCase(test.TestCase):
|
||||
self.vvol, self.vvol['id'])
|
||||
ssh.HNASSSHBackend._execute.assert_called_with(fake_list_command)
|
||||
|
||||
def test_manage_existing_share_invalid_size(self):
|
||||
fake_list_command = ['quota', 'list', 'file_system', 'vvol_test']
|
||||
self.mock_object(ssh.HNASSSHBackend, '_execute',
|
||||
mock.Mock(side_effect=[(HNAS_RESULT_fs, ""),
|
||||
(HNAS_RESULT_fs, ""),
|
||||
(HNAS_RESULT_vvol, ""),
|
||||
(HNAS_RESULT_quota, ""),
|
||||
(HNAS_RESULT_export, ""),
|
||||
(HNAS_RESULT_quota_mb, "")]))
|
||||
|
||||
self.assertRaises(exception.HNASBackendException,
|
||||
self._driver.manage_existing,
|
||||
self.vvol, self.vvol['id'])
|
||||
ssh.HNASSSHBackend._execute.assert_called_with(fake_list_command)
|
||||
|
||||
def test_create_snapshot(self):
|
||||
fake_create_command = ['tree-clone-job-submit', '-e',
|
||||
'-f', 'file_system', '/shares/vvol_test',
|
||||
|
Loading…
x
Reference in New Issue
Block a user