Skip to content

Commit

Permalink
Enable not set remote port
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Dec 16, 2024
1 parent 8a87e24 commit 4dd28b1
Showing 1 changed file with 7 additions and 7 deletions.
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

0 comments on commit 4dd28b1

Please sign in to comment.