]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: split cli parsing & ctx setup from logging setup
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 6 Jan 2022 21:26:37 +0000 (16:26 -0500)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 18 Jan 2022 11:06:55 +0000 (12:06 +0100)
Split the parsing and processing of the CLI from the logging
setup in the cephadm main func. Move logging setup to occur after
we've determined that there's a runnable command func.

This is preparatory work to allow running `cephadm --help` without being
root.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 110d294dc607ece48291d96bda08c5cce2c8ecd7)

src/cephadm/cephadm

index c49f0b55b376a093a59eab667b18e7724d939881..f73ffc7f5e5bb3c734327a0785fd399b3aeae378 100755 (executable)
@@ -8542,11 +8542,11 @@ def cephadm_init_ctx(args: List[str]) -> CephadmContext:
     return ctx
 
 
-def cephadm_init(args: List[str]) -> CephadmContext:
+def cephadm_init_logging(ctx: CephadmContext, args: List[str]) -> None:
+    """Configure the logging for cephadm as well as updating the system
+    to have the expected log dir and logrotate configuration.
+    """
     global logger
-    ctx = cephadm_init_ctx(args)
-
-    # Logger configuration
     if not os.path.exists(LOG_DIR):
         os.makedirs(LOG_DIR)
     dictConfig(logging_config)
@@ -8569,7 +8569,6 @@ def cephadm_init(args: List[str]) -> CephadmContext:
             if handler.name == 'console':
                 handler.setLevel(logging.DEBUG)
     logger.debug('%s\ncephadm %s' % ('-' * 80, args))
-    return ctx
 
 
 def main() -> None:
@@ -8582,11 +8581,12 @@ def main() -> None:
     av: List[str] = []
     av = sys.argv[1:]
 
-    ctx = cephadm_init(av)
+    ctx = cephadm_init_ctx(av)
     if not ctx.has_function():
         sys.stderr.write('No command specified; pass -h or --help for usage\n')
         sys.exit(1)
 
+    cephadm_init_logging(ctx, av)
     try:
         # podman or docker?
         ctx.container_engine = find_container_engine(ctx)