Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable not set remote port #1644

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions IM/tosca/Tosca.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def _get_current_num_instances(sys_name, inf_info):
return current_num

@staticmethod
def _format_outports(ports):
def _format_outports(ports, local_to_remote=True):
res = ""
if isinstance(ports, dict):
ports = list(ports.values())
Expand All @@ -438,18 +438,18 @@ def _format_outports(ports):
if "source_range" in port:
source_range = port["source_range"]
else:
remote_port = None
local_port = None
remote_port = 0
local_port = 0
if "source" in port:
remote_port = port["source"]
if "target" in port:
local_port = port["target"]
elif remote_port:
elif remote_port and local_to_remote:
local_port = remote_port
if not remote_port and local_port:
if not remote_port and local_port and local_to_remote:
remote_port = local_port

if not remote_port or not local_port:
if not remote_port and not local_port:
raise Exception("source or target port must be specified in PortSpec type.")

# In case of source_range do not use port mapping only direct ports
Expand Down Expand Up @@ -2239,7 +2239,7 @@ def _gen_k8s_system(self, node, nodetemplates):
# Asume that publish_ports must be published as NodePort
pub = network("%s_pub" % node.name)
pub.setValue("outbound", "yes")
pub.setValue("outports", self._format_outports(value))
pub.setValue("outports", self._format_outports(value, False))
nets.append(pub)
res.setValue("net_interface.0.connection", "%s_pub" % node.name)
if value and value[0] and 'endpoint' in value[0]:
Expand Down
Loading