From: Sage Weil Date: Thu, 31 Oct 2019 15:22:09 +0000 (-0500) Subject: ceph-daemon: make second call arg optional X-Git-Tag: v15.1.0~1055^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bb79365548ae666c03f04939a59a4a67608d17a6;p=ceph-ci.git ceph-daemon: make second call arg optional If not specified, pull it from command[0]. Signed-off-by: Sage Weil --- diff --git a/src/ceph-daemon b/src/ceph-daemon index 34c3798095c..e6aebed80c8 100755 --- a/src/ceph-daemon +++ b/src/ceph-daemon @@ -78,7 +78,7 @@ podman_path = None ################################## # Popen wrappers, lifted from ceph-volume -def call(command, desc, verbose=False, **kw): +def call(command, desc=None, verbose=False, **kw): """ Wrap subprocess.Popen to @@ -91,6 +91,8 @@ def call(command, desc, verbose=False, **kw): :param verbose_on_failure: On a non-zero exit status, it will forcefully set logging ON for the terminal """ + if not desc: + desc = command[0] verbose_on_failure = kw.pop('verbose_on_failure', True) logger.debug("Running command: %s" % ' '.join(command)) @@ -234,7 +236,7 @@ def check_unit(unit_name): # various exit codes based on the state of the service, but the # string result is more explicit (and sufficient). try: - out, err, code = call(['systemctl', 'is-enabled', unit_name], 'systemctl') + out, err, code = call(['systemctl', 'is-enabled', unit_name]) enabled = out.strip() == 'enabled' except Exception as e: logger.warning('unable to run systemctl: %s' % e) @@ -242,7 +244,7 @@ def check_unit(unit_name): state = 'unknown' try: - out, err, code = call(['systemctl', 'is-active', unit_name], 'systemctl') + out, err, code = call(['systemctl', 'is-active', unit_name]) out = out.strip() if out in ['active']: state = 'running' @@ -1305,13 +1307,11 @@ def command_ls(): podman_path, 'inspect', '--format', '{{.Id}}', 'ceph-%s-%s' % (fsid, j) - ], - podman_path) + ]) if not code: container_id = out.strip()[0:12] out, err, code = call( - [podman_path, 'exec', container_id, 'ceph', '-v'], - podman_path) + [podman_path, 'exec', container_id, 'ceph', '-v']) if not code and out.startswith('ceph version '): version = out.split(' ')[2] ls.append({ @@ -1410,16 +1410,16 @@ def command_rm_cluster(): # ignore errors here for unit_name in ['ceph-%s.target' % args.fsid, 'ceph-%s-crash.service' % args.fsid]: - call(['systemctl', 'stop', unit_name], 'systemctl', + call(['systemctl', 'stop', unit_name], verbose_on_failure=False) - call(['systemctl', 'reset-failed', unit_name], 'systemctl', + call(['systemctl', 'reset-failed', unit_name], verbose_on_failure=False) - call(['systemctl', 'disable', unit_name], 'systemctl', + call(['systemctl', 'disable', unit_name], verbose_on_failure=False) slice_name = 'system-%s.slice' % (('ceph-%s' % args.fsid).replace('-', '\\x2d')) - call(['systemctl', 'stop', slice_name], 'systemctl', + call(['systemctl', 'stop', slice_name], verbose_on_failure=False) # FIXME: stop + disable individual daemon units, too?