Add support for resizine a CephFS share
This also protects against resizing the share to smaller than the in-use value of the share.
This commit is contained in:
parent
6294e8fd0c
commit
25afd66652
12
actions.yaml
12
actions.yaml
@ -34,6 +34,18 @@ grant-access:
|
||||
description: IP address or network to change access for
|
||||
type: string
|
||||
default:
|
||||
resize-share:
|
||||
description: |
|
||||
Resize a specified share.
|
||||
params:
|
||||
name:
|
||||
description: Name of the share
|
||||
type: string
|
||||
default:
|
||||
size:
|
||||
description: What size (GB) should the share be
|
||||
type: integer
|
||||
default:
|
||||
|
||||
revoke-access:
|
||||
description: |
|
||||
|
16
src/charm.py
16
src/charm.py
@ -200,6 +200,9 @@ class CephNfsCharm(
|
||||
self.framework.observe(
|
||||
self.on.list_shares_action,
|
||||
self.list_shares_action)
|
||||
self.framework.observe(
|
||||
self.on.resize_share_action,
|
||||
self.resize_share_action)
|
||||
self.framework.observe(
|
||||
self.on.delete_share_action,
|
||||
self.delete_share_action
|
||||
@ -470,7 +473,18 @@ class CephNfsCharm(
|
||||
return
|
||||
self.peers.trigger_reload()
|
||||
event.set_results({
|
||||
"message": "Acess revoked",
|
||||
"message": "Access revoked",
|
||||
})
|
||||
|
||||
def resize_share_action(self, event):
|
||||
name = event.params.get('name')
|
||||
size = event.params.get('size')
|
||||
if size is None:
|
||||
event.fail("Size must be set")
|
||||
client = GaneshaNfs(self.client_name, self.pool_name)
|
||||
client.resize_share(name=name, size=size)
|
||||
event.set_results({
|
||||
"message": f"{name} is now {size}GB",
|
||||
})
|
||||
|
||||
|
||||
|
@ -177,6 +177,10 @@ class GaneshaNfs(object):
|
||||
logging.warning("Encountered an independently created export")
|
||||
return exports
|
||||
|
||||
def resize_share(self, name: str, size: int):
|
||||
size_in_bytes = size * 1024 * 1024
|
||||
self._ceph_subvolume_command('resize', 'ceph-fs', name, str(size_in_bytes), '--no_shrink')
|
||||
|
||||
def delete_share(self, name: str, purge=False):
|
||||
share = [share for share in self.list_shares() if share.name == name]
|
||||
if share:
|
||||
|
Loading…
Reference in New Issue
Block a user