Skip to content

Commit

Permalink
Add fixes for API
Browse files Browse the repository at this point in the history
Signed-off-by: Sagi Shnaidman <[email protected]>
  • Loading branch information
sshnaidm committed Jun 12, 2024
1 parent 7b9142d commit 772df7c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions plugins/module_utils/podman/podman_container_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,26 +414,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'):
Expand Down

0 comments on commit 772df7c

Please sign in to comment.