]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: shell: default to config and keyring in /etc/ceph, if present
authorSage Weil <sage@redhat.com>
Fri, 6 Mar 2020 21:20:24 +0000 (15:20 -0600)
committerSage Weil <sage@redhat.com>
Sat, 7 Mar 2020 21:18:45 +0000 (15:18 -0600)
This just makes things painless for humans: they can usually run
'cephadm shell' and have a working environment.

Signed-off-by: Sage Weil <sage@redhat.com>
src/cephadm/cephadm

index 4b51eb4c7ff44f3bb6a48b4b3ab129960b299bbf..18104fcc0745c42316dee50df9a8d17a6dad45fd 100755 (executable)
@@ -12,6 +12,8 @@ CONTAINER_PREFERENCE = ['podman', 'docker']  # prefer podman to docker
 CUSTOM_PS1=r'[ceph: \u@\h \W]\$ '
 DEFAULT_TIMEOUT=None # in seconds
 DEFAULT_RETRY=10
+SHELL_DEFAULT_CONF='/etc/ceph/ceph.conf'
+SHELL_DEFAULT_KEYRING='/etc/ceph/ceph.client.admin.keyring'
 
 """
 You can invoke cephadm in two ways:
@@ -2198,6 +2200,14 @@ def command_shell():
     if daemon_id and not args.fsid:
         raise Error('must pass --fsid to specify cluster')
 
+    # 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
+
     container_args = [] # type: List[str]
     mounts = get_container_mounts(args.fsid, daemon_type, daemon_id,
                                   no_config=True if args.config else False)