diff --git a/actions.yaml b/actions.yaml index 0845fa1..ccb3e74 100644 --- a/actions.yaml +++ b/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: | diff --git a/src/charm.py b/src/charm.py index bc60035..f43556d 100755 --- a/src/charm.py +++ b/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", }) diff --git a/src/ganesha.py b/src/ganesha.py index b55a239..34a87bd 100644 --- a/src/ganesha.py +++ b/src/ganesha.py @@ -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: