import uuid
from distutils.spawn import find_executable
+from functools import wraps
from glob import glob
try:
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.debug('Found fsids %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 func()
+ return _infer_fsid
+
def makedirs(dir, uid, gid, mode):
# type: (str, int, int, int) -> None
if not os.path.exists(dir):
##################################
+@infer_fsid
def command_shell():
# type: () -> int
if args.fsid:
##################################
+@infer_fsid
def command_enter():
# type: () -> int
(daemon_type, daemon_id) = args.name.split('.', 1)
##################################
+@infer_fsid
def command_ceph_volume():
# type: () -> None
make_log_dir(args.fsid)
##################################
+@infer_fsid
def command_unit():
# type: () -> None
(daemon_type, daemon_id) = args.name.split('.', 1)
##################################
+@infer_fsid
def command_logs():
# type: () -> None
cmd = [container_path, 'logs']
parser_enter.set_defaults(func=command_enter)
parser_enter.add_argument(
'--fsid',
- required=True,
help='cluster FSID')
parser_enter.add_argument(
'--name', '-n',
parser_ceph_volume.set_defaults(func=command_ceph_volume)
parser_ceph_volume.add_argument(
'--fsid',
- required=True,
help='cluster FSID')
parser_ceph_volume.add_argument(
'--config-and-keyring',
help='systemd command (start, stop, restart, enable, disable, ...)')
parser_unit.add_argument(
'--fsid',
- required=True,
help='cluster FSID')
parser_unit.add_argument(
'--name', '-n',
parser_logs.set_defaults(func=command_logs)
parser_logs.add_argument(
'--fsid',
- required=True,
help='cluster FSID')
parser_logs.add_argument(
'--name', '-n',