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>
This commit is contained in:
abhinav_ayyapasetti
2025-07-08 03:50:32 -04:00
committed by Christian Roy
parent 162152c153
commit 1fabfc59ee
21 changed files with 490 additions and 319 deletions

View File

@@ -11,18 +11,21 @@ class PMCGetCurrentDataSetObject:
def get_steps_removed(self) -> int: def get_steps_removed(self) -> int:
""" """
Getter for steps_removed Getter for steps_removed
Returns: the steps_removed value
Returns:
int: the steps_removed value
""" """
return self.steps_removed return self.steps_removed
def set_steps_removed(self, steps_removed: int): def set_steps_removed(self, steps_removed: int) -> None:
""" """
Setter for steps_removed Setter for steps_removed
Args: Args:
steps_removed (): the steps_removed value steps_removed (int): the steps_removed value
Returns: Returns:
None: This method does not return anything.
""" """
self.steps_removed = steps_removed self.steps_removed = steps_removed
@@ -30,37 +33,41 @@ class PMCGetCurrentDataSetObject:
def get_offset_from_master(self) -> float: def get_offset_from_master(self) -> float:
""" """
Getter for offset_from_master Getter for offset_from_master
Returns: offset_from_master
Returns:
float: the offset_from_master value
""" """
return self.offset_from_master return self.offset_from_master
def set_offset_from_master(self, offset_from_master: float): def set_offset_from_master(self, offset_from_master: float) -> None:
""" """
Setter for offset_from_master Setter for offset_from_master
Args: Args:
offset_from_master (): the offset_from_master value offset_from_master (float): the offset_from_master value
Returns: Returns:
None: This method does not return anything.
""" """
self.offset_from_master = offset_from_master self.offset_from_master = offset_from_master
def get_mean_path_delay(self) -> float: def get_mean_path_delay(self) -> float:
""" """
Getter for mean_path_delay Getter for mean_path_delay
Returns: mean_path_delay value
Returns:
float: the mean_path_delay value
""" """
return self.mean_path_delay return self.mean_path_delay
def set_mean_path_delay(self, mean_path_delay: float): def set_mean_path_delay(self, mean_path_delay: float) -> None:
""" """
Setter for mean_path_delay Setter for mean_path_delay
Args: Args:
mean_path_delay (): mean_path_delay value mean_path_delay (float): mean_path_delay value
Returns: Returns:
None: This method does not return anything.
""" """
self.mean_path_delay = mean_path_delay self.mean_path_delay = mean_path_delay

View File

@@ -9,21 +9,20 @@ class PMCGetDomainObject:
def get_domain_number(self) -> int: def get_domain_number(self) -> int:
""" """
Getter for domain_number Getter for domain_number
Returns: the domain_number value
Returns:
int: the domain_number value
""" """
return self.domain_number return self.domain_number
def set_domain_number(self, domain_number: int): def set_domain_number(self, domain_number: int) -> None:
""" """
Setter for domain_number Setter for domain_number
Args: Args:
domain_number : the domain_number value domain_number (int): the domain_number value
Returns: Returns:
None: This method does not return anything.
""" """
self.domain_number = domain_number self.domain_number = domain_number

View File

@@ -4,9 +4,12 @@ class PMCGetGrandmasterSettingsNpObject:
""" """
def __init__(self): def __init__(self):
"""
Initializes the attributes of the object to default values.
"""
self.clock_class: int = -1 self.clock_class: int = -1
self.clock_accuracy: str = '' self.clock_accuracy: str = ""
self.offset_scaled_log_variance: str = '' self.offset_scaled_log_variance: str = ""
self.current_utc_offset: int = -1 self.current_utc_offset: int = -1
self.leap61: int = -1 self.leap61: int = -1
self.leap59: int = -1 self.leap59: int = -1
@@ -14,216 +17,235 @@ class PMCGetGrandmasterSettingsNpObject:
self.ptp_time_scale: int = -1 self.ptp_time_scale: int = -1
self.time_traceable: int = -1 self.time_traceable: int = -1
self.frequency_traceable: int = -1 self.frequency_traceable: int = -1
self.time_source: str = '' self.time_source: str = ""
def get_clock_class(self) -> int: def get_clock_class(self) -> int:
""" """
Getter for clock_class Getter for clock_class
Returns: the clock_class value
Returns:
int: the clock_class value
""" """
return self.clock_class return self.clock_class
def set_clock_class(self, clock_class: int): def set_clock_class(self, clock_class: int) -> None:
""" """
Setter for clock_class Setter for clock_class
Args: Args:
clock_class : the clock_class value clock_class (int): the clock_class value
Returns: Returns:
None: This method does not return anything.
""" """
self.clock_class = clock_class self.clock_class = clock_class
def get_clock_accuracy(self) -> str: def get_clock_accuracy(self) -> str:
""" """
Getter for clock_accuracy Getter for clock_accuracy
Returns: the clock_accuracy value
Returns:
str: the clock_accuracy value
""" """
return self.clock_accuracy return self.clock_accuracy
def set_clock_accuracy(self, clock_accuracy: str): def set_clock_accuracy(self, clock_accuracy: str) -> None:
""" """
Setter for clock_accuracy Setter for clock_accuracy
Args: Args:
clock_accuracy : the clock_accuracy value clock_accuracy (str): the clock_accuracy value
Returns: Returns:
None: This method does not return anything.
""" """
self.clock_accuracy = clock_accuracy self.clock_accuracy = clock_accuracy
def get_offset_scaled_log_variance(self) -> str: def get_offset_scaled_log_variance(self) -> str:
""" """
Getter for offset_scaled_log_variance Getter for offset_scaled_log_variance
Returns: the offset_scaled_log_variance value
Returns:
str: the offset_scaled_log_variance value
""" """
return self.offset_scaled_log_variance return self.offset_scaled_log_variance
def set_offset_scaled_log_variance(self, offset_scaled_log_variance: str): def set_offset_scaled_log_variance(self, offset_scaled_log_variance: str) -> None:
""" """
Setter for offset_scaled_log_variance Setter for offset_scaled_log_variance
Args: Args:
offset_scaled_log_variance : the offset_scaled_log_variance value offset_scaled_log_variance (str): the offset_scaled_log_variance value
Returns: Returns:
None: This method does not return anything.
""" """
self.offset_scaled_log_variance = offset_scaled_log_variance self.offset_scaled_log_variance = offset_scaled_log_variance
def get_current_utc_offset(self) -> int: def get_current_utc_offset(self) -> int:
""" """
Getter for current_utc_offset Getter for current_utc_offset
Returns: the current_utc_offset value
Returns:
int: the current_utc_offset value
""" """
return self.current_utc_offset return self.current_utc_offset
def set_current_utc_offset(self, current_utc_offset: int): def set_current_utc_offset(self, current_utc_offset: int) -> None:
""" """
Setter for current_utc_offset Setter for current_utc_offset
Args: Args:
current_utc_offset : the current_utc_offset value current_utc_offset (int): the current_utc_offset value
Returns: Returns:
None: This method does not return anything.
""" """
self.current_utc_offset = current_utc_offset self.current_utc_offset = current_utc_offset
def get_leap61(self) -> int: def get_leap61(self) -> int:
""" """
Getter for leap61 Getter for leap61
Returns: the leap61 value
Returns:
int: the leap61 value
""" """
return self.leap61 return self.leap61
def set_leap61(self, leap61: int): def set_leap61(self, leap61: int) -> None:
""" """
Setter for leap61 Setter for leap61
Args: Args:
leap61 : the leap61 value leap61 (int): the leap61 value
Returns: Returns:
None: This method does not return anything.
""" """
self.leap61 = leap61 self.leap61 = leap61
def get_leap59(self) -> int: def get_leap59(self) -> int:
""" """
Getter for leap59 Getter for leap59
Returns: the leap59 value
Returns:
int: the leap59 value
""" """
return self.leap59 return self.leap59
def set_leap59(self, leap59: int): def set_leap59(self, leap59: int) -> None:
""" """
Setter for leap59 Setter for leap59
Args: Args:
leap59 : the leap59 value leap59 (int): the leap59 value
Returns: Returns:
None: This method does not return anything.
""" """
self.leap59 = leap59 self.leap59 = leap59
def get_current_utc_off_set_valid(self) -> int: def get_current_utc_off_set_valid(self) -> int:
""" """
Getter for current_utc_off_set_valid Getter for current_utc_off_set_valid
Returns: the current_utc_off_set_valid value
Returns:
int: the current_utc_off_set_valid value
""" """
return self.current_utc_off_set_valid return self.current_utc_off_set_valid
def set_current_utc_off_set_valid(self, current_utc_off_set_valid: int): def set_current_utc_off_set_valid(self, current_utc_off_set_valid: int) -> None:
""" """
Setter for current_utc_off_set_valid Setter for current_utc_off_set_valid
Args: Args:
current_utc_off_set_valid : the current_utc_off_set_valid value current_utc_off_set_valid (int): the current_utc_off_set_valid value
Returns: Returns:
None: This method does not return anything.
""" """
self.current_utc_off_set_valid = current_utc_off_set_valid self.current_utc_off_set_valid = current_utc_off_set_valid
def get_ptp_time_scale(self) -> int: def get_ptp_time_scale(self) -> int:
""" """
Getter for ptp_time_scale Getter for ptp_time_scale
Returns: the ptp_time_scale value
Returns:
int: the ptp_time_scale value
""" """
return self.ptp_time_scale return self.ptp_time_scale
def set_ptp_time_scale(self, ptp_time_scale: int): def set_ptp_time_scale(self, ptp_time_scale: int) -> None:
""" """
Setter for ptp_time_scale Setter for ptp_time_scale
Args: Args:
ptp_time_scale : the ptp_time_scale value ptp_time_scale (int): the ptp_time_scale value
Returns: Returns:
None: This method does not return anything.
""" """
self.ptp_time_scale = ptp_time_scale self.ptp_time_scale = ptp_time_scale
def get_time_traceable(self) -> int: def get_time_traceable(self) -> int:
""" """
Getter for time_traceable Getter for time_traceable
Returns: the time_traceable value
Returns:
int: the time_traceable value
""" """
return self.time_traceable return self.time_traceable
def set_time_traceable(self, time_traceable: int): def set_time_traceable(self, time_traceable: int) -> None:
""" """
Setter for time_traceable Setter for time_traceable
Args: Args:
time_traceable : the time_traceable value time_traceable (int): the time_traceable value
Returns: Returns:
None: This method does not return anything.
""" """
self.time_traceable = time_traceable self.time_traceable = time_traceable
def get_frequency_traceable(self) -> int: def get_frequency_traceable(self) -> int:
""" """
Getter for frequency_traceable Getter for frequency_traceable
Returns: the frequency_traceable value
Returns:
int: the frequency_traceable value
""" """
return self.frequency_traceable return self.frequency_traceable
def set_frequency_traceable(self, frequency_traceable: int): def set_frequency_traceable(self, frequency_traceable: int) -> None:
""" """
Setter for frequency_traceable Setter for frequency_traceable
Args: Args:
frequency_traceable : the frequency_traceable value frequency_traceable (int): the frequency_traceable value
Returns: Returns:
None: This method does not return anything.
""" """
self.frequency_traceable = frequency_traceable self.frequency_traceable = frequency_traceable
def get_time_source(self) -> str: def get_time_source(self) -> str:
""" """
Getter for time_source Getter for time_source
Returns: the time_source value
Returns
str: the time_source value
""" """
return self.time_source return self.time_source
def set_time_source(self, time_source: str): def set_time_source(self, time_source: str) -> None:
""" """
Setter for time_source Setter for time_source
Args: Args:
time_source : the time_source value time_source (str): the time_source value
Returns: Returns:
None: This method does not return anything.
""" """
self.time_source = time_source self.time_source = time_source

View File

@@ -4,203 +4,224 @@ class PMCGetParentDataSetObject:
""" """
def __init__(self): def __init__(self):
self.parent_port_identity: str = '' self.parent_port_identity: str = ""
self.parent_stats: int = -1 self.parent_stats: int = -1
self.observed_parent_offset_scaled_log_variance: str = '' self.observed_parent_offset_scaled_log_variance: str = ""
self.observed_parent_clock_phase_change_rate: str = '' self.observed_parent_clock_phase_change_rate: str = ""
self.grandmaster_priority1: int = -1 self.grandmaster_priority1: int = -1
self.gm_clock_class: int = -1 self.gm_clock_class: int = -1
self.gm_clock_accuracy: str = '' self.gm_clock_accuracy: str = ""
self.gm_offset_scaled_log_variance: str = '' self.gm_offset_scaled_log_variance: str = ""
self.grandmaster_priority2: int = -1 self.grandmaster_priority2: int = -1
self.grandmaster_identity: str = '' self.grandmaster_identity: str = ""
def get_parent_port_identity(self) -> str: def get_parent_port_identity(self) -> str:
""" """
Getter for parent_port_identity Getter for parent_port_identity
Returns: parent_port_identity
Returns:
str: parent_port_identity
""" """
return self.parent_port_identity return self.parent_port_identity
def set_parent_port_identity(self, parent_port_identity: str): def set_parent_port_identity(self, parent_port_identity: str) -> None:
""" """
Setter for parent_port_identity Setter for parent_port_identity
Args: Args:
parent_port_identity (): the parent_port_identity value parent_port_identity (str): the parent_port_identity value
Returns: Returns:
None: This method does not return anything.
""" """
self.parent_port_identity = parent_port_identity self.parent_port_identity = parent_port_identity
def get_parent_stats(self) -> int: def get_parent_stats(self) -> int:
""" """
Getter for parent_stats Getter for parent_stats
Returns: parent_stats value
Returns:
int: parent_stats value
""" """
return self.parent_stats return self.parent_stats
def set_parent_stats(self, parent_stats: int): def set_parent_stats(self, parent_stats: int) -> None:
""" """
Setter for parent_stats Setter for parent_stats
Args: Args:
parent_stats (): parent_stats value parent_stats (int): parent_stats value
Returns: Returns:
None: This method does not return anything.
""" """
self.parent_stats = parent_stats self.parent_stats = parent_stats
def get_observed_parent_offset_scaled_log_variance(self) -> str: def get_observed_parent_offset_scaled_log_variance(self) -> str:
""" """
Getter for observed_parent_offset_scaled_log_variance Getter for observed_parent_offset_scaled_log_variance
Returns: the observed_parent_offset_scaled_log_variance value
Returns:
str: the observed_parent_offset_scaled_log_variance value
""" """
return self.observed_parent_offset_scaled_log_variance return self.observed_parent_offset_scaled_log_variance
def set_observed_parent_offset_scaled_log_variance(self, observed_parent_offset_scaled_log_variance: str): def set_observed_parent_offset_scaled_log_variance(self, observed_parent_offset_scaled_log_variance: str) -> None:
""" """
Setter for observed_parent_offset_scaled_log_variance Setter for observed_parent_offset_scaled_log_variance
Args: Args:
observed_parent_offset_scaled_log_variance (): the observed_parent_offset_scaled_log_variance value observed_parent_offset_scaled_log_variance (str): the observed_parent_offset_scaled_log_variance value
Returns: Returns:
None: This method does not return anything.
""" """
self.observed_parent_offset_scaled_log_variance = observed_parent_offset_scaled_log_variance self.observed_parent_offset_scaled_log_variance = observed_parent_offset_scaled_log_variance
def get_observed_parent_clock_phase_change_rate(self) -> str: def get_observed_parent_clock_phase_change_rate(self) -> str:
""" """
Getter for observed_parent_clock_phase_change_rate Getter for observed_parent_clock_phase_change_rate
Returns: observed_parent_clock_phase_change_rate value
Returns:
str: observed_parent_clock_phase_change_rate value
""" """
return self.observed_parent_clock_phase_change_rate return self.observed_parent_clock_phase_change_rate
def set_observed_parent_clock_phase_change_rate(self, observed_parent_clock_phase_change_rate: str): def set_observed_parent_clock_phase_change_rate(self, observed_parent_clock_phase_change_rate: str) -> None:
""" """
Setter for observed_parent_clock_phase_change_rate Setter for observed_parent_clock_phase_change_rate
Args: Args:
observed_parent_clock_phase_change_rate (): the observed_parent_clock_phase_change_rate value observed_parent_clock_phase_change_rate (str): the observed_parent_clock_phase_change_rate value
Returns: Returns:
None: This method does not return anything.
""" """
self.observed_parent_clock_phase_change_rate = observed_parent_clock_phase_change_rate self.observed_parent_clock_phase_change_rate = observed_parent_clock_phase_change_rate
def get_grandmaster_priority1(self) -> int: def get_grandmaster_priority1(self) -> int:
""" """
Getter for grandmaster_priority1 Getter for grandmaster_priority1
Returns: the grandmaster_priority1 value
Returns:
int: the grandmaster_priority1 value
""" """
return self.grandmaster_priority1 return self.grandmaster_priority1
def set_grandmaster_priority1(self, grandmaster_priority1: int): def set_grandmaster_priority1(self, grandmaster_priority1: int) -> None:
""" """
Setter for grandmaster_priority1 Setter for grandmaster_priority1
Args: Args:
grandmaster_priority1 (): the grandmaster_priority1 value grandmaster_priority1 (int): the grandmaster_priority1 value
Returns: Returns:
None: This method does not return anything.
""" """
self.grandmaster_priority1 = grandmaster_priority1 self.grandmaster_priority1 = grandmaster_priority1
def get_gm_clock_class(self) -> int: def get_gm_clock_class(self) -> int:
""" """
Getter for gm_clock_class Getter for gm_clock_class
Returns: the gm_clock_class value
Returns:
int: the gm_clock_class value
""" """
return self.gm_clock_class return self.gm_clock_class
def set_gm_clock_class(self, gm_clock_class: int): def set_gm_clock_class(self, gm_clock_class: int) -> None:
""" """
Setter for gm_clock_class Setter for gm_clock_class
Args: Args:
gm_clock_class (): the gm_clock_class value gm_clock_class (int): the gm_clock_class value
Returns: Returns:
None: This method does not return anything.
""" """
self.gm_clock_class = gm_clock_class self.gm_clock_class = gm_clock_class
def get_gm_clock_accuracy(self) -> str: def get_gm_clock_accuracy(self) -> str:
""" """
Getter for gm_clock_accuracy Getter for gm_clock_accuracy
Returns: the gm_clock_accuracy value
Returns:
str: the gm_clock_accuracy value
""" """
return self.gm_clock_accuracy return self.gm_clock_accuracy
def set_gm_clock_accuracy(self, gm_clock_accuracy: str): def set_gm_clock_accuracy(self, gm_clock_accuracy: str) -> None:
""" """
Setter for gm_clock_accuracy Setter for gm_clock_accuracy
Args: Args:
gm_clock_accuracy (): the gm_clock_accuracy value gm_clock_accuracy (str): the gm_clock_accuracy value
Returns: Returns:
None: This method does not return anything.
""" """
self.gm_clock_accuracy = gm_clock_accuracy self.gm_clock_accuracy = gm_clock_accuracy
def get_gm_offset_scaled_log_variance(self) -> str: def get_gm_offset_scaled_log_variance(self) -> str:
""" """
Getter for gm_offset_scaled_log_variance Getter for gm_offset_scaled_log_variance
Returns: the gm_offset_scaled_log_variance value
Returns:
str: the gm_offset_scaled_log_variance value
""" """
return self.gm_offset_scaled_log_variance return self.gm_offset_scaled_log_variance
def set_gm_offset_scaled_log_variance(self, gm_offset_scaled_log_variance: str): def set_gm_offset_scaled_log_variance(self, gm_offset_scaled_log_variance: str) -> None:
""" """
Setter for gm_offset_scaled_log_variance Setter for gm_offset_scaled_log_variance
Args: Args:
gm_offset_scaled_log_variance (): the gm_offset_scaled_log_variance value gm_offset_scaled_log_variance (str): the gm_offset_scaled_log_variance value
Returns: Returns:
None: This method does not return anything.
""" """
self.gm_offset_scaled_log_variance = gm_offset_scaled_log_variance self.gm_offset_scaled_log_variance = gm_offset_scaled_log_variance
def get_grandmaster_priority2(self) -> int: def get_grandmaster_priority2(self) -> int:
""" """
Getter for grandmaster_priority2 Getter for grandmaster_priority2
Returns: the grandmaster_priority2 value
Returns:
int: the grandmaster_priority2 value
""" """
return self.grandmaster_priority2 return self.grandmaster_priority2
def set_grandmaster_priority2(self, grandmaster_priority2: int): def set_grandmaster_priority2(self, grandmaster_priority2: int) -> None:
""" """
Setter for grandmaster_priority2 Setter for grandmaster_priority2
Args: Args:
grandmaster_priority2 (): the grandmaster_priority2 value grandmaster_priority2 (int): the grandmaster_priority2 value
Returns: Returns:
None: This method does not return anything.
""" """
self.grandmaster_priority2 = grandmaster_priority2 self.grandmaster_priority2 = grandmaster_priority2
def get_grandmaster_identity(self) -> str: def get_grandmaster_identity(self) -> str:
""" """
Getter for grandmaster_identity Getter for grandmaster_identity
Returns: the grandmaster_identity value
Returns:
str: the grandmaster_identity value
""" """
return self.grandmaster_identity return self.grandmaster_identity
def set_grandmaster_identity(self, grandmaster_identity: str): def set_grandmaster_identity(self, grandmaster_identity: str) -> None:
""" """
Setter for grandmaster_identity Setter for grandmaster_identity
Args: Args:
grandmaster_identity (): the grandmaster_identity value grandmaster_identity (str): the grandmaster_identity value
Returns: Returns:
None: This method does not return anything.history
""" """
self.grandmaster_identity = grandmaster_identity self.grandmaster_identity = grandmaster_identity

View File

@@ -11,118 +11,134 @@ class PMCGetTimePropertiesDataSetObject:
self.ptp_time_scale: int = -1 self.ptp_time_scale: int = -1
self.time_traceable: int = -1 self.time_traceable: int = -1
self.frequency_traceable: int = -1 self.frequency_traceable: int = -1
self.time_source: str = '' self.time_source: str = ""
def get_current_utc_offset(self) -> int: def get_current_utc_offset(self) -> int:
""" """
Getter for current_utc_offset Getter for current_utc_offset
Returns: the current_utc_offset value
Returns:
int: the current_utc_offset value
""" """
return self.current_utc_offset return self.current_utc_offset
def set_current_utc_offset(self, current_utc_offset: int): def set_current_utc_offset(self, current_utc_offset: int) -> None:
""" """
Setter for current_utc_offset Setter for current_utc_offset
Args: Args:
current_utc_offset : the current_utc_offset value current_utc_offset (int): the current_utc_offset value
Returns: Returns:
None: This method does not return anything.
""" """
self.current_utc_offset = current_utc_offset self.current_utc_offset = current_utc_offset
def get_leap61(self) -> int: def get_leap61(self) -> int:
""" """
Getter for leap61 Getter for leap61
Returns: the leap61 value
Returns:
int: the leap61 value
""" """
return self.leap61 return self.leap61
def set_leap61(self, leap61: int): def set_leap61(self, leap61: int) -> None:
""" """
Setter for leap61 Setter for leap61
Args: Args:
leap61 : the leap61 value leap61 (int): the leap61 value
Returns: Returns:
None: This method does not return anything.
""" """
self.leap61 = leap61 self.leap61 = leap61
def get_leap59(self) -> int: def get_leap59(self) -> int:
""" """
Getter for leap59 Getter for leap59
Returns: the leap59 value
Returns:
int: the leap59 value
""" """
return self.leap59 return self.leap59
def set_leap59(self, leap59: int): def set_leap59(self, leap59: int) -> None:
""" """
Setter for leap59 Setter for leap59
Args: Args:
leap59 : the leap59 value leap59 (int): the leap59 value
Returns: Returns:
None: This method does not return anything.
""" """
self.leap59 = leap59 self.leap59 = leap59
def get_current_utc_off_set_valid(self) -> int: def get_current_utc_off_set_valid(self) -> int:
""" """
Getter for current_utc_off_set_valid Getter for current_utc_off_set_valid
Returns: the current_utc_off_set_valid value
Returns:
int: the current_utc_off_set_valid value
""" """
return self.current_utc_off_set_valid return self.current_utc_off_set_valid
def set_current_utc_off_set_valid(self, current_utc_off_set_valid: int): def set_current_utc_off_set_valid(self, current_utc_off_set_valid: int) -> None:
""" """
Setter for current_utc_off_set_valid Setter for current_utc_off_set_valid
Args: Args:
current_utc_off_set_valid : the current_utc_off_set_valid value current_utc_off_set_valid (int): the current_utc_off_set_valid value
Returns: Returns:
None: This method does not return anything.
""" """
self.current_utc_off_set_valid = current_utc_off_set_valid self.current_utc_off_set_valid = current_utc_off_set_valid
def get_ptp_time_scale(self) -> int: def get_ptp_time_scale(self) -> int:
""" """
Getter for ptp_time_scale Getter for ptp_time_scale
Returns: the ptp_time_scale value
Returns:
int: the ptp_time_scale value
""" """
return self.ptp_time_scale return self.ptp_time_scale
def set_ptp_time_scale(self, ptp_time_scale: int): def set_ptp_time_scale(self, ptp_time_scale: int) -> None:
""" """
Setter for ptp_time_scale Setter for ptp_time_scale
Args: Args:
ptp_time_scale : the ptp_time_scale value ptp_time_scale (int): the ptp_time_scale value
Returns: Returns:
None: This method does not return anything.
""" """
self.ptp_time_scale = ptp_time_scale self.ptp_time_scale = ptp_time_scale
def get_time_traceable(self) -> int: def get_time_traceable(self) -> int:
""" """
Getter for time_traceable Getter for time_traceable
Returns: the time_traceable value
Returns:
int: the time_traceable value
""" """
return self.time_traceable return self.time_traceable
def set_time_traceable(self, time_traceable: int): def set_time_traceable(self, time_traceable: int) -> None:
""" """
Setter for time_traceable Setter for time_traceable
Args: Args:
time_traceable : the time_traceable value time_traceable (int): the time_traceable value
Returns: Returns:
None: This method does not return anything.
""" """
self.time_traceable = time_traceable self.time_traceable = time_traceable
@@ -130,18 +146,21 @@ class PMCGetTimePropertiesDataSetObject:
def get_frequency_traceable(self) -> int: def get_frequency_traceable(self) -> int:
""" """
Getter for frequency_traceable Getter for frequency_traceable
Returns: the frequency_traceable value
Returns:
int: the frequency_traceable value
""" """
return self.frequency_traceable return self.frequency_traceable
def set_frequency_traceable(self, frequency_traceable: int): def set_frequency_traceable(self, frequency_traceable: int) -> None:
""" """
Setter for frequency_traceable Setter for frequency_traceable
Args: Args:
frequency_traceable : the frequency_traceable value frequency_traceable (int): the frequency_traceable value
Returns: Returns:
None: This method does not return anything.
""" """
self.frequency_traceable = frequency_traceable self.frequency_traceable = frequency_traceable
@@ -149,21 +168,20 @@ class PMCGetTimePropertiesDataSetObject:
def get_time_source(self) -> str: def get_time_source(self) -> str:
""" """
Getter for time_source Getter for time_source
Returns: the time_source value
Returns:
str: the time_source value
""" """
return self.time_source return self.time_source
def set_time_source(self, time_source: str): def set_time_source(self, time_source: str) -> None:
""" """
Setter for time_source Setter for time_source
Args: Args:
time_source : the time_source value time_source (str): the time_source value
Returns: Returns:
None: This method does not return anything.
""" """
self.time_source = time_source self.time_source = time_source

View File

@@ -37,6 +37,8 @@ class PMCTableParser:
Returns: Returns:
list[dict]: the output values dict list[dict]: the output values dict
Raises:
KeywordException: if a line with values is not in the expected format.
""" """
output_values_dict = {} output_values_dict = {}
output_values_dict_list = [] output_values_dict_list = []

View File

@@ -10,15 +10,21 @@ class GetPtp4lServiceStatusKeywords(BaseKeyword):
""" """
def __init__(self, ssh_connection: SSHConnection): def __init__(self, ssh_connection: SSHConnection):
"""
Constructor for GetPtp4lServiceStatusKeywords.
Args:
ssh_connection (SSHConnection): An SSHConnection object to execute commands on the remote host.
"""
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def get_systemctl_ptp4l_status(self) -> PTP4LStatusOutput: def get_systemctl_ptp4l_status(self) -> PTP4LStatusOutput:
""" """
Getter for systemctl ptp4l status output Getter for systemctl ptp4l status output
Returns:
Returns:
PTP4LStatusOutput: A PTP4LStatusOutput object containing the status of ptp4l services
""" """
output = SystemCTLStatusKeywords(self.ssh_connection).get_status('ptp4l@*') output = SystemCTLStatusKeywords(self.ssh_connection).get_status("ptp4l@*")
ptp4l_status_output = PTP4LStatusOutput(output) ptp4l_status_output = PTP4LStatusOutput(output)
return ptp4l_status_output return ptp4l_status_output

View File

@@ -1,34 +1,43 @@
class PTP4LStatusObject: class PTP4LStatusObject:
"""Represents system resource information. """
Represents system resource information for a PTP4L service.
"""
def __init__(self, service_name: str):
"""
Initializes a new PTP4LStatusObject instance with default values.
Args:
service_name (str): The name of the PTP4L service (e.g., "phc1").
Attributes: Attributes:
service_name (str): the name of the service service_name (str): the name of the service
loaded (str): The loading status of the resource. loaded (str): The loading status of the resource.
active (str): The active status of the resource. active (str): The active status of the resource.
process (str): The process associated with the resource.
main_pid (str): The main process ID associated with the resource. main_pid (str): The main process ID associated with the resource.
tasks (str): Information about the tasks related to the resource. tasks (str): Information about the tasks related to the resource.
memory (str): Memory usage information. memory (str): Memory usage information.
cpu (str): CPU usage information. cpu (str): CPU usage information.
c_group (str): The C group the resource belongs to. c_group (str): The C group the resource belongs to.
command (str): The command used to start the resource.
""" """
def __init__(self, service_name: str):
self.service_name = service_name self.service_name = service_name
self.loaded: str = '' self.loaded: str = ""
self.active: str = '' self.active: str = ""
self.process: str = '' self.process: str = ""
self.main_pid: str = '' self.main_pid: str = ""
self.tasks: str = '' self.tasks: str = ""
self.memory: str = '' self.memory: str = ""
self.cpu: str = '' self.cpu: str = ""
self.c_group: str = '' self.c_group: str = ""
self.command: str = '' self.command: str = ""
def get_service_name(self) -> str: def get_service_name(self) -> str:
"""Gets the service_name. """Gets the service_name.
Returns: Returns:
The service_name. str: The service_name.
""" """
return self.service_name return self.service_name
@@ -36,7 +45,10 @@ class PTP4LStatusObject:
"""Sets service_name. """Sets service_name.
Args: Args:
service_name: The new loading status. service_name (str): The new loading status.
Returns:
None: This method does not return anything.
""" """
self.service_name = service_name self.service_name = service_name
@@ -44,7 +56,7 @@ class PTP4LStatusObject:
"""Gets the loading status. """Gets the loading status.
Returns: Returns:
The loading status. str: The loading status.
""" """
return self.loaded return self.loaded
@@ -52,7 +64,10 @@ class PTP4LStatusObject:
"""Sets the loading status. """Sets the loading status.
Args: Args:
loaded: The new loading status. loaded (str): The new loading status.
Returns:
None: This method does not return anything.
""" """
self.loaded = loaded self.loaded = loaded
@@ -60,7 +75,7 @@ class PTP4LStatusObject:
"""Gets the active status. """Gets the active status.
Returns: Returns:
The active status. str: The active status.
""" """
return self.active return self.active
@@ -68,7 +83,10 @@ class PTP4LStatusObject:
"""Sets the active status. """Sets the active status.
Args: Args:
active: The new active status. active (str): The new active status.
Returns:
None: This method does not return anything.
""" """
self.active = active self.active = active
@@ -76,7 +94,7 @@ class PTP4LStatusObject:
"""Gets the main process ID. """Gets the main process ID.
Returns: Returns:
The main process ID. str: The main process ID.
""" """
return self.main_pid return self.main_pid
@@ -84,7 +102,10 @@ class PTP4LStatusObject:
"""Sets the main process ID. """Sets the main process ID.
Args: Args:
main_pid: The new main process ID. main_pid (str): The new main process ID.
Returns:
None: This method does not return anything.
""" """
self.main_pid = main_pid self.main_pid = main_pid
@@ -92,7 +113,7 @@ class PTP4LStatusObject:
"""Gets the tasks information. """Gets the tasks information.
Returns: Returns:
The tasks information. str: The tasks information.
""" """
return self.tasks return self.tasks
@@ -100,7 +121,10 @@ class PTP4LStatusObject:
"""Sets the tasks information. """Sets the tasks information.
Args: Args:
tasks: The new tasks information. tasks (str): The new tasks information.
Returns:
None: This method does not return anything.
""" """
self.tasks = tasks self.tasks = tasks
@@ -108,7 +132,7 @@ class PTP4LStatusObject:
"""Gets the memory information. """Gets the memory information.
Returns: Returns:
The memory information. str: The memory information.
""" """
return self.memory return self.memory
@@ -116,7 +140,10 @@ class PTP4LStatusObject:
"""Sets the memory information. """Sets the memory information.
Args: Args:
memory: The new memory information. memory (str): The new memory information.
Returns:
None: This method does not return anything.
""" """
self.memory = memory self.memory = memory
@@ -124,7 +151,7 @@ class PTP4LStatusObject:
"""Gets the CPU information. """Gets the CPU information.
Returns: Returns:
The CPU information. str: The CPU information.
""" """
return self.cpu return self.cpu
@@ -132,7 +159,10 @@ class PTP4LStatusObject:
"""Sets the CPU information. """Sets the CPU information.
Args: Args:
cpu: The new CPU information. cpu (str): The new CPU information.
Returns:
None: This method does not return anything.
""" """
self.cpu = cpu self.cpu = cpu
@@ -140,7 +170,7 @@ class PTP4LStatusObject:
"""Gets the C group. """Gets the C group.
Returns: Returns:
The C group. str: The C group.
""" """
return self.c_group return self.c_group
@@ -148,7 +178,10 @@ class PTP4LStatusObject:
"""Sets the C group. """Sets the C group.
Args: Args:
c_group: The new C group. c_group (str): The new C group.
Returns:
None: This method does not return anything.
""" """
self.c_group = c_group self.c_group = c_group
@@ -156,7 +189,7 @@ class PTP4LStatusObject:
"""Gets the command. """Gets the command.
Returns: Returns:
The command. str: The command.
""" """
return self.command return self.command
@@ -164,7 +197,10 @@ class PTP4LStatusObject:
"""Sets the command. """Sets the command.
Args: Args:
command: The new command. command (str): The new command.
Returns:
None: This method does not return anything.
""" """
self.command = command self.command = command
@@ -172,7 +208,7 @@ class PTP4LStatusObject:
"""Gets the process. """Gets the process.
Returns: Returns:
The process. str: The process.
""" """
return self.process return self.process
@@ -180,8 +216,9 @@ class PTP4LStatusObject:
"""Sets the process. """Sets the process.
Args: Args:
process: The new process. process (str): The new process.
Returns:
None: This method does not return anything.
""" """
self.process = process self.process = process

View File

@@ -31,13 +31,14 @@ class PTP4LStatusOutput:
""" """
def __init__(self, ptp4l_status_output: [str]): def __init__(self, ptp4l_status_output: list[str]):
""" """
Constructor. Constructor.
Create an internal RunTimeOptionsObject from the passed parameter. Create an internal RunTimeOptionsObject from the passed parameter.
Args: Args:
ptp4l_status_output (list[str]): a list of strings representing the ptp4l_status_output ptp4l_status_output (list[str]): a list of strings representing the ptp4l_status_output
""" """
ptp4l_status_parser = PTP4LStatusParser(ptp4l_status_output) ptp4l_status_parser = PTP4LStatusParser(ptp4l_status_output)
output_values = ptp4l_status_parser.get_output_values_dict() output_values = ptp4l_status_parser.get_output_values_dict()
@@ -46,24 +47,24 @@ class PTP4LStatusOutput:
for value in output_values: for value in output_values:
ptp4l_status_object = PTP4LStatusObject(value) ptp4l_status_object = PTP4LStatusObject(value)
if 'Loaded' in output_values[value]: if "Loaded" in output_values[value]:
ptp4l_status_object.set_loaded(output_values[value]['Loaded']) ptp4l_status_object.set_loaded(output_values[value]["Loaded"])
if 'Active' in output_values[value]: if "Active" in output_values[value]:
ptp4l_status_object.set_active(output_values[value]['Active']) ptp4l_status_object.set_active(output_values[value]["Active"])
if 'Process' in output_values[value]: if "Process" in output_values[value]:
ptp4l_status_object.set_process(output_values[value]['Process']) ptp4l_status_object.set_process(output_values[value]["Process"])
if 'Main PID' in output_values[value]: if "Main PID" in output_values[value]:
ptp4l_status_object.set_main_pid(output_values[value]['Main PID']) ptp4l_status_object.set_main_pid(output_values[value]["Main PID"])
if 'Tasks' in output_values[value]: if "Tasks" in output_values[value]:
ptp4l_status_object.set_tasks(output_values[value]['Tasks']) ptp4l_status_object.set_tasks(output_values[value]["Tasks"])
if 'Memory' in output_values[value]: if "Memory" in output_values[value]:
ptp4l_status_object.set_memory(output_values[value]['Memory']) ptp4l_status_object.set_memory(output_values[value]["Memory"])
if 'CPU' in output_values[value]: if "CPU" in output_values[value]:
ptp4l_status_object.set_cpu(output_values[value]['CPU']) ptp4l_status_object.set_cpu(output_values[value]["CPU"])
if 'CGroup' in output_values[value]: if "CGroup" in output_values[value]:
ptp4l_status_object.set_c_group(output_values[value]['CGroup']) ptp4l_status_object.set_c_group(output_values[value]["CGroup"])
if 'command' in output_values[value]: if "command" in output_values[value]:
ptp4l_status_object.set_command(output_values[value]['command']) ptp4l_status_object.set_command(output_values[value]["command"])
self.ptp4l_status_object_list.append(ptp4l_status_object) self.ptp4l_status_object_list.append(ptp4l_status_object)
def get_ptp4l_objects(self) -> list[PTP4LStatusObject]: def get_ptp4l_objects(self) -> list[PTP4LStatusObject]:
@@ -71,19 +72,22 @@ class PTP4LStatusOutput:
Getter for ptp4l status object. Getter for ptp4l status object.
Returns: Returns:
A PTP4LStatusObject list list[PTP4LStatusObject]: A PTP4LStatusObject list
""" """
return self.ptp4l_status_object_list return self.ptp4l_status_object_list
def get_ptp4l_object(self, service_name: str) -> PTP4LStatusObject: def get_ptp4l_object(self, service_name: str) -> PTP4LStatusObject:
""" """
Getter for ptp4l object with the given service name Getter for ptp4l object with the given service name
Args: Args:
service_name (str): the name of the service (e.g., "phc1") service_name (str): the name of the service (e.g., "phc1")
Returns: PTP4LStatusObject Returns:
PTP4LStatusObject: the PTP4LStatusObject with the given service name
Raises:
KeywordException: if no service with the given name is found or if more than one service with the given name is found.
""" """
service_list = list(filter(lambda service: service.get_service_name() == service_name, self.ptp4l_status_object_list)) service_list = list(filter(lambda service: service.get_service_name() == service_name, self.ptp4l_status_object_list))
if len(service_list) == 1: if len(service_list) == 1:

View File

@@ -1,6 +1,7 @@
class PTP4LStatusParser: class PTP4LStatusParser:
""" """
Class for PTP4LStatusParser Class for PTP4LStatusParser
Example: Example:
● ptp4l@ptp1.service - Precision Time Protocol (PTP) service ● ptp4l@ptp1.service - Precision Time Protocol (PTP) service
Loaded: loaded (/etc/systemd/system/ptp4l@.service; enabled; vendor preset: disabled) Loaded: loaded (/etc/systemd/system/ptp4l@.service; enabled; vendor preset: disabled)
@@ -24,33 +25,32 @@ class PTP4LStatusParser:
└─3816048 /usr/sbin/ptp4l -f /etc/linuxptp/ptpinstance/ptp4l-ptp3.conf └─3816048 /usr/sbin/ptp4l -f /etc/linuxptp/ptpinstance/ptp4l-ptp3.conf
""" """
def __init__(self, ptp4l_status_output): def __init__(self, ptp4l_status_output: list[str]):
""" """
Constructor Constructor
Args: Args:
ptp4l_status_output (list[str]): a list of strings representing the output of a systemctl status <>. ptp4l_status_output (list[str]): a list of strings representing the output of a systemctl status <>.
""" """
self.ptp4l_status_output = ptp4l_status_output self.ptp4l_status_output = ptp4l_status_output
def get_output_values_dict( def get_output_values_dict(self) -> dict[str, dict[str, str]]:
self,
):
""" """
Getter for output values dict Getter for output values dict
Returns: the output values dict
Returns:
dict[str, dict[str, str]]: the output values dict
""" """
services = {} services = {}
current_service = None current_service = None
for line in self.ptp4l_status_output: for line in self.ptp4l_status_output:
line = line.strip() line = line.strip()
if line.startswith(''): # we have a new service to get values for if line.startswith(""): # we have a new service to get values for
service_name = line.split('@')[1].split(' ')[0].replace('.service','') # format ptp4l@ptp1.service - Precision Time Protocol (PTP) service service_name = line.split("@")[1].split(" ")[0].replace(".service", "") # format ptp4l@ptp1.service - Precision Time Protocol (PTP) service
services[service_name] = {} services[service_name] = {}
current_service = services[service_name] current_service = services[service_name]
elif line.startswith('└─') and current_service is not None: elif line.startswith("└─") and current_service is not None:
current_service['command'] = line[2:].strip() # we have a special case with the └─ which maps to the command to start the service current_service["command"] = line[2:].strip() # we have a special case with the └─ which maps to the command to start the service
elif current_service is not None: elif current_service is not None:
parts = line.split(":", 1) # parse the rest using the first : to make key value pairs parts = line.split(":", 1) # parse the rest using the first : to make key value pairs
if len(parts) == 2: if len(parts) == 2:

View File

@@ -13,6 +13,7 @@ from keywords.ptp.ptp4l.objects.ptp4l_status_output import PTP4LStatusOutput
class PTPServiceStatusValidator(BaseKeyword): class PTPServiceStatusValidator(BaseKeyword):
""" """
A class to validate the status and parameters of PTP (Precision Time Protocol) A class to validate the status and parameters of PTP (Precision Time Protocol)
services on a target host using systemctl. services on a target host using systemctl.
""" """
@@ -21,20 +22,21 @@ class PTPServiceStatusValidator(BaseKeyword):
Initializes the PTPServiceStatusValidator with an SSH connection. Initializes the PTPServiceStatusValidator with an SSH connection.
Args: Args:
ssh_connection: An instance of an SSH connection. ssh_connection (SSHConnection): An instance of an SSH connection.
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def verify_status_on_hostname(self, hostname: str, name: str, service_name: str) -> None: def verify_status_on_hostname(self, hostname: str, name: str, service_name: str) -> None:
""" """
verify systemctl ptp service status on hostname Verify systemctl ptp service status on hostname
Args: Args:
hostname (str): The name of the host hostname (str): The name of the host
name (str): name of instance (e.g., "phc1") name (str): name of instance (e.g., "phc1")
service_name (str): service name (e.g., "phc2sys@phc1.service") service_name (str): service name (e.g., "phc2sys@phc1.service")
Returns: None Returns:
None: This method does not return anything.
Raises: Raises:
Exception: raised when validate fails Exception: raised when validate fails
@@ -51,7 +53,7 @@ class PTPServiceStatusValidator(BaseKeyword):
def verify_status_and_instance_parameters_on_hostname(self, hostname: str, name: str, service_name: str, instance_parameters: str) -> None: def verify_status_and_instance_parameters_on_hostname(self, hostname: str, name: str, service_name: str, instance_parameters: str) -> None:
""" """
verify systemctl service status and instance parameters on hostname Verify systemctl service status and instance parameters on hostname
Args: Args:
hostname (str): The name of the host hostname (str): The name of the host
@@ -133,6 +135,7 @@ class PTPServiceStatusValidator(BaseKeyword):
def verify_service_status_and_recent_event(self, service_name: str, instance_name: str, threshold_seconds: int, expected_service_status: str = "active (running)") -> None: def verify_service_status_and_recent_event(self, service_name: str, instance_name: str, threshold_seconds: int, expected_service_status: str = "active (running)") -> None:
""" """
Verifies that the given PTP service is in the expected systemctl status and Verifies that the given PTP service is in the expected systemctl status and
that its most recent state change occurred within the given threshold. that its most recent state change occurred within the given threshold.
Args: Args:

View File

@@ -16,6 +16,12 @@ class ClockSetup:
setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this clock setup. setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this clock setup.
ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object. ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object.
Raises:
Exception: If the setup_dict does not contain required keys or if the ptp_host_ifs_dict does not contain required PTPHostInterfaceSetup entries.
Exception: If the setup_dict does not contain required instance hostnames.
Exception: If the setup_dict does not contain required instance parameters.
Exception: If the setup_dict does not contain required ptp_interface_names.
Exception: If the setup_dict does not contain required ptp_host_if entries.
""" """
if "name" not in setup_dict: if "name" not in setup_dict:
raise Exception("Every clock entry should have a name.") raise Exception("Every clock entry should have a name.")
@@ -39,13 +45,12 @@ class ClockSetup:
ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name]) ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name])
self.ptp_interfaces = ptp_interfaces self.ptp_interfaces = ptp_interfaces
def __str__(self): def __str__(self) -> str:
""" """
String representation of this object. String representation of this object.
Returns: Returns:
str: String representation of this object. str: String representation of this object.
""" """
return self.get_name() return self.get_name()

View File

@@ -16,6 +16,12 @@ class PHC2SysSetup:
setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this phc2sys setup. setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this phc2sys setup.
ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object. ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object.
Raises:
Exception: If the setup_dict does not contain required keys or if the ptp_host_ifs_dict does not contain required PTPHostInterfaceSetup entries.
Exception: If the setup_dict does not contain required instance hostnames.
Exception: If the setup_dict does not contain required instance parameters.
Exception: If the setup_dict does not contain required ptp_interface_names.
Exception: If the setup_dict does not contain required ptp_host_if entries.
""" """
if "name" not in setup_dict: if "name" not in setup_dict:
raise Exception("Every phc2sys entry should have a name.") raise Exception("Every phc2sys entry should have a name.")
@@ -39,13 +45,12 @@ class PHC2SysSetup:
ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name]) ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name])
self.ptp_interfaces = ptp_interfaces self.ptp_interfaces = ptp_interfaces
def __str__(self): def __str__(self) -> str:
""" """
String representation of this object. String representation of this object.
Returns: Returns:
str: String representation of this object. str: String representation of this object.
""" """
return self.get_name() return self.get_name()

View File

@@ -13,6 +13,11 @@ class PTPHostInterfaceSetup:
Args: Args:
setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this ptp host interface setup. 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: if "name" not in setup_dict:
raise Exception("Every ptp host interface entry should have a name.") raise Exception("Every ptp host interface entry should have a name.")
@@ -34,13 +39,12 @@ class PTPHostInterfaceSetup:
if "compute_0_interfaces" in setup_dict: if "compute_0_interfaces" in setup_dict:
self.compute_0_interfaces = setup_dict.get("compute_0_interfaces") self.compute_0_interfaces = setup_dict.get("compute_0_interfaces")
def __str__(self): def __str__(self) -> str:
""" """
String representation of this object. String representation of this object.
Returns: Returns:
str: String representation of this object. str: String representation of this object.
""" """
return self.get_name() return self.get_name()

View File

@@ -16,6 +16,8 @@ class TS2PHCSetup:
setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this ts2phc setup. setup_dict (Dict[str, Any]): The dictionary read from the JSON setup template file associated with this ts2phc setup.
ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object. ptp_host_ifs_dict (Dict[str, PTPHostInterfaceSetup]): The dictionary that maps the name of thePTPHostInterfaceSetup to its associated object.
Raises:
Exception: If the setup_dict does not contain required keys or if the ptp_host_ifs_dict does not contain required PTPHostInterfaceSetup entries.
""" """
if "name" not in setup_dict: if "name" not in setup_dict:
raise Exception("Every ts2phc entry should have a name.") raise Exception("Every ts2phc entry should have a name.")
@@ -39,13 +41,12 @@ class TS2PHCSetup:
ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name]) ptp_interfaces.append(ptp_host_ifs_dict[ptp_interface_name])
self.ptp_interfaces = ptp_interfaces self.ptp_interfaces = ptp_interfaces
def __str__(self): def __str__(self) -> str:
""" """
String representation of this object. String representation of this object.
Returns: Returns:
str: String representation of this object. str: String representation of this object.
""" """
return self.get_name() return self.get_name()

View File

@@ -69,7 +69,7 @@ class PTPSetupKeywords(BaseKeyword):
custom_expected_dict_template (Optional[str]): custom_expected_dict_template (Optional[str]):
Jinja2-formatted string representing an expected_dict override. If provided, Jinja2-formatted string representing an expected_dict override. If provided,
it replaces the auto-filtered expected_dict. it replaces the auto-filtered expected_dict.
expected_dict_overrides: Optional[Dict[str, Any]]: expected_dict_overrides (Optional[Dict[str, Any]]):
A dictionary of specific overrides to apply on the generated or provided expected_dict. A dictionary of specific overrides to apply on the generated or provided expected_dict.
Supports nested structure (e.g. overriding grandmaster_settings -> clock_class). Supports nested structure (e.g. overriding grandmaster_settings -> clock_class).

View File

@@ -1,5 +1,6 @@
from config.configuration_manager import ConfigurationManager from config.configuration_manager import ConfigurationManager
from framework.ssh.prompt_response import PromptResponse from framework.ssh.prompt_response import PromptResponse
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
from keywords.ptp.gnss_keywords import GnssKeywords from keywords.ptp.gnss_keywords import GnssKeywords
@@ -8,16 +9,16 @@ class SmaKeywords(BaseKeyword):
""" """
Disabled and enable SMA using SSH connection. Disabled and enable SMA using SSH connection.
Attributes: Inherits from:
ssh_connection: An instance of an SSH connection. BaseKeyword: to provide common functionality.
""" """
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Initializes the SmaKeywords with an SSH connection. Initializes the SmaKeywords with an SSH connection.
Args: Args:
ssh_connection: An instance of an SSH connection. ssh_connection (SSHConnection): An instance of an SSH connection.
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
@@ -29,7 +30,8 @@ class SmaKeywords(BaseKeyword):
hostname (str): The name of the host. hostname (str): The name of the host.
nic (str): The name of the NIC. nic (str): The name of the NIC.
Returns : None Returns :
None: This method does not return anything.
""" """
gnss_keywords = GnssKeywords() gnss_keywords = GnssKeywords()
@@ -68,7 +70,8 @@ class SmaKeywords(BaseKeyword):
hostname (str): The name of the host. hostname (str): The name of the host.
nic (str): The name of the NIC. nic (str): The name of the NIC.
Returns : None Returns :
None: This method does not return anything.
""" """
gnss_keywords = GnssKeywords() gnss_keywords = GnssKeywords()

View File

@@ -1,12 +1,14 @@
class ProductVersion: class ProductVersion:
""" """
This class models a ProductVersion as an object. This class models a ProductVersion as an object.
ProductVersions have names and can also be compared chronologically. ProductVersions have names and can also be compared chronologically.
""" """
def __init__(self, version_name: str, version_id: int): def __init__(self, version_name: str, version_id: int):
""" """
Constructor Constructor
Args: Args:
version_name (str): The String name of the Product Version version_name (str): The String name of the Product Version
version_id (int): Integers assigned for comparing release order version_id (int): Integers assigned for comparing release order
@@ -15,12 +17,33 @@ class ProductVersion:
self.version_id = version_id self.version_id = version_id
def __str__(self) -> str: def __str__(self) -> str:
"""
Returns the string representation of the product version.
Returns:
str: The version name.
"""
return self.version_name return self.version_name
def __hash__(self): def __hash__(self) -> int:
"""
Returns the hash of the product version based on its name.
Returns:
int: Hash value.
"""
return hash(self.version_name) return hash(self.version_name)
def __eq__(self, other): def __eq__(self, other: object) -> bool:
"""
Checks if two ProductVersion objects are equal based on their name and id.
Args:
other (object): The other ProductVersion to compare with.
Returns:
bool: True if both ProductVersion objects have the same name and id, False otherwise.
"""
return hash(self) == hash(other) return hash(self) == hash(other)
def get_name(self) -> str: def get_name(self) -> str:
@@ -28,7 +51,7 @@ class ProductVersion:
Getter for the name of this version Getter for the name of this version
Returns: Returns:
str: The name of the version
""" """
return self.version_name return self.version_name
@@ -37,27 +60,30 @@ class ProductVersion:
Getter for the id of this version Getter for the id of this version
Returns: Returns:
int: The id of the version
""" """
return self.version_id return self.version_id
def is_before_or_equal_to(self, other_product_version) -> bool: def is_before_or_equal_to(self, other_product_version: "ProductVersion") -> bool:
""" """
Returns true if SELF <= other_product_version based on their id. Returns true if SELF <= other_product_version based on their id.
Args: Args:
other_product_version (ProductVersion): The version of comparison other_product_version (ProductVersion): The version of comparison
Returns (bool): SELF <= other_product_version based on their id. Returns:
bool: SELF <= other_product_version based on their id.
""" """
return self.version_id <= other_product_version.version_id return self.version_id <= other_product_version.version_id
def is_after_or_equal_to(self, other_product_version) -> bool: def is_after_or_equal_to(self, other_product_version: "ProductVersion") -> bool:
""" """
Returns true if SELF >= other_product_version based on their id. Returns true if SELF >= other_product_version based on their id.
Args: Args:
other_product_version (ProductVersion): The version of comparison other_product_version (ProductVersion): The version of comparison
Returns (bool): SELF >= other_product_version based on their id. Returns:
bool: SELF >= other_product_version based on their id.
""" """
return self.version_id >= other_product_version.version_id return self.version_id >= other_product_version.version_id

View File

@@ -7,12 +7,13 @@ class String:
def is_empty(some_string: str) -> bool: def is_empty(some_string: str) -> bool:
""" """
Checks if 'some_string' is an empty string. Checks if 'some_string' is an empty string.
An empty string is either a sequence with zero characters or one that consists only of space characters. An empty string is either a sequence with zero characters or one that consists only of space characters.
Args: Args:
some_string: the string to be checked. some_string (str): the string to be checked.
Returns: Returns:
bool: True if 'some_string' is empty, False otherwise. bool: True if 'some_string' is empty, False otherwise.
""" """
return not some_string or some_string.strip() == "" return not some_string or some_string.strip() == ""

View File

@@ -4,27 +4,29 @@ class TypeConverter:
""" """
@staticmethod @staticmethod
def parse_string_to_dict(string: str, separator_char='=') -> dict[str, str]: def parse_string_to_dict(string: str, separator_char: str = "=") -> dict[str, str]:
""" """
This function converts a string in the format "key_1<separator_char>value_1,key_2<separator_char>value_2... Converts a string representation of key-value pairs into a dictionary.
This function converts a string in the format "key_1<separator_char>value_1, key_2<separator_char>value_2,...
key_n<separator_char>value_n" in a dictionary in the following format: key_n<separator_char>value_n" in a dictionary in the following format:
{"key_1": value_1, "key_2": value_2 ... "key_n": value_n}. {"key_1": value_1, "key_2": value_2 ... "key_n": value_n}.
Note: this function will try to convert numeric and boolean values to its correct type. Note: this function will try to convert numeric and boolean values to its correct type.
Args: Args:
string (str): a string in the following format: "key_1 <separator_char> value_1, string (str): a string in the following format: "key_1 <separator_char> value_1,
key_2 <separator_char> value_2 ... key_n <separator_char> value_n" key_2 <separator_char> value_2, ... key_n <separator_char> value_n"
separator_char (str): the character used to separate key from value in the <string>. separator_char (str): the character used to separate key from value in the <string>.
If not provided, the default value is '='.
Returns: Returns:
dict in the following format: {"key_1": value_1, "key_2" = value_2 ... "key_n" = value_n} dict[str, str]: a dictionary in the following format: {"key_1": value_1, "key_2": value_2 ... "key_n": value_n}
""" """
result = {} result = {}
clean_string = string.replace('{', '').replace('}', '').replace('\'', '') clean_string = string.replace("{", "").replace("}", "").replace("'", "")
pairs = clean_string.split(',') pairs = clean_string.split(",")
for pair in pairs: for pair in pairs:
key, value = pair.split(separator_char) key, value = pair.split(separator_char)
@@ -43,6 +45,8 @@ class TypeConverter:
@staticmethod @staticmethod
def parse_string_to_list(string: str) -> list[str]: def parse_string_to_list(string: str) -> list[str]:
""" """
Converts a string representation of a list into an actual list.
This function converts a string in the format "['value_1, value_2 ... value_n']" in a list of string in This function converts a string in the format "['value_1, value_2 ... value_n']" in a list of string in
the following format: ["value_1", "value_2" ... "value_n"]. the following format: ["value_1", "value_2" ... "value_n"].
@@ -50,10 +54,8 @@ class TypeConverter:
string (str): a string in the following format: "['value_1, value_2 ... value_n']" string (str): a string in the following format: "['value_1, value_2 ... value_n']"
Returns: Returns:
list of strings in the following format: ["value_1", "value_2" ... "value_n"] list[str]: a list of string in the following format: ["value_1", "value_2" ... "value_n"]
""" """
if string is None or string == "[]": if string is None or string == "[]":
return [] return []
@@ -62,7 +64,7 @@ class TypeConverter:
if not cleaned_str: if not cleaned_str:
return [] return []
items = [item.strip().strip("'\"") for item in cleaned_str.split(',')] items = [item.strip().strip("'\"") for item in cleaned_str.split(",")]
return items return items
@@ -72,11 +74,13 @@ class TypeConverter:
This function verifies if <string> represents an integer number. This function verifies if <string> represents an integer number.
Args: Args:
string: a string that one wants to verify to see if it represents an integer number. string (str): a string that one wants to verify to see if it represents an integer number.
Returns: Returns:
True if <string> represents an integer number, and False otherwise. bool: True if <string> represents an integer number, and False otherwise.
Raises:
TypeError: If the input is not a string.
""" """
if not isinstance(string, str): if not isinstance(string, str):
raise TypeError(f"The argument passed <{string}> is not of type str.") raise TypeError(f"The argument passed <{string}> is not of type str.")
@@ -89,16 +93,18 @@ class TypeConverter:
This function verifies if <string> represents a float point number. This function verifies if <string> represents a float point number.
Args: Args:
string: a string that one wants to verify to see if it represents a floating-point number. string (str): a string that one wants to verify to see if it represents a floating-point number.
Returns: Returns:
True if <string> represents a float point number, and False otherwise. bool: True if <string> represents a float point number, and False otherwise.
Raises:
TypeError: If the input is not a string.
""" """
if not isinstance(string, str): if not isinstance(string, str):
raise TypeError(f"The argument passed <{string}> is not of type str.") raise TypeError(f"The argument passed <{string}> is not of type str.")
return string.replace('.', '', 1).isdigit() and string.count('.') < 2 return string.replace(".", "", 1).isdigit() and string.count(".") < 2
@staticmethod @staticmethod
def is_number(string: str) -> bool: def is_number(string: str) -> bool:
@@ -106,11 +112,10 @@ class TypeConverter:
This function verifies if <string> represents an integer or float point number. This function verifies if <string> represents an integer or float point number.
Args: Args:
string: a string that one wants to verify to see if it represents an integer or a floating-point number. string (str) : a string that one wants to verify to see if it represents an integer or a floating-point number.
Returns: Returns:
True if <string> represents an integer or float point number, and False otherwise. bool: True if <string> represents an integer or float point number, and False otherwise.
""" """
return TypeConverter.is_int(string) or TypeConverter.is_float(string) return TypeConverter.is_int(string) or TypeConverter.is_float(string)
@@ -120,11 +125,13 @@ class TypeConverter:
This function verifies if <string> represents a boolean value. This function verifies if <string> represents a boolean value.
Args: Args:
string: a string that one wants to verify to see if it represents a boolean value. string (str) : a string that one wants to verify to see if it represents a boolean value.
Returns: Returns:
True if <string> represents a boolean value, and False otherwise. bool: True if <string> represents a boolean value, and False otherwise.
Raises:
TypeError: If the input is not a string.
""" """
if not isinstance(string, str): if not isinstance(string, str):
raise TypeError(f"The argument passed <{string}> is not of type str.") raise TypeError(f"The argument passed <{string}> is not of type str.")

View File

@@ -21,32 +21,32 @@ class PowerKeywords(BaseKeyword):
def power_on(self, host_name: str) -> bool: def power_on(self, host_name: str) -> bool:
""" """
Powers on the given host and waits for the host to be in a good state Powers on the given host and waits for the host to be in a good state
Args: Args:
host_name (): the name of the host host_name (str): the name of the host
Returns: Returns:
bool: True if host powers on successfully
Raises:
KeywordException: if host fails to power on within the expected time
""" """
IPMIToolChassisPowerKeywords(self.ssh_connection, host_name).power_on() IPMIToolChassisPowerKeywords(self.ssh_connection, host_name).power_on()
if not self.is_powered_on(host_name): if not self.is_powered_on(host_name):
host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name) host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name)
raise KeywordException( raise KeywordException("Power on host did not power on in the required time. Host values were: " f"Operational: {host_value.get_operational()} " f"Administrative: {host_value.get_administrative()} " f"Availability: {host_value.get_availability()}")
"Power on host did not power on in the required time. Host values were: "
f"Operational: {host_value.get_operational()} "
f"Administrative: {host_value.get_administrative()} "
f"Availability: {host_value.get_availability()}"
)
return True return True
def is_powered_on(self, host_name, power_on_wait_timeout: int = 1800): def is_powered_on(self, host_name: str, power_on_wait_timeout: int = 1800) -> bool:
""" """
Checks that the host is powered on and in a good state Checks that the host is powered on and in a good state
Args: Args:
host_name (): the name of the host host_name (str): the name of the host
power_on_wait_timeout (): the time to wait for the host to be powered on power_on_wait_timeout (int): the time to wait for the host to be powered on
Returns: Returns:
bool: True if the host is powered on, healthy and has no failure alarms ; False otherwise
""" """
timeout = time.time() + power_on_wait_timeout timeout = time.time() + power_on_wait_timeout
refresh_time = 5 refresh_time = 5
@@ -59,7 +59,7 @@ class PowerKeywords(BaseKeyword):
try: try:
status = IPMIToolChassisStatusKeywords(self.ssh_connection, host_name).get_ipmi_chassis_status() status = IPMIToolChassisStatusKeywords(self.ssh_connection, host_name).get_ipmi_chassis_status()
if status.system_power == 'on': if status.system_power == "on":
get_logger().log_info("The host is powered on.") get_logger().log_info("The host is powered on.")
is_power_on = True is_power_on = True
@@ -71,7 +71,7 @@ class PowerKeywords(BaseKeyword):
alarms = AlarmListKeywords(self.ssh_connection).alarm_list() alarms = AlarmListKeywords(self.ssh_connection).alarm_list()
is_alarms_list_ok = True is_alarms_list_ok = True
for alarm in alarms: for alarm in alarms:
if alarm.get_alarm_id() == "200.004" or alarm.get_alarm_id() == "200.005" or alarm.get_alarm_id() == '750.006': # if alarm.get_alarm_id() == "200.004" or alarm.get_alarm_id() == "200.005" or alarm.get_alarm_id() == "750.006": #
is_alarms_list_ok = False is_alarms_list_ok = False
if is_alarms_list_ok: if is_alarms_list_ok:
get_logger().log_info("There are no critical failures alarms") get_logger().log_info("There are no critical failures alarms")
@@ -90,31 +90,31 @@ class PowerKeywords(BaseKeyword):
def power_off(self, host_name: str) -> bool: def power_off(self, host_name: str) -> bool:
""" """
Powers off the host Powers off the host
Args: Args:
host_name (): the name of the host host_name (str): the name of the host
Returns: Returns:
bool: True if powered off
Raises:
KeywordException: if host fails to power off within the expected time
""" """
IPMIToolChassisPowerKeywords(self.ssh_connection, host_name).power_off() IPMIToolChassisPowerKeywords(self.ssh_connection, host_name).power_off()
if not self.is_powered_off(host_name): if not self.is_powered_off(host_name):
host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name) host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name)
raise KeywordException( raise KeywordException("Power off host did not power off in the required time. Host values were: " f"Operational: {host_value.get_operational()} " f"Administrative: {host_value.get_administrative()} " f"Availability: {host_value.get_availability()}")
"Power off host did not power off in the required time. Host values were: "
f"Operational: {host_value.get_operational()} "
f"Administrative: {host_value.get_administrative()} "
f"Availability: {host_value.get_availability()}"
)
return True return True
def is_powered_off(self, host_name): def is_powered_off(self, host_name: str) -> bool:
""" """
Waits for the host to be powered off Waits for the host to be powered off
Args: Args:
host_name (): the name of the host host_name (str): the name of the host
Returns: Returns:
bool: True if host powered off and host operations are disabled; False otherwise
""" """
timeout = time.time() + 600 timeout = time.time() + 600
is_power_off = False is_power_off = False
@@ -123,12 +123,12 @@ class PowerKeywords(BaseKeyword):
while time.time() < timeout: while time.time() < timeout:
try: try:
status = IPMIToolChassisStatusKeywords(self.ssh_connection, host_name).get_ipmi_chassis_status() status = IPMIToolChassisStatusKeywords(self.ssh_connection, host_name).get_ipmi_chassis_status()
if status.system_power == 'off': if status.system_power == "off":
get_logger().log_info("The host is powered off.") get_logger().log_info("The host is powered off.")
is_power_off = True is_power_off = True
host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name) host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name)
if host_value.get_availability() == 'offline' and host_value.get_operational() == 'disabled': if host_value.get_availability() == "offline" and host_value.get_operational() == "disabled":
is_host_list_ok = True is_host_list_ok = True
if is_power_off and is_host_list_ok: if is_power_off and is_host_list_ok: