diff --git a/config/ptp/objects/ptp_nic.py b/config/ptp/objects/ptp_nic.py index aca3e20f..3ef5cc51 100644 --- a/config/ptp/objects/ptp_nic.py +++ b/config/ptp/objects/ptp_nic.py @@ -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: diff --git a/config/ptp/objects/sma_connector.py b/config/ptp/objects/sma_connector.py index 2e27d5b7..dce3c69a 100644 --- a/config/ptp/objects/sma_connector.py +++ b/config/ptp/objects/sma_connector.py @@ -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.