From: John Mulligan Date: Fri, 26 May 2023 19:13:03 +0000 (-0400) Subject: cephadm: update code to use the fetch_tcp_ports function X-Git-Tag: v19.0.0~982^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=389368d48527af74fda3bfb37251a9fb3c47b1dc;p=ceph.git 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 --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 06d8161a4ae..96ea56748f2 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 = [] @@ -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)