]> git.apps.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)
committerAdam King <adking@redhat.com>
Thu, 31 Aug 2023 17:35:14 +0000 (13: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 fc5ba80023db4a7a00cfba5e267419d305f75e25..d5a46a4916c171ed7e3dfd5aa877eb3b1b7392a7 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 = []
@@ -6271,10 +6268,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)
 
 
@@ -6339,10 +6333,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)
 
 
@@ -7595,8 +7586,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)