From 6d7a56611e88db8e19a4397c887ba72da2184fa8 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 26 May 2023 15:13:03 -0400 Subject: [PATCH] cephadm: update code to use the fetch_tcp_ports function 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 --- src/cephadm/cephadm.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index fc5ba80023db4..d5a46a4916c17 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -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) -- 2.39.5