From: John Mulligan Date: Fri, 26 May 2023 19:06:40 +0000 (-0400) Subject: cephadm: add fetch_tcp_ports function for getting processed ports X-Git-Tag: v18.2.1~326^2~66 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9e040ba46685b91fa4c2c79ecf21e625fe50be24;p=ceph-ci.git cephadm: add fetch_tcp_ports function for getting processed ports The cephadm cli can pass ports as either a string containing space separated port numbers or, in the newer method, a (JSON) list of ints. The fetch_tcp_ports function abstracts away the handling of these input forms. Signed-off-by: John Mulligan --- diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index 6f19620ee56..fc5ba80023d 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -3066,6 +3066,17 @@ def fetch_configs(ctx: CephadmContext) -> Dict[str, str]: return {} +def fetch_tcp_ports(ctx: CephadmContext) -> List[int]: + """Return a list of tcp ports, as integers, stored on the given ctx. + """ + ports = getattr(ctx, 'tcp_ports', None) + if ports is None: + return [] + if isinstance(ports, str): + return list(map(int, ports.split())) + return ports + + def get_config_and_keyring(ctx): # type: (CephadmContext) -> Tuple[Optional[str], Optional[str]] config = None