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:
"""
Getter for steps_removed
Returns: the steps_removed value
Returns:
int: the steps_removed value
"""
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
Args:
steps_removed (): the steps_removed value
steps_removed (int): the steps_removed value
Returns:
None: This method does not return anything.
"""
self.steps_removed = steps_removed
@@ -30,37 +33,41 @@ class PMCGetCurrentDataSetObject:
def get_offset_from_master(self) -> float:
"""
Getter for offset_from_master
Returns: offset_from_master
Returns:
float: the offset_from_master value
"""
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
Args:
offset_from_master (): the offset_from_master value
offset_from_master (float): the offset_from_master value
Returns:
None: This method does not return anything.
"""
self.offset_from_master = offset_from_master
def get_mean_path_delay(self) -> float:
"""
Getter for mean_path_delay
Returns: mean_path_delay value
Returns:
float: the mean_path_delay value
"""
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
Args:
mean_path_delay (): mean_path_delay value
mean_path_delay (float): mean_path_delay value
Returns:
None: This method does not return anything.
"""
self.mean_path_delay = mean_path_delay

View File

@@ -4,26 +4,25 @@ class PMCGetDomainObject:
"""
def __init__(self):
self.domain_number: int = -1
self.domain_number: int = -1
def get_domain_number(self) -> int:
"""
Getter for domain_number
Returns: the domain_number value
Returns:
int: the domain_number value
"""
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
Args:
domain_number : the domain_number value
domain_number (int): the domain_number value
Returns:
None: This method does not return anything.
"""
self.domain_number = domain_number

View File

@@ -4,9 +4,12 @@ class PMCGetGrandmasterSettingsNpObject:
"""
def __init__(self):
"""
Initializes the attributes of the object to default values.
"""
self.clock_class: int = -1
self.clock_accuracy: str = ''
self.offset_scaled_log_variance: str = ''
self.clock_accuracy: str = ""
self.offset_scaled_log_variance: str = ""
self.current_utc_offset: int = -1
self.leap61: int = -1
self.leap59: int = -1
@@ -14,216 +17,235 @@ class PMCGetGrandmasterSettingsNpObject:
self.ptp_time_scale: int = -1
self.time_traceable: int = -1
self.frequency_traceable: int = -1
self.time_source: str = ''
self.time_source: str = ""
def get_clock_class(self) -> int:
"""
Getter for clock_class
Returns: the clock_class value
Returns:
int: the clock_class value
"""
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
Args:
clock_class : the clock_class value
clock_class (int): the clock_class value
Returns:
None: This method does not return anything.
"""
self.clock_class = clock_class
def get_clock_accuracy(self) -> str:
"""
Getter for clock_accuracy
Returns: the clock_accuracy value
Returns:
str: the clock_accuracy value
"""
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
Args:
clock_accuracy : the clock_accuracy value
clock_accuracy (str): the clock_accuracy value
Returns:
None: This method does not return anything.
"""
self.clock_accuracy = clock_accuracy
def get_offset_scaled_log_variance(self) -> str:
"""
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
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
Args:
offset_scaled_log_variance : the offset_scaled_log_variance value
offset_scaled_log_variance (str): the offset_scaled_log_variance value
Returns:
None: This method does not return anything.
"""
self.offset_scaled_log_variance = offset_scaled_log_variance
def get_current_utc_offset(self) -> int:
"""
Getter for current_utc_offset
Returns: the current_utc_offset value
Returns:
int: the current_utc_offset value
"""
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
Args:
current_utc_offset : the current_utc_offset value
current_utc_offset (int): the current_utc_offset value
Returns:
None: This method does not return anything.
"""
self.current_utc_offset = current_utc_offset
def get_leap61(self) -> int:
"""
Getter for leap61
Returns: the leap61 value
Returns:
int: the leap61 value
"""
return self.leap61
def set_leap61(self, leap61: int):
def set_leap61(self, leap61: int) -> None:
"""
Setter for leap61
Args:
leap61 : the leap61 value
leap61 (int): the leap61 value
Returns:
None: This method does not return anything.
"""
self.leap61 = leap61
def get_leap59(self) -> int:
"""
Getter for leap59
Returns: the leap59 value
Returns:
int: the leap59 value
"""
return self.leap59
def set_leap59(self, leap59: int):
def set_leap59(self, leap59: int) -> None:
"""
Setter for leap59
Args:
leap59 : the leap59 value
leap59 (int): the leap59 value
Returns:
None: This method does not return anything.
"""
self.leap59 = leap59
def get_current_utc_off_set_valid(self) -> int:
"""
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
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
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:
None: This method does not return anything.
"""
self.current_utc_off_set_valid = current_utc_off_set_valid
def get_ptp_time_scale(self) -> int:
"""
Getter for ptp_time_scale
Returns: the ptp_time_scale value
Returns:
int: the ptp_time_scale value
"""
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
Args:
ptp_time_scale : the ptp_time_scale value
ptp_time_scale (int): the ptp_time_scale value
Returns:
None: This method does not return anything.
"""
self.ptp_time_scale = ptp_time_scale
def get_time_traceable(self) -> int:
"""
Getter for time_traceable
Returns: the time_traceable value
Returns:
int: the time_traceable value
"""
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
Args:
time_traceable : the time_traceable value
time_traceable (int): the time_traceable value
Returns:
None: This method does not return anything.
"""
self.time_traceable = time_traceable
def get_frequency_traceable(self) -> int:
"""
Getter for frequency_traceable
Returns: the frequency_traceable value
Returns:
int: the frequency_traceable value
"""
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
Args:
frequency_traceable : the frequency_traceable value
frequency_traceable (int): the frequency_traceable value
Returns:
None: This method does not return anything.
"""
self.frequency_traceable = frequency_traceable
def get_time_source(self) -> str:
"""
Getter for time_source
Returns: the time_source value
Returns
str: the time_source value
"""
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
Args:
time_source : the time_source value
time_source (str): the time_source value
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):
self.parent_port_identity: str = ''
self.parent_port_identity: str = ""
self.parent_stats: int = -1
self.observed_parent_offset_scaled_log_variance: str = ''
self.observed_parent_clock_phase_change_rate: str = ''
self.observed_parent_offset_scaled_log_variance: str = ""
self.observed_parent_clock_phase_change_rate: str = ""
self.grandmaster_priority1: int = -1
self.gm_clock_class: int = -1
self.gm_clock_accuracy: str = ''
self.gm_offset_scaled_log_variance: str = ''
self.gm_clock_accuracy: str = ""
self.gm_offset_scaled_log_variance: str = ""
self.grandmaster_priority2: int = -1
self.grandmaster_identity: str = ''
self.grandmaster_identity: str = ""
def get_parent_port_identity(self) -> str:
"""
Getter for parent_port_identity
Returns: parent_port_identity
Returns:
str: 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
Args:
parent_port_identity (): the parent_port_identity value
parent_port_identity (str): the parent_port_identity value
Returns:
None: This method does not return anything.
"""
self.parent_port_identity = parent_port_identity
def get_parent_stats(self) -> int:
"""
Getter for parent_stats
Returns: parent_stats value
Returns:
int: parent_stats value
"""
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
Args:
parent_stats (): parent_stats value
parent_stats (int): parent_stats value
Returns:
None: This method does not return anything.
"""
self.parent_stats = parent_stats
def get_observed_parent_offset_scaled_log_variance(self) -> str:
"""
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
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
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:
None: This method does not return anything.
"""
self.observed_parent_offset_scaled_log_variance = observed_parent_offset_scaled_log_variance
def get_observed_parent_clock_phase_change_rate(self) -> str:
"""
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
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
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:
None: This method does not return anything.
"""
self.observed_parent_clock_phase_change_rate = observed_parent_clock_phase_change_rate
def get_grandmaster_priority1(self) -> int:
"""
Getter for grandmaster_priority1
Returns: the grandmaster_priority1 value
Returns:
int: the grandmaster_priority1 value
"""
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
Args:
grandmaster_priority1 (): the grandmaster_priority1 value
grandmaster_priority1 (int): the grandmaster_priority1 value
Returns:
None: This method does not return anything.
"""
self.grandmaster_priority1 = grandmaster_priority1
def get_gm_clock_class(self) -> int:
"""
Getter for gm_clock_class
Returns: the gm_clock_class value
Returns:
int: the gm_clock_class value
"""
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
Args:
gm_clock_class (): the gm_clock_class value
gm_clock_class (int): the gm_clock_class value
Returns:
None: This method does not return anything.
"""
self.gm_clock_class = gm_clock_class
def get_gm_clock_accuracy(self) -> str:
"""
Getter for gm_clock_accuracy
Returns: the gm_clock_accuracy value
Returns:
str: the gm_clock_accuracy value
"""
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
Args:
gm_clock_accuracy (): the gm_clock_accuracy value
gm_clock_accuracy (str): the gm_clock_accuracy value
Returns:
None: This method does not return anything.
"""
self.gm_clock_accuracy = gm_clock_accuracy
def get_gm_offset_scaled_log_variance(self) -> str:
"""
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
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
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:
None: This method does not return anything.
"""
self.gm_offset_scaled_log_variance = gm_offset_scaled_log_variance
def get_grandmaster_priority2(self) -> int:
"""
Getter for grandmaster_priority2
Returns: the grandmaster_priority2 value
Returns:
int: the grandmaster_priority2 value
"""
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
Args:
grandmaster_priority2 (): the grandmaster_priority2 value
grandmaster_priority2 (int): the grandmaster_priority2 value
Returns:
None: This method does not return anything.
"""
self.grandmaster_priority2 = grandmaster_priority2
def get_grandmaster_identity(self) -> str:
"""
Getter for grandmaster_identity
Returns: the grandmaster_identity value
Returns:
str: the grandmaster_identity value
"""
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
Args:
grandmaster_identity (): the grandmaster_identity value
grandmaster_identity (str): the grandmaster_identity value
Returns:
None: This method does not return anything.history
"""
self.grandmaster_identity = grandmaster_identity

View File

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

View File

@@ -10,15 +10,21 @@ class GetPtp4lServiceStatusKeywords(BaseKeyword):
"""
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
def get_systemctl_ptp4l_status(self) -> PTP4LStatusOutput:
"""
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)
return ptp4l_status_output

View File

@@ -1,34 +1,43 @@
class PTP4LStatusObject:
"""Represents system resource information.
Attributes:
service_name (str): the name of the service
loaded (str): The loading status of the resource.
active (str): The active status of the resource.
main_pid (str): The main process ID associated with the resource.
tasks (str): Information about the tasks related to the resource.
memory (str): Memory usage information.
cpu (str): CPU usage information.
c_group (str): The C group the resource belongs to.
"""
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:
service_name (str): the name of the service
loaded (str): The loading 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.
tasks (str): Information about the tasks related to the resource.
memory (str): Memory usage information.
cpu (str): CPU usage information.
c_group (str): The C group the resource belongs to.
command (str): The command used to start the resource.
"""
self.service_name = service_name
self.loaded: str = ''
self.active: str = ''
self.process: str = ''
self.main_pid: str = ''
self.tasks: str = ''
self.memory: str = ''
self.cpu: str = ''
self.c_group: str = ''
self.command: str = ''
self.loaded: str = ""
self.active: str = ""
self.process: str = ""
self.main_pid: str = ""
self.tasks: str = ""
self.memory: str = ""
self.cpu: str = ""
self.c_group: str = ""
self.command: str = ""
def get_service_name(self) -> str:
"""Gets the service_name.
Returns:
The service_name.
str: The service_name.
"""
return self.service_name
@@ -36,7 +45,10 @@ class PTP4LStatusObject:
"""Sets service_name.
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
@@ -44,7 +56,7 @@ class PTP4LStatusObject:
"""Gets the loading status.
Returns:
The loading status.
str: The loading status.
"""
return self.loaded
@@ -52,7 +64,10 @@ class PTP4LStatusObject:
"""Sets the loading status.
Args:
loaded: The new loading status.
loaded (str): The new loading status.
Returns:
None: This method does not return anything.
"""
self.loaded = loaded
@@ -60,7 +75,7 @@ class PTP4LStatusObject:
"""Gets the active status.
Returns:
The active status.
str: The active status.
"""
return self.active
@@ -68,7 +83,10 @@ class PTP4LStatusObject:
"""Sets the active status.
Args:
active: The new active status.
active (str): The new active status.
Returns:
None: This method does not return anything.
"""
self.active = active
@@ -76,7 +94,7 @@ class PTP4LStatusObject:
"""Gets the main process ID.
Returns:
The main process ID.
str: The main process ID.
"""
return self.main_pid
@@ -84,7 +102,10 @@ class PTP4LStatusObject:
"""Sets the main process ID.
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
@@ -92,7 +113,7 @@ class PTP4LStatusObject:
"""Gets the tasks information.
Returns:
The tasks information.
str: The tasks information.
"""
return self.tasks
@@ -100,7 +121,10 @@ class PTP4LStatusObject:
"""Sets the tasks information.
Args:
tasks: The new tasks information.
tasks (str): The new tasks information.
Returns:
None: This method does not return anything.
"""
self.tasks = tasks
@@ -108,7 +132,7 @@ class PTP4LStatusObject:
"""Gets the memory information.
Returns:
The memory information.
str: The memory information.
"""
return self.memory
@@ -116,7 +140,10 @@ class PTP4LStatusObject:
"""Sets the memory information.
Args:
memory: The new memory information.
memory (str): The new memory information.
Returns:
None: This method does not return anything.
"""
self.memory = memory
@@ -124,7 +151,7 @@ class PTP4LStatusObject:
"""Gets the CPU information.
Returns:
The CPU information.
str: The CPU information.
"""
return self.cpu
@@ -132,7 +159,10 @@ class PTP4LStatusObject:
"""Sets the CPU information.
Args:
cpu: The new CPU information.
cpu (str): The new CPU information.
Returns:
None: This method does not return anything.
"""
self.cpu = cpu
@@ -140,7 +170,7 @@ class PTP4LStatusObject:
"""Gets the C group.
Returns:
The C group.
str: The C group.
"""
return self.c_group
@@ -148,7 +178,10 @@ class PTP4LStatusObject:
"""Sets the C group.
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
@@ -156,7 +189,7 @@ class PTP4LStatusObject:
"""Gets the command.
Returns:
The command.
str: The command.
"""
return self.command
@@ -164,7 +197,10 @@ class PTP4LStatusObject:
"""Sets the command.
Args:
command: The new command.
command (str): The new command.
Returns:
None: This method does not return anything.
"""
self.command = command
@@ -172,7 +208,7 @@ class PTP4LStatusObject:
"""Gets the process.
Returns:
The process.
str: The process.
"""
return self.process
@@ -180,8 +216,9 @@ class PTP4LStatusObject:
"""Sets the process.
Args:
process: The new process.
process (str): The new process.
Returns:
None: This method does not return anything.
"""
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.
Create an internal RunTimeOptionsObject from the passed parameter.
Create an internal RunTimeOptionsObject from the passed parameter.
Args:
ptp4l_status_output (list[str]): a list of strings representing the ptp4l_status_output
"""
ptp4l_status_parser = PTP4LStatusParser(ptp4l_status_output)
output_values = ptp4l_status_parser.get_output_values_dict()
@@ -46,24 +47,24 @@ class PTP4LStatusOutput:
for value in output_values:
ptp4l_status_object = PTP4LStatusObject(value)
if 'Loaded' in output_values[value]:
ptp4l_status_object.set_loaded(output_values[value]['Loaded'])
if 'Active' in output_values[value]:
ptp4l_status_object.set_active(output_values[value]['Active'])
if 'Process' in output_values[value]:
ptp4l_status_object.set_process(output_values[value]['Process'])
if 'Main PID' in output_values[value]:
ptp4l_status_object.set_main_pid(output_values[value]['Main PID'])
if 'Tasks' in output_values[value]:
ptp4l_status_object.set_tasks(output_values[value]['Tasks'])
if 'Memory' in output_values[value]:
ptp4l_status_object.set_memory(output_values[value]['Memory'])
if 'CPU' in output_values[value]:
ptp4l_status_object.set_cpu(output_values[value]['CPU'])
if 'CGroup' in output_values[value]:
ptp4l_status_object.set_c_group(output_values[value]['CGroup'])
if 'command' in output_values[value]:
ptp4l_status_object.set_command(output_values[value]['command'])
if "Loaded" in output_values[value]:
ptp4l_status_object.set_loaded(output_values[value]["Loaded"])
if "Active" in output_values[value]:
ptp4l_status_object.set_active(output_values[value]["Active"])
if "Process" in output_values[value]:
ptp4l_status_object.set_process(output_values[value]["Process"])
if "Main PID" in output_values[value]:
ptp4l_status_object.set_main_pid(output_values[value]["Main PID"])
if "Tasks" in output_values[value]:
ptp4l_status_object.set_tasks(output_values[value]["Tasks"])
if "Memory" in output_values[value]:
ptp4l_status_object.set_memory(output_values[value]["Memory"])
if "CPU" in output_values[value]:
ptp4l_status_object.set_cpu(output_values[value]["CPU"])
if "CGroup" in output_values[value]:
ptp4l_status_object.set_c_group(output_values[value]["CGroup"])
if "command" in output_values[value]:
ptp4l_status_object.set_command(output_values[value]["command"])
self.ptp4l_status_object_list.append(ptp4l_status_object)
def get_ptp4l_objects(self) -> list[PTP4LStatusObject]:
@@ -71,22 +72,25 @@ class PTP4LStatusOutput:
Getter for ptp4l status object.
Returns:
A PTP4LStatusObject list
list[PTP4LStatusObject]: A PTP4LStatusObject list
"""
return self.ptp4l_status_object_list
def get_ptp4l_object(self, service_name: str) -> PTP4LStatusObject:
"""
Getter for ptp4l object with the given service name
Args:
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))
if len(service_list) == 1:
return service_list[0]
else: # should never be more than one but this will check anyway
raise KeywordException(f"Found {len(service_list)} service(s) with the service name: {service_name}.")
raise KeywordException(f"Found {len(service_list)} service(s) with the service name: {service_name}.")

View File

@@ -1,6 +1,7 @@
class PTP4LStatusParser:
"""
Class for PTP4LStatusParser
Example:
● ptp4l@ptp1.service - Precision Time Protocol (PTP) service
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
"""
def __init__(self, ptp4l_status_output):
def __init__(self, ptp4l_status_output: list[str]):
"""
Constructor
Args:
ptp4l_status_output (list[str]): a list of strings representing the output of a systemctl status <>.
"""
self.ptp4l_status_output = ptp4l_status_output
def get_output_values_dict(
self,
):
def get_output_values_dict(self) -> dict[str, dict[str, str]]:
"""
Getter for output values dict
Returns: the output values dict
Returns:
dict[str, dict[str, str]]: the output values dict
"""
services = {}
current_service = None
for line in self.ptp4l_status_output:
line = line.strip()
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
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
services[service_name] = {}
current_service = services[service_name]
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
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
elif current_service is not None:
parts = line.split(":", 1) # parse the rest using the first : to make key value pairs
if len(parts) == 2:

View File

@@ -13,6 +13,7 @@ from keywords.ptp.ptp4l.objects.ptp4l_status_output import PTP4LStatusOutput
class PTPServiceStatusValidator(BaseKeyword):
"""
A class to validate the status and parameters of PTP (Precision Time Protocol)
services on a target host using systemctl.
"""
@@ -21,20 +22,21 @@ class PTPServiceStatusValidator(BaseKeyword):
Initializes the PTPServiceStatusValidator with an SSH connection.
Args:
ssh_connection: An instance of an SSH connection.
ssh_connection (SSHConnection): An instance of an SSH connection.
"""
self.ssh_connection = ssh_connection
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:
hostname (str): The name of the host
name (str): name of instance (e.g., "phc1")
service_name (str): service name (e.g., "phc2sys@phc1.service")
Returns: None
Returns:
None: This method does not return anything.
Raises:
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:
"""
verify systemctl service status and instance parameters on hostname
Verify systemctl service status and instance parameters on hostname
Args:
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:
"""
Verifies that the given PTP service is in the expected systemctl status and
that its most recent state change occurred within the given threshold.
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.
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:
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])
self.ptp_interfaces = ptp_interfaces
def __str__(self):
def __str__(self) -> str:
"""
String representation of this object.
Returns:
str: String representation of this object.
"""
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.
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:
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])
self.ptp_interfaces = ptp_interfaces
def __str__(self):
def __str__(self) -> str:
"""
String representation of this object.
Returns:
str: String representation of this object.
"""
return self.get_name()

View File

@@ -13,6 +13,11 @@ class PTPHostInterfaceSetup:
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.")
@@ -34,13 +39,12 @@ class PTPHostInterfaceSetup:
if "compute_0_interfaces" in setup_dict:
self.compute_0_interfaces = setup_dict.get("compute_0_interfaces")
def __str__(self):
def __str__(self) -> str:
"""
String representation of this object.
Returns:
str: String representation of this object.
"""
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.
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:
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])
self.ptp_interfaces = ptp_interfaces
def __str__(self):
def __str__(self) -> str:
"""
String representation of this object.
Returns:
str: String representation of this object.
"""
return self.get_name()

View File

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

View File

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

View File

@@ -1,26 +1,49 @@
class ProductVersion:
"""
This class models a ProductVersion as an object.
ProductVersions have names and can also be compared chronologically.
"""
def __init__(self, version_name: str, version_id: int):
"""
Constructor
Args:
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
"""
self.version_name = version_name
self.version_id = version_id
def __str__(self) -> str:
"""
Returns the string representation of the product version.
Returns:
str: The 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)
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)
def get_name(self) -> str:
@@ -28,7 +51,7 @@ class ProductVersion:
Getter for the name of this version
Returns:
str: The name of the version
"""
return self.version_name
@@ -37,27 +60,30 @@ class ProductVersion:
Getter for the id of this version
Returns:
int: The id of the version
"""
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.
Args:
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
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.
Args:
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

View File

@@ -7,12 +7,13 @@ class String:
def is_empty(some_string: str) -> bool:
"""
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.
Args:
some_string: the string to be checked.
some_string (str): the string to be checked.
Returns:
bool: True if 'some_string' is empty, False otherwise.
"""
return not some_string or some_string.strip() == ""

View File

@@ -4,27 +4,29 @@ class TypeConverter:
"""
@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_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.
Args:
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>.
If not provided, the default value is '='.
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 = {}
clean_string = string.replace('{', '').replace('}', '').replace('\'', '')
pairs = clean_string.split(',')
clean_string = string.replace("{", "").replace("}", "").replace("'", "")
pairs = clean_string.split(",")
for pair in pairs:
key, value = pair.split(separator_char)
@@ -43,6 +45,8 @@ class TypeConverter:
@staticmethod
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
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']"
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 == "[]":
return []
@@ -62,7 +64,7 @@ class TypeConverter:
if not cleaned_str:
return []
items = [item.strip().strip("'\"") for item in cleaned_str.split(',')]
items = [item.strip().strip("'\"") for item in cleaned_str.split(",")]
return items
@@ -72,11 +74,13 @@ class TypeConverter:
This function verifies if <string> represents an integer number.
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:
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):
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.
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:
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):
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
def is_number(string: str) -> bool:
@@ -106,11 +112,10 @@ class TypeConverter:
This function verifies if <string> represents an integer or float point number.
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:
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)
@@ -120,11 +125,13 @@ class TypeConverter:
This function verifies if <string> represents a boolean value.
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:
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):
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:
"""
Powers on the given host and waits for the host to be in a good state
Args:
host_name (): the name of the host
host_name (str): the name of the host
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()
if not self.is_powered_on(host_name):
host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name)
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()}"
)
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()}")
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
Args:
host_name (): the name of the host
power_on_wait_timeout (): the time to wait for the host to be powered on
host_name (str): the name of the host
power_on_wait_timeout (int): the time to wait for the host to be powered on
Returns:
bool: True if the host is powered on, healthy and has no failure alarms ; False otherwise
"""
timeout = time.time() + power_on_wait_timeout
refresh_time = 5
@@ -59,7 +59,7 @@ class PowerKeywords(BaseKeyword):
try:
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.")
is_power_on = True
@@ -71,7 +71,7 @@ class PowerKeywords(BaseKeyword):
alarms = AlarmListKeywords(self.ssh_connection).alarm_list()
is_alarms_list_ok = True
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
if is_alarms_list_ok:
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:
"""
Powers off the host
Args:
host_name (): the name of the host
host_name (str): the name of the host
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()
if not self.is_powered_off(host_name):
host_value = SystemHostListKeywords(self.ssh_connection).get_system_host_list().get_host(host_name)
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()}"
)
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()}")
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
Args:
host_name (): the name of the host
host_name (str): the name of the host
Returns:
bool: True if host powered off and host operations are disabled; False otherwise
"""
timeout = time.time() + 600
is_power_off = False
@@ -123,12 +123,12 @@ class PowerKeywords(BaseKeyword):
while time.time() < timeout:
try:
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.")
is_power_off = True
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
if is_power_off and is_host_list_ok: