]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephadm: Add CephContainer.for_daemon()
authorSebastian Wagner <sewagner@redhat.com>
Mon, 19 Jul 2021 09:45:54 +0000 (11:45 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Wed, 4 Aug 2021 12:52:55 +0000 (14:52 +0200)
To avoid calling get_container()

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
src/cephadm/cephadm

index c81e9f5bc4d5d4e2f06c77467610a10a0d2e4ea5..724977a90fa7beea935784088b9f4218b994e007 100755 (executable)
@@ -2554,15 +2554,16 @@ def get_container(ctx: CephadmContext,
         if ctx.container_engine.version >= CGROUPS_SPLIT_PODMAN_VERSION:
             container_args.append('--cgroups=split')
 
-    return CephContainer(
+    return CephContainer.for_daemon(
         ctx,
-        image=ctx.image,
+        fsid=fsid,
+        daemon_type=daemon_type,
+        daemon_id=str(daemon_id),
         entrypoint=entrypoint,
         args=ceph_args + get_daemon_args(ctx, fsid, daemon_type, daemon_id),
         container_args=container_args,
         volume_mounts=get_container_mounts(ctx, fsid, daemon_type, daemon_id),
         bind_mounts=get_container_binds(ctx, fsid, daemon_type, daemon_id),
-        cname='ceph-%s-%s.%s' % (fsid, daemon_type, daemon_id),
         envs=envs,
         privileged=privileged,
         ptrace=ptrace,
@@ -3206,6 +3207,43 @@ class CephContainer:
         self.memory_request = memory_request
         self.memory_limit = memory_limit
 
+    @classmethod
+    def for_daemon(cls,
+                   ctx: CephadmContext,
+                   fsid: str,
+                   daemon_type: str,
+                   daemon_id: str,
+                   entrypoint: str,
+                   args: List[str] = [],
+                   volume_mounts: Dict[str, str] = {},
+                   container_args: List[str] = [],
+                   envs: Optional[List[str]] = None,
+                   privileged: bool = False,
+                   ptrace: bool = False,
+                   bind_mounts: Optional[List[List[str]]] = None,
+                   init: Optional[bool] = None,
+                   host_network: bool = True,
+                   memory_request: Optional[str] = None,
+                   memory_limit: Optional[str] = None,
+                   ) -> 'CephContainer':
+        return cls(
+            ctx,
+            image=ctx.image,
+            entrypoint=entrypoint,
+            args=args,
+            volume_mounts=volume_mounts,
+            cname='ceph-%s-%s.%s' % (fsid, daemon_type, daemon_id),
+            container_args=container_args,
+            envs=envs,
+            privileged=privileged,
+            ptrace=ptrace,
+            bind_mounts=bind_mounts,
+            init=init,
+            host_network=host_network,
+            memory_request=memory_request,
+            memory_limit=memory_limit,
+        )
+
     @property
     def cname(self) -> str:
         """