diff options
author | John Mulligan <jmulligan@redhat.com> | 2023-11-19 22:35:06 +0100 |
---|---|---|
committer | John Mulligan <jmulligan@redhat.com> | 2024-01-02 15:30:21 +0100 |
commit | 08e7a56ead5d3a241cd626d0436dff24867d3445 (patch) | |
tree | f9c88cc75ad25b83d48ee2b3c8d5578c37dcab48 /src/cephadm/cephadm.py | |
parent | cephadm: remove a non-functional line in _rm_cluster (diff) | |
download | ceph-08e7a56ead5d3a241cd626d0436dff24867d3445.tar.xz ceph-08e7a56ead5d3a241cd626d0436dff24867d3445.zip |
cephadm: call functions instead of executing rm in rm_cluster
Convert a bunch of invocations of rm via a subprocess to function calls.
This should make it easier (or possible?) to test the function
in the unit test framework as well as possibly saving a few resources.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Diffstat (limited to '')
-rwxr-xr-x | src/cephadm/cephadm.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 23352651f27..636c2161547 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -4326,25 +4326,30 @@ def _rm_cluster(ctx: CephadmContext, keep_logs: bool, zap_osds: bool) -> None: shutil.rmtree(unit_dir / f'ceph-{ctx.fsid}.target.wants', ignore_errors=True) # rm data - call_throws(ctx, ['rm', '-rf', ctx.data_dir + '/' + ctx.fsid]) + shutil.rmtree(Path(ctx.data_dir) / ctx.fsid, ignore_errors=True) if not keep_logs: # rm logs - call_throws(ctx, ['rm', '-rf', ctx.log_dir + '/' + ctx.fsid]) + shutil.rmtree(Path(ctx.log_dir) / ctx.fsid, ignore_errors=True) # rm logrotate config - call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/ceph-%s' % ctx.fsid]) + unlink_file( + Path(ctx.logrotate_dir) / ('ceph-%s' % ctx.fsid), ignore_errors=True + ) # if last cluster on host remove shared files if get_ceph_cluster_count(ctx) == 0: terminate_service(ctx, 'ceph.target') # rm shared ceph target files - call_throws(ctx, ['rm', '-f', ctx.unit_dir + '/multi-user.target.wants/ceph.target']) - call_throws(ctx, ['rm', '-f', ctx.unit_dir + '/ceph.target']) + unlink_file( + Path(ctx.unit_dir) / 'multi-user.target.wants/ceph.target', + ignore_errors=True + ) + unlink_file(Path(ctx.unit_dir) / 'ceph.target', ignore_errors=True) # rm cephadm logrotate config - call_throws(ctx, ['rm', '-f', ctx.logrotate_dir + '/cephadm']) + unlink_file(Path(ctx.logrotate_dir) / 'cephadm', ignore_errors=True) if not keep_logs: # remove all cephadm logs |