From 3d75f991191d9413a9aa5580b14ac0f66f7fa600 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Sat, 23 Sep 2023 15:26:03 -0400 Subject: [PATCH] cephadm: add func to deploy any generic ContainerDaemonForm While there are no ContainerDaemonForms implemented yet, add a function that uses the ContainerDaemonForm methods to construct a deployment for the container based daemons. Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 2b7c8a0a69a..c40d2f15bbf 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -164,10 +164,12 @@ from cephadmlib.host_facts import HostFacts, list_networks from cephadmlib.ssh import authorize_ssh_key, check_ssh_connectivity from cephadmlib.daemon_form import ( DaemonForm, + UnexpectedDaemonTypeError, create as daemon_form_create, register as register_daemon_form, ) from cephadmlib.deploy import DeploymentType +from cephadmlib.container_daemon_form import ContainerDaemonForm from cephadmlib.sysctl import install_sysctl, migrate_sysctl_dir from cephadmlib.firewalld import Firewalld, update_firewalld @@ -5257,10 +5259,42 @@ def _dispatch_deploy( deployment_type=deployment_type, endpoints=daemon_endpoints, ) - else: - raise Error('daemon type {} not implemented in command_deploy function' - .format(daemon_type)) + try: + _deploy_daemon_container( + ctx, ident, daemon_endpoints, deployment_type + ) + except UnexpectedDaemonTypeError: + raise Error('daemon type {} not implemented in command_deploy function' + .format(daemon_type)) + + +def _deploy_daemon_container( + ctx: CephadmContext, + ident: 'DaemonIdentity', + daemon_endpoints: List[EndPoint], + deployment_type: DeploymentType, +) -> None: + daemon = daemon_form_create(ctx, ident) + assert isinstance(daemon, ContainerDaemonForm) + daemon.customize_container_endpoints(daemon_endpoints, deployment_type) + ctr = daemon.container(ctx) + ics = daemon.init_containers(ctx) + config, keyring = daemon.config_and_keyring(ctx) + uid, gid = daemon.uid_gid(ctx) + deploy_daemon( + ctx, + ident, + ctr, + uid, + gid, + config=config, + keyring=keyring, + deployment_type=deployment_type, + endpoints=daemon_endpoints, + osd_fsid=daemon.osd_fsid, + init_containers=ics, + ) ################################## -- 2.39.5