1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Add fixes for API

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sagi Shnaidman 2024-06-12 13:07:46 +03:00
parent 5bf2d9fe7a
commit 8e0674c4b7
2 changed files with 15 additions and 9 deletions

View file

@ -226,7 +226,6 @@ API_TRANSLATION = {
'published_ports': 'portmappings',
'ports': 'portmappings',
'pids_mode': 'pidns',
'pid': 'pidns',
'ipc_mode': 'ipcns',
'ipc': 'ipcns',
'uts': 'utsns',
@ -414,26 +413,35 @@ class PodmanModuleParamsAPI:
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'):
@ -1233,7 +1241,6 @@ class PodmanContainerDiff:
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)

View file

@ -638,7 +638,6 @@ class PodmanPodDiff:
after = [":".join([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: