Merge "Exposing is_input_or_output for sma_connector"

This commit is contained in:
Zuul
2025-04-17 12:55:24 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 3 deletions

View File

@@ -78,11 +78,11 @@ class PTPNic:
"""
sma1_dict = None
if self.sma1:
sma1_dict = self.sma1.to_dictionary()
sma1_dict = self.sma1.to_dictionary(self.name)
sma2_dict = None
if self.sma2:
sma2_dict = self.sma2.to_dictionary()
sma2_dict = self.sma2.to_dictionary(self.name)
ufl1_dict = None
if self.ufl1:

View File

@@ -58,12 +58,15 @@ class SMAConnector:
"""
return self.name
def to_dictionary(self) -> Dict[str, str]:
def to_dictionary(self, nic_name: str) -> Dict[str, str]:
"""
This function will return a dictionary view of the SMA Connector.
This is mostly used for substitution in JINJA templates.
Args:
nic_name (str): Name of the nic attached to this ptp_nic_connection
Returns:
Dict[str, str]: Dictionary representation
@@ -74,9 +77,26 @@ class SMAConnector:
"input_sma": self.input_sma,
"output_nic": self.output_nic,
"output_sma": self.output_sma,
"is_input_or_output": self.is_input_or_output(nic_name),
}
return dictionary
def is_input_or_output(self, nic_name: str) -> str:
"""
This function will return 'input' or 'output' if the specified nic_name is used as an input/output for this sma_connector.
Args:
nic_name (str): Name of the nic attached to this sma_connector
Returns:
str: 'input' or 'output'
"""
if self.input_nic == nic_name:
return "input"
else:
return "output"
def get_name(self) -> str:
"""
Retrieves the name from the SMA connector.