From: Shweta Sodani Date: Mon, 20 Apr 2026 09:14:01 +0000 (+0530) Subject: mgr/smb: Add CLI command for RGW share creation X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6a3f3103a8a7498a41c8a90e27952d7e483da11b;p=ceph.git mgr/smb: Add CLI command for RGW share creation - Add 'smb share create rgw' CLI command - Import rgw module for credential management - Fetch RGW credentials using radosgw-admin - Create Share resource with RGWStorage backend - Handle errors from credential fetching This enables users to create SMB shares backed by RGW buckets, similar to 'nfs export create rgw' functionality. Example usage: ceph smb share create rgw mysmb share1 mybucket Signed-off-by: Shweta Sodani --- diff --git a/src/pybind/mgr/smb/module.py b/src/pybind/mgr/smb/module.py index 9badbe57460..185d1b1718d 100644 --- a/src/pybind/mgr/smb/module.py +++ b/src/pybind/mgr/smb/module.py @@ -25,6 +25,7 @@ from . import ( rados_store, resources, results, + rgw, sqlite_store, utils, ) @@ -101,6 +102,7 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): authorizer=authorizer, orch=self._orch_backend(enable_orch=uo), earmark_resolver=earmark_resolver, + tool_execer=self, ) def _backend_store(self, store_conf: str = '') -> ConfigStore: @@ -615,6 +617,48 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): if cid == cluster_id ] + @SMBCLICommand('share create rgw', perm='rw') + def share_create_rgw( + self, + cluster_id: str, + share_id: str, + bucket: str, + share_name: str = '', + user_id: str = '', + readonly: bool = False, + ) -> results.Result: + """Create an SMB share backed by RGW""" + try: + # Pass 'self' which conforms to ToolExecer protocol + ( + fetched_user_id, + access_key, + secret_key, + ) = rgw.fetch_rgw_credentials(self, bucket, user_id) + + share = resources.Share( + cluster_id=cluster_id, + share_id=share_id, + name=share_name or share_id, + readonly=readonly, + rgw=resources.RGWStorage( + bucket=bucket, + user_id=fetched_user_id, + access_key_id=access_key, + secret_access_key=secret_key, + ), + ) + return self._apply_res([share], create_only=True).one() + except ValueError as e: + # Create a minimal share resource for error reporting + error_share = resources.Share( + cluster_id=cluster_id, + share_id=share_id, + name=share_name or share_id, + rgw=resources.RGWStorage(bucket='error'), + ) + return results.ErrorResult(error_share, msg=str(e)) + @SMBCLICommand('share create', perm='rw') def share_create( self,