ensure that we can delete shares in cephfs
This commit is contained in:
parent
ac1048ed1c
commit
6294e8fd0c
@ -59,6 +59,10 @@ delete-share:
|
||||
exist then this action will have no effect.
|
||||
type: string
|
||||
default:
|
||||
purge:
|
||||
type: boolean
|
||||
default: False
|
||||
description: Delete the backing CephFS share as well.
|
||||
list-shares:
|
||||
description: List all shares that this application is managing
|
||||
# TODO: Update, delete share
|
@ -434,7 +434,8 @@ class CephNfsCharm(
|
||||
return
|
||||
client = GaneshaNfs(self.client_name, self.pool_name)
|
||||
name = event.params.get('name')
|
||||
client.delete_share(name)
|
||||
purge = event.params.get('purge')
|
||||
client.delete_share(name, purge=purge)
|
||||
self.peers.trigger_reload()
|
||||
event.set_results({
|
||||
"message": "Share deleted",
|
||||
|
@ -177,7 +177,7 @@ class GaneshaNfs(object):
|
||||
logging.warning("Encountered an independently created export")
|
||||
return exports
|
||||
|
||||
def delete_share(self, name: str):
|
||||
def delete_share(self, name: str, purge=False):
|
||||
share = [share for share in self.list_shares() if share.name == name]
|
||||
if share:
|
||||
share = share[0]
|
||||
@ -189,6 +189,8 @@ class GaneshaNfs(object):
|
||||
self._remove_share_from_index(share.export_id)
|
||||
logging.debug("Removing export file from RADOS")
|
||||
self._rados_rm('ganesha-export-{}'.format(share.export_id))
|
||||
if purge:
|
||||
self._delete_cephfs_share(name)
|
||||
|
||||
def grant_access(self, name: str, client: str) -> Optional[str]:
|
||||
share = self.get_share(name)
|
||||
@ -248,6 +250,16 @@ class GaneshaNfs(object):
|
||||
logging.debug("About to call: {}".format(cmd))
|
||||
return subprocess.check_output(cmd)
|
||||
|
||||
def _delete_cephfs_share(self, name: str):
|
||||
"""Delete a CephFS share.
|
||||
|
||||
:param name: String name of the share to create
|
||||
"""
|
||||
self._ceph_subvolume_command(
|
||||
'deauthorize', 'ceph-fs', name,
|
||||
'ganesha-{name}'.format(name=name))
|
||||
self._ceph_subvolume_command('rm', 'ceph-fs', name)
|
||||
|
||||
def _create_cephfs_share(self, name: str, size_in_bytes: int = None):
|
||||
"""Create an authorise a CephFS share.
|
||||
|
||||
|
@ -48,6 +48,7 @@ class NfsGaneshaTest(unittest.TestCase):
|
||||
'delete-share',
|
||||
action_params={
|
||||
'name': self.created_share,
|
||||
'purge': True
|
||||
})
|
||||
|
||||
def _create_share(self, name: str, size: int = 10,
|
||||
|
Loading…
Reference in New Issue
Block a user