Files
test/keywords/ptp/setup/object/ptp_host_interface_setup.py
abhinav_ayyapasetti 1fabfc59ee pylint fix
Description:
- Added data types to function arguments and return values.
- Added blank lines between summary and description in docstrings to match style guidelines.
- Removed extra blank lines after docstrings.
- Added a missing import for SSHConnection in sma_keywords.py.
- Capitalized the first word in each docstring to comply with style guide rules.
- Improved docstring for PTP4LStatusObject constructor with detailed attribute descriptions

Change-Id: Idada0b0b0c3f895a16f4b439beaaaf071597a16a

Change-Id: I8e7756d32eb56a2aa85b277a91b26cc6280d1c56
Signed-off-by: aabhinav <ayyapasetti.abhinav@windriver.com>
2025-07-09 19:38:14 +00:00

85 lines
3.1 KiB
Python

from typing import Any, Dict, List
class PTPHostInterfaceSetup:
"""
This class models a PTP Host interface setup.
"""
def __init__(self, setup_dict: Dict[str, Any]):
"""
Constructor.
Args:
setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this ptp host interface setup.
Raises:
Exception: If the setup_dict does not contain required keys.
Exception: If the setup_dict does not contain required PTPHostInterfaceSetup entries.
Exception: If the setup_dict does not contain required controller interfaces.
Exception: If the setup_dict does not contain required compute interfaces.
"""
if "name" not in setup_dict:
raise Exception("Every ptp host interface entry should have a name.")
self.name = setup_dict["name"]
if "ptp_interface_parameter" not in setup_dict:
raise Exception(f"The ptp host interface entry {self.name} must have ptp_interface_parameter defined.")
self.ptp_interface_parameter = setup_dict["ptp_interface_parameter"]
if "controller_0_interfaces" not in setup_dict:
raise Exception(f"The ptp host interface entry {self.name} must have controller_0_interfaces defined.")
self.controller_0_interfaces = setup_dict["controller_0_interfaces"]
if "controller_1_interfaces" not in setup_dict:
raise Exception(f"The ptp host interface entry {self.name} must have controller_1_interfaces defined.")
self.controller_1_interfaces = setup_dict["controller_1_interfaces"]
self.compute_0_interfaces = None
if "compute_0_interfaces" in setup_dict:
self.compute_0_interfaces = setup_dict.get("compute_0_interfaces")
def __str__(self) -> str:
"""
String representation of this object.
Returns:
str: String representation of this object.
"""
return self.get_name()
def get_name(self) -> str:
"""
Gets the name of this ptp host interface setup.
Returns:
str: The name of this ptp host interface setup.
"""
return self.name
def get_ptp_interface_parameter(self) -> str:
"""
Gets the ptp_interface_parameter of this ptp host interface setup.
Returns:
str: The ptp_interface_parameter of this ptp host interface setup.
"""
return self.ptp_interface_parameter
def get_interfaces_for_hostname(self, hostname: str) -> List[str]:
"""
Gets the interfaces for the given hostname in this PTP host interface setup.
Args:
hostname (str): The name of the host.
Returns:
List[str]: The interfaces for the given hostname in this PTP host interface setup.
"""
interfaces_to_hostname_mapping = {
"controller-0": self.controller_0_interfaces,
"controller-1": self.controller_1_interfaces,
"compute-0": self.compute_0_interfaces,
}
return interfaces_to_hostname_mapping.get(hostname)