Skip to content

Commit

Permalink
ceph-daemon: infer fsid for shell, enter, ceph-volume, unit, logs
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Fritch <mfritch@suse.com>
  • Loading branch information
mgfritch committed Nov 19, 2019
1 parent c1b142e commit da6fa2f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/ceph-daemon/ceph-daemon
Expand Up @@ -60,6 +60,7 @@ except ImportError:
import uuid

from distutils.spawn import find_executable
from functools import wraps
from glob import glob

try:
Expand Down Expand Up @@ -226,6 +227,38 @@ def is_fsid(s):
return False
return True


def infer_fsid(func):
"""
If we only find a single fsid in /var/lib/ceph/*, use that
"""
@wraps(func)
def _infer_fsid():
if args.fsid:
logger.debug('Using specified fsid: %s' % args.fsid)
return

fsid_list = []
for i in os.listdir(args.data_dir):
if is_fsid(i):
fsid_list.append(i)

logger.info('Found fsid: %s' % str(fsid_list))

if not fsid_list:
# TODO: raise?
return

if len(fsid_list) > 1:
raise RuntimeError('Cannot infer fsid, must specify --fsid')

logger.info('Inferring fsid %s' % fsid_list[0])
args.fsid = fsid_list[0]
return _infer_fsid




def makedirs(dir, uid, gid, mode):
# type: (str, int, int, int) -> None
if not os.path.exists(dir):
Expand Down Expand Up @@ -1258,6 +1291,7 @@ def command_run():

##################################

@infer_fsid
def command_shell():
# type: () -> int
if args.fsid:
Expand Down Expand Up @@ -1296,6 +1330,7 @@ def command_shell():

##################################

@infer_fsid
def command_enter():
# type: () -> int
(daemon_type, daemon_id) = args.name.split('.', 1)
Expand All @@ -1315,6 +1350,7 @@ def command_enter():

##################################

@infer_fsid
def command_ceph_volume():
# type: () -> None
make_log_dir(args.fsid)
Expand Down Expand Up @@ -1357,6 +1393,7 @@ def command_ceph_volume():

##################################

@infer_fsid
def command_unit():
# type: () -> None
(daemon_type, daemon_id) = args.name.split('.', 1)
Expand All @@ -1368,6 +1405,7 @@ def command_unit():

##################################

@infer_fsid
def command_logs():
# type: () -> None
cmd = [container_path, 'logs']
Expand Down

0 comments on commit da6fa2f

Please sign in to comment.