Fix a bug cephfs subvolume size calculation
The charm is documented to take the 'size' in gigabytes. But when passing it down to 'ceph fs subvolume', it's incorrectly calculating the bytes. Closes-Bug: #2078019 Change-Id: I94ebe1bf506ef7741dbf9d2975a7ba82405a41ff Signed-off-by: Ponnuvel Palaniyappan <pponnuvel@gmail.com>
This commit is contained in:
parent
52fb257d66
commit
28a1bb3f3c
@ -126,7 +126,7 @@ class GaneshaNFS(object):
|
||||
if existing_shares:
|
||||
return existing_shares[0].path
|
||||
if size is not None:
|
||||
size_in_bytes = size * 1024 * 1024
|
||||
size_in_bytes = size * 1024 * 1024 * 1024
|
||||
if access_ips is None:
|
||||
access_ips = ['0.0.0.0']
|
||||
# Ganesha deals with networks just fine, except when the network is
|
||||
@ -188,7 +188,7 @@ class GaneshaNFS(object):
|
||||
return exports
|
||||
|
||||
def resize_share(self, name: str, size: int):
|
||||
size_in_bytes = size * 1024 * 1024
|
||||
size_in_bytes = size * 1024 * 1024 * 1024
|
||||
self._ceph_subvolume_command('resize', 'ceph-fs', name,
|
||||
str(size_in_bytes), '--no_shrink')
|
||||
|
||||
|
@ -78,3 +78,43 @@ class ExportTest(unittest.TestCase):
|
||||
[
|
||||
{'Access_Type': 'rw', 'Clients': '10.0.0.0/8, 192.168.0.0/16'},
|
||||
])
|
||||
|
||||
|
||||
class TestGaneshaNFS(unittest.TestCase):
|
||||
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_ceph_subvolume_command')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_ganesha_add_export')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_get_next_export_id')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, 'list_shares')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_ceph_auth_key')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_rados_get')
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_rados_put')
|
||||
@unittest.mock.patch.object(ganesha.Export, 'to_export')
|
||||
def test_create_share(self, mock_export,
|
||||
mock_rados_put,
|
||||
mock_rados_get,
|
||||
mock_auth_key,
|
||||
mock_list_shares,
|
||||
mock_export_id,
|
||||
mock_add_export,
|
||||
mock_subvolume_command):
|
||||
mock_subvolume_command.return_value = b'mock-volume'
|
||||
mock_list_shares.return_value = []
|
||||
mock_export_id.return_value = 1
|
||||
mock_auth_key.return_value = b'mock-auth-key'
|
||||
|
||||
inst = ganesha.GaneshaNFS('ceph-client', 'mypool')
|
||||
inst.create_share('test-create-share', size=3, access_ips=None)
|
||||
|
||||
mock_subvolume_command.assert_any_call('create', 'ceph-fs',
|
||||
'test-create-share',
|
||||
str(3 * 1024 * 1024 * 1024))
|
||||
|
||||
@unittest.mock.patch.object(ganesha.GaneshaNFS, '_ceph_subvolume_command')
|
||||
def test_resize_share(self, mock_subvolume_command):
|
||||
inst = ganesha.GaneshaNFS('ceph-client', 'mypool')
|
||||
inst.resize_share('test-resize-share', 5)
|
||||
mock_subvolume_command.assert_any_call('resize', 'ceph-fs',
|
||||
'test-resize-share',
|
||||
str(5 * 1024 * 1024 * 1024),
|
||||
'--no_shrink')
|
||||
|
Loading…
Reference in New Issue
Block a user