]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add fetch_tcp_ports function for getting processed ports
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 26 May 2023 19:06:40 +0000 (15:06 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 15 Jun 2023 20:35:34 +0000 (16:35 -0400)
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 <jmulligan@redhat.com>
src/cephadm/cephadm.py

index d0332f1900a35d273c024fc542830e3ba9280e98..06d8161a4ae82748f907ff2d0d3883a0219cbaa1 100755 (executable)
@@ -3067,6 +3067,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