From f204c05e26fd806e6ea1f177d3c155c47a35baf8 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Wed, 12 Jun 2024 13:07:46 +0300 Subject: [PATCH] Add fixes for API Signed-off-by: Sagi Shnaidman --- .../podman/podman_container_lib.py | 23 ++++++++++++------- plugins/module_utils/podman/podman_pod_lib.py | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/module_utils/podman/podman_container_lib.py b/plugins/module_utils/podman/podman_container_lib.py index 9e7af8f5..fd845c32 100644 --- a/plugins/module_utils/podman/podman_container_lib.py +++ b/plugins/module_utils/podman/podman_container_lib.py @@ -226,7 +226,6 @@ 'published_ports': 'portmappings', 'ports': 'portmappings', 'pids_mode': 'pidns', - 'pid': 'pidns', 'ipc_mode': 'ipcns', 'ipc': 'ipcns', 'uts': 'utsns', @@ -414,26 +413,35 @@ def translate(self): if len(parts) == 1: c_port, protocol = (parts[0].split("/") + ["tcp"])[:2] total_ports.append({ - "container_port": int(p), + "container_port": int(p) if "-" not in p else int(p.split("-")[0]), "protocol": protocol if 'udp' not in p else 'udp', - # "host_port": int(parts[0].split("/")[0]) + # "host_port": int(parts[0].split("/")[0]), + "range": 0 if "-" not in p else int(p.split("-")[1]) - int(p.split("-")[0]) }) elif len(parts) == 2: c_port, protocol = (parts[1].split("/") + ["tcp"])[:2] + cport = int(c_port) if "-" not in c_port else int(c_port.split("-")[0]) + hport = int(parts[0].split("/")[0]) if "-" not in parts[0] else int( + parts[0].split("/")[0].split("-")[0]) total_ports.append( { - "container_port": int(c_port), - "host_port": int(parts[0].split("/")[0]), + "container_port": cport, + "host_port": hport, "protocol": protocol if 'udp' not in p else 'udp', + "range": 0 if "-" not in c_port else int(c_port.split("-")[1]) - int(c_port.split("-")[0]) }) elif len(parts) == 3: c_port, protocol = (parts[1].split("/") + ["tcp"])[:2] + hport = int(c_port) if "-" not in c_port else int(c_port.split("-")[0]) + cport = int(parts[2].split("/")[0]) if "-" not in parts[2] else int( + parts[2].split("/")[0].split("-")[0]) total_ports.append( { - "host_port": int(c_port), - "container_port": int(parts[2].split("/")[0]), + "host_port": hport, + "container_port": cport, "protocol": protocol if 'udp' not in p else 'udp', "host_ip": parts[0], + "range": 0 if "-" not in c_port else int(c_port.split("-")[1]) - int(c_port.split("-")[0]) }) transformed['portmappings'] = total_ports if transformed.get('pod'): @@ -1223,7 +1231,6 @@ def _diff_generic(self, module_arg, cmd_arg, boolean_type=False): cmd = self._get_create_command_annotation() if cmd: params = self.clean_aliases(self.params) - self.module.log("PODMAN-DEBUG: cmd_arg = %s and param arg = %s" % (cmd.get(module_arg), params.get(module_arg))) return self._diff_update_and_compare(module_arg, cmd.get(module_arg), params.get(module_arg)) return self._diff_update_and_compare(module_arg, None, None) diff --git a/plugins/module_utils/podman/podman_pod_lib.py b/plugins/module_utils/podman/podman_pod_lib.py index 8f315a5c..ae0bbe40 100644 --- a/plugins/module_utils/podman/podman_pod_lib.py +++ b/plugins/module_utils/podman/podman_pod_lib.py @@ -612,7 +612,6 @@ def clean_volume(x): [clean_volume(i) for i in v.split(":")[:2]]) for v in self.params['volume']] if before is not None: before = [":".join([clean_volume(i) for i in v.split(":")[:2]]) for v in before] - self.module.log("PODMAN Before: %s and After: %s" % (before, after)) if before is None and after is None: return self._diff_update_and_compare('volume', before, after) if after is not None: