mirror of
https://github.com/ceph/ceph
synced 2024-12-26 21:43:10 +00:00
cephadm: Infer config on "cephadm shell"
Fixes: https://tracker.ceph.com/issues/44792 Signed-off-by: Ricardo Marques <rimarques@suse.com>
This commit is contained in:
parent
cd94861e96
commit
eb732dcbc5
@ -114,10 +114,12 @@ host. However, we recommend enabling easy access to the the ``ceph``
|
||||
command. There are several ways to do this:
|
||||
|
||||
* The ``cephadm shell`` command launches a bash shell in a container
|
||||
with all of the Ceph packages installed. By default, if
|
||||
with all of the Ceph packages installed. By default, if
|
||||
configuration and keyring files are found in ``/etc/ceph`` on the
|
||||
host, they are passed into the container environment so that the
|
||||
shell is fully functional::
|
||||
shell is fully functional. Note that when executed on a MON host,
|
||||
``cephadm shell`` will infer the ``config`` from the MON container
|
||||
instead of using the default configuration::
|
||||
|
||||
# cephadm shell
|
||||
|
||||
|
@ -1078,6 +1078,36 @@ def infer_fsid(func):
|
||||
|
||||
return _infer_fsid
|
||||
|
||||
def infer_config(func):
|
||||
"""
|
||||
If we find a MON daemon, use the config from that container
|
||||
"""
|
||||
@wraps(func)
|
||||
def _infer_config():
|
||||
if args.config:
|
||||
logger.debug('Using specified config: %s' % args.config)
|
||||
return func()
|
||||
config = None
|
||||
if args.fsid:
|
||||
name = args.name
|
||||
if not name:
|
||||
daemon_list = list_daemons(detail=False)
|
||||
for daemon in daemon_list:
|
||||
if daemon['name'].startswith('mon.'):
|
||||
name = daemon['name']
|
||||
break
|
||||
if name:
|
||||
config = '/var/lib/ceph/{}/{}/config'.format(args.fsid, name)
|
||||
if config:
|
||||
logger.info('Inferring config %s' % config)
|
||||
args.config = config
|
||||
elif os.path.exists(SHELL_DEFAULT_CONF):
|
||||
logger.debug('Using default config: %s' % SHELL_DEFAULT_CONF)
|
||||
args.config = SHELL_DEFAULT_CONF
|
||||
return func()
|
||||
|
||||
return _infer_config
|
||||
|
||||
def _get_default_image():
|
||||
if DEFAULT_IMAGE_IS_MASTER:
|
||||
yellow = '\033[93m'
|
||||
@ -2708,6 +2738,7 @@ def command_run():
|
||||
##################################
|
||||
|
||||
@infer_fsid
|
||||
@infer_config
|
||||
@infer_image
|
||||
def command_shell():
|
||||
# type: () -> int
|
||||
@ -2729,8 +2760,6 @@ def command_shell():
|
||||
# use /etc/ceph files by default, if present. we do this instead of
|
||||
# making these defaults in the arg parser because we don't want an error
|
||||
# if they don't exist.
|
||||
if not args.config and os.path.exists(SHELL_DEFAULT_CONF):
|
||||
args.config = SHELL_DEFAULT_CONF
|
||||
if not args.keyring and os.path.exists(SHELL_DEFAULT_KEYRING):
|
||||
args.keyring = SHELL_DEFAULT_KEYRING
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user