From: John Mulligan Date: Tue, 30 May 2023 20:23:13 +0000 (-0400) Subject: cephadm: combine deploy functions some more X-Git-Tag: v18.2.1~326^2~51 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e81ca94094fb577923dd78ae21fcb368859adb04;p=ceph.git cephadm: combine deploy functions some more 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 --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 7af523a3883..bd5bb59422b 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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,