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
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'
##################################
@infer_fsid
+@infer_config
@infer_image
def command_shell():
# type: () -> int
# 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