]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: update code to use the fetch_tcp_ports function
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 26 May 2023 19:13:03 +0000 (15:13 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 15 Jun 2023 20:35:34 +0000 (16:35 -0400)
Replace a bunch of locations that were "parsing" the tcp ports to use
the recently added fetch_tcp_ports function.

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

index 06d8161a4ae82748f907ff2d0d3883a0219cbaa1..96ea56748f2a4b5963b9abbcc9ecbaf368fceca8 100755 (executable)
@@ -479,13 +479,10 @@ class SNMPGateway:
 
     @property
     def port(self) -> int:
-        if not self.ctx.tcp_ports:
+        ports = fetch_tcp_ports(self.ctx)
+        if not ports:
             return self.DEFAULT_PORT
-        else:
-            if len(self.ctx.tcp_ports) > 0:
-                return int(self.ctx.tcp_ports.split()[0])
-            else:
-                return self.DEFAULT_PORT
+        return ports[0]
 
     def get_daemon_args(self) -> List[str]:
         v3_args = []
@@ -6236,10 +6233,7 @@ def command_deploy(ctx):
     migrate_sysctl_dir(ctx, ctx.fsid)
 
     # Get and check ports explicitly required to be opened
-    daemon_ports = []  # type: List[int]
-
-    if ctx.tcp_ports:
-        daemon_ports = list(map(int, ctx.tcp_ports.split()))
+    daemon_ports = fetch_tcp_ports(ctx)
     _common_deploy(ctx, daemon_type, daemon_id, daemon_ports, deployment_type)
 
 
@@ -6304,10 +6298,7 @@ def command_deploy_from(ctx: CephadmContext) -> None:
     migrate_sysctl_dir(ctx, ctx.fsid)
 
     # Get and check ports explicitly required to be opened
-    daemon_ports = []  # type: List[int]
-
-    if ctx.tcp_ports:
-        daemon_ports = list(map(int, ctx.tcp_ports.split()))
+    daemon_ports = fetch_tcp_ports(ctx)
     _common_deploy(ctx, daemon_type, daemon_id, daemon_ports, deployment_type)
 
 
@@ -7560,8 +7551,8 @@ def command_rm_daemon(ctx):
     else:
         call_throws(ctx, ['rm', '-rf', data_dir])
 
-    if 'tcp_ports' in ctx and ctx.tcp_ports is not None:
-        ports: List[int] = [int(p) for p in ctx.tcp_ports.split()]
+    ports: List[int] = fetch_tcp_ports(ctx)
+    if ports:
         try:
             fw = Firewalld(ctx)
             fw.close_ports(ports)