]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: combine deploy functions some more
authorJohn Mulligan <jmulligan@redhat.com>
Tue, 30 May 2023 20:23:13 +0000 (16:23 -0400)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:15 +0000 (13:35 -0400)
During review it was pointed out that much of command_deploy and
command_deploy_from were still common. Combine the bulk of
command_deploy and command_deploy_from into a new _common_deploy.
The old _common_deploy is renamed to _dispatch_deploy but kept
as a separate function.

The reason for keeping _dispatch_deploy as a function is that
it limits the scope of variables. It helps knowing exactly what
is needed and what is not needed from _common_deploy.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadm.py

index 7af523a388317ae8f4bd983bd892f1fc2d3d4b06..bd5bb59422b72f22f6fa9f067a8f0db9c10918fb 100755 (executable)
@@ -6276,22 +6276,7 @@ def get_deployment_type(ctx: CephadmContext, daemon_type: str, daemon_id: str) -
 @deprecated_command
 def command_deploy(ctx):
     # type: (CephadmContext) -> None
-    daemon_type, daemon_id = ctx.name.split('.', 1)
-
-    lock = FileLock(ctx, ctx.fsid)
-    lock.acquire()
-
-    if daemon_type not in get_supported_daemons():
-        raise Error('daemon type %s not recognized' % daemon_type)
-
-    deployment_type: DeploymentType = get_deployment_type(ctx, daemon_type, daemon_id)
-
-    # Migrate sysctl conf files from /usr/lib to /etc
-    migrate_sysctl_dir(ctx, ctx.fsid)
-
-    # Get and check ports explicitly required to be opened
-    daemon_ports = fetch_tcp_ports(ctx)
-    _common_deploy(ctx, daemon_type, daemon_id, daemon_ports, deployment_type)
+    _common_deploy(ctx)
 
 
 def read_configuration_source(ctx: CephadmContext) -> Dict[str, Any]:
@@ -6346,15 +6331,17 @@ def command_deploy_from(ctx: CephadmContext) -> None:
     """
     config_data = read_configuration_source(ctx)
     apply_deploy_config_to_ctx(config_data, ctx)
+    _common_deploy(ctx)
+
 
+def _common_deploy(ctx: CephadmContext) -> None:
     daemon_type, daemon_id = ctx.name.split('.', 1)
+    if daemon_type not in get_supported_daemons():
+        raise Error('daemon type %s not recognized' % daemon_type)
 
     lock = FileLock(ctx, ctx.fsid)
     lock.acquire()
 
-    if daemon_type not in get_supported_daemons():
-        raise Error('daemon type %s not recognized' % daemon_type)
-
     deployment_type = get_deployment_type(ctx, daemon_type, daemon_id)
 
     # Migrate sysctl conf files from /usr/lib to /etc
@@ -6362,10 +6349,10 @@ def command_deploy_from(ctx: CephadmContext) -> None:
 
     # Get and check ports explicitly required to be opened
     daemon_ports = fetch_tcp_ports(ctx)
-    _common_deploy(ctx, daemon_type, daemon_id, daemon_ports, deployment_type)
+    _dispatch_deploy(ctx, daemon_type, daemon_id, daemon_ports, deployment_type)
 
 
-def _common_deploy(
+def _dispatch_deploy(
     ctx: CephadmContext,
     daemon_type: str,
     daemon_id: str,