Skip to content

Commit 8af7aad

Browse files
mgr/smb: extend password filtering to cluster commands
The imperative commands like `ceph smb cluster create` may involve setting and reporting outputs that have passwords. Use the previously established password filter mechanism there (and use the new _apply_res function everywhere for completeness). Signed-off-by: John Mulligan <[email protected]>
1 parent bb38fec commit 8af7aad

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/pybind/mgr/smb/module.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def internal_store_backend(self) -> str:
145145
def _apply_res(
146146
self,
147147
resource_input: List[resources.SMBResource],
148+
create_only: bool = False,
148149
password_filter: InputPasswordFilter = InputPasswordFilter.NONE,
149150
password_filter_out: Optional[PasswordFilter] = None,
150151
) -> results.ResultGroup:
@@ -155,7 +156,9 @@ def _apply_res(
155156
in_op = (in_pf, PasswordFilter.NONE)
156157
log.debug('Password filtering for resource apply: %r', in_op)
157158
resource_input = [r.convert(in_op) for r in resource_input]
158-
all_results = self._handler.apply(resource_input)
159+
all_results = self._handler.apply(
160+
resource_input, create_only=create_only
161+
)
159162
if out_pf is not PasswordFilter.NONE:
160163
# we need to apply the conversion filter to the output
161164
# resources in the results - otherwise we would show raw
@@ -208,6 +211,8 @@ def cluster_create(
208211
placement: Optional[str] = None,
209212
clustering: Optional[SMBClustering] = None,
210213
public_addrs: Optional[List[str]] = None,
214+
password_filter: InputPasswordFilter = InputPasswordFilter.NONE,
215+
password_filter_out: Optional[PasswordFilter] = None,
211216
) -> results.Result:
212217
"""Create an smb cluster"""
213218
domain_settings = None
@@ -318,13 +323,24 @@ def cluster_create(
318323
public_addrs=c_public_addrs,
319324
)
320325
to_apply.append(cluster)
321-
return self._handler.apply(to_apply, create_only=True).squash(cluster)
326+
return self._apply_res(
327+
to_apply,
328+
create_only=True,
329+
password_filter=password_filter,
330+
password_filter_out=password_filter_out,
331+
).squash(cluster)
322332

323333
@cli.SMBCommand('cluster rm', perm='rw')
324-
def cluster_rm(self, cluster_id: str) -> results.Result:
334+
def cluster_rm(
335+
self,
336+
cluster_id: str,
337+
password_filter: PasswordFilter = PasswordFilter.NONE,
338+
) -> results.Result:
325339
"""Remove an smb cluster"""
326340
cluster = resources.RemovedCluster(cluster_id=cluster_id)
327-
return self._handler.apply([cluster]).one()
341+
return self._apply_res(
342+
[cluster], password_filter_out=password_filter
343+
).one()
328344

329345
@cli.SMBCommand('share ls', perm='r')
330346
def share_ls(self, cluster_id: str) -> List[str]:
@@ -360,15 +376,15 @@ def share_create(
360376
subvolume=subvolume,
361377
),
362378
)
363-
return self._handler.apply([share], create_only=True).one()
379+
return self._apply_res([share], create_only=True).one()
364380

365381
@cli.SMBCommand('share rm', perm='rw')
366382
def share_rm(self, cluster_id: str, share_id: str) -> results.Result:
367383
"""Remove an smb share"""
368384
share = resources.RemovedShare(
369385
cluster_id=cluster_id, share_id=share_id
370386
)
371-
return self._handler.apply([share]).one()
387+
return self._apply_res([share]).one()
372388

373389
@cli.SMBCommand("show", perm="r")
374390
def show(

0 commit comments

Comments
 (0)