Merge "pylint fix 01"

This commit is contained in:
Zuul
2025-07-30 16:25:41 +00:00
committed by Gerrit Code Review
29 changed files with 793 additions and 910 deletions

View File

@@ -12,31 +12,35 @@ class InterfaceObject:
def get_interface_name(self) -> str: def get_interface_name(self) -> str:
""" """
Getter for interface name Getter for interface name
Returns:
Returns:
str: the interface name value
""" """
return self.interface_name return self.interface_name
def get_mtu(self) -> str: def get_mtu(self) -> str:
""" """
Getter for mtu name Getter for mtu name
Returns:
Returns:
str: the mtu name value
""" """
return self.mtu return self.mtu
def get_state(self) -> str: def get_state(self) -> str:
""" """
Getter for state Getter for state
Returns:
Returns:
str: the state value
""" """
return self.state return self.state
def get_mode(self) -> str: def get_mode(self) -> str:
""" """
Getter for mode Getter for mode
Returns:
Returns:
str: the mode value
""" """
return self.mode return self.mode

View File

@@ -11,21 +11,22 @@ class IPBrAddrOutput:
def __init__(self, ip_br_addr_output: str): def __init__(self, ip_br_addr_output: str):
""" """
Constructor Constructor
Args: Args:
ip_br_addr_output: a string representing the output of the command 'ip -br addr'. ip_br_addr_output (str): a string representing the output of the command 'ip -br addr'.
""" """
self.ip_br_addr_objects: [IPBrAddrObject] = [] self.ip_br_addr_objects: list[IPBrAddrObject] = []
ip_br_addr_parser = IPBrAddrParser(ip_br_addr_output) ip_br_addr_parser = IPBrAddrParser(ip_br_addr_output)
output_values = ip_br_addr_parser.get_output_values_list() output_values = ip_br_addr_parser.get_output_values_list()
for value in output_values: for value in output_values:
ip_br_addr_object = IPBrAddrObject() ip_br_addr_object = IPBrAddrObject()
ip_br_addr_object.set_network_interface_name(value.get('network_interface_name')) ip_br_addr_object.set_network_interface_name(value.get("network_interface_name"))
ip_br_addr_object.set_network_interface_status(value.get('network_interface_status')) ip_br_addr_object.set_network_interface_status(value.get("network_interface_status"))
# The column 'ip_addresses' of the output of the command 'ip -br addr' can have zero or many IP addresses. # The column 'ip_addresses' of the output of the command 'ip -br addr' can have zero or many IP addresses.
if value.get('ip_addresses') is not None: if value.get("ip_addresses") is not None:
for ip in value['ip_addresses']: for ip in value["ip_addresses"]:
ip_object = IPObject(ip) ip_object = IPObject(ip)
ip_br_addr_object.get_ip_objects().append(ip_object) ip_br_addr_object.get_ip_objects().append(ip_object)
@@ -33,10 +34,7 @@ class IPBrAddrOutput:
def get_ip_br_addr_objects(self) -> list[IPBrAddrObject]: def get_ip_br_addr_objects(self) -> list[IPBrAddrObject]:
""" """
Getter for the list of instances of IPBrAddrObject. Each item of this list is an object the represents a row in Getter for the list of instances of IPBrAddrObject. Each item of this list is an object the represents a row in the table shown by the execution of the command 'ip -br addr'.
the table shown by the execution of the command 'ip -br addr'.
Args: None.
Returns: Returns:
list[IPBrAddrObject]: list of instances of IPBrAddrObject where each item represents a row in list[IPBrAddrObject]: list of instances of IPBrAddrObject where each item represents a row in

View File

@@ -15,22 +15,22 @@ class IPLinkShowOutput:
def get_interface(self) -> InterfaceObject: def get_interface(self) -> InterfaceObject:
""" """
Getter for interface Getter for interface
Returns: Returns:
InterfaceObject: Parsed interface data.
""" """
# Regex is designed for an output of the shape: # Regex is designed for an output of the shape:
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 # 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
# This regex will extract the interface name, mode, mtu and state # This regex will extract the interface name, mode, mtu and state
regex = r'\d+:\s+(?P<interface_name>\S+):\s+<(?P<mode>\S+)>' r'\s+mtu\s+(?P<mtu>\d+)[\s\S]+state\s+(?P<state>\w+)' regex = r"\d+:\s+(?P<interface_name>\S+):\s+<(?P<mode>\S+)>" r"\s+mtu\s+(?P<mtu>\d+)[\s\S]+state\s+(?P<state>\w+)"
match = re.match(regex, self.ip_link_show_output[0]) match = re.match(regex, self.ip_link_show_output[0])
if match: if match:
interface_name = match.group('interface_name') interface_name = match.group("interface_name")
modes = match.group('mode') modes = match.group("mode")
mtu = match.group('mtu') mtu = match.group("mtu")
state = match.group('state') state = match.group("state")
modes, modes,
self.interface_object = InterfaceObject(interface_name, mtu, state, modes) self.interface_object = InterfaceObject(interface_name, mtu, state, modes)

View File

@@ -7,13 +7,13 @@ class IPObject:
Class that represents an IP address, including the IP itself and its prefix length (subnet network). Class that represents an IP address, including the IP itself and its prefix length (subnet network).
""" """
def __init__(self, ip_with_prefix): def __init__(self, ip_with_prefix: str):
"""
Constructor.
Args:
ip_with_prefix: An IP address, either version 4 or 6, followed or not by /<prefix length>.
""" """
Constructor
Args:
ip_with_prefix (str): An IP address, either version 4 or 6, followed or not by /<prefix length>.
"""
# Gets the IP from an IP with prefix length. Example: gets '192.168.1.1' from '192.168.1.1/24'. # Gets the IP from an IP with prefix length. Example: gets '192.168.1.1' from '192.168.1.1/24'.
self.ip_address = IPObject._extract_ip_address(ip_with_prefix) self.ip_address = IPObject._extract_ip_address(ip_with_prefix)
@@ -21,22 +21,23 @@ class IPObject:
self.prefix_length = IPObject._extract_prefix_length(ip_with_prefix) self.prefix_length = IPObject._extract_prefix_length(ip_with_prefix)
if not ipaddress.ip_address(self.ip_address): if not ipaddress.ip_address(self.ip_address):
raise ValueError(f'The argument {ip_with_prefix} must be a valid IPv4 or IPv6 address.') raise ValueError(f"The argument {ip_with_prefix} must be a valid IPv4 or IPv6 address.")
def set_ip_address(self, ip_address: str): def set_ip_address(self, ip_address: str) -> None:
""" """
Setter for ip_address property. Setter for ip_address property
Args: Args:
ip_address (str): a string representing an IPv4 or IPv6 address either with prefix length or without prefix length. ip_address (str): a string representing an IPv4 or IPv6 address either with prefix length or without prefix length, the prefix length will be discarded if present.
The prefix length will be discarded if present.
""" """
if ipaddress.ip_address(ip_address): if ipaddress.ip_address(ip_address):
raise ValueError(f'The argument {ip_address} must be a valid IPv4 or IPv6 address.') raise ValueError(f"The argument {ip_address} must be a valid IPv4 or IPv6 address.")
self.ip_address = IPObject._extract_ip_address(ip_address) self.ip_address = IPObject._extract_ip_address(ip_address)
def get_ip_address(self) -> str: def get_ip_address(self) -> str:
""" """
Getter for ip_address property. Getter for ip_address property
Returns: Returns:
str: ip_address str: ip_address
""" """
@@ -44,15 +45,19 @@ class IPObject:
def set_prefix_length(self, prefix_length: int): def set_prefix_length(self, prefix_length: int):
""" """
Setter for prefix_length property. Setter for prefix_length property
Args: Args:
prefix_length (int): an prefix length number. prefix_length (int): an prefix length number.
""" """
self.prefix_length = prefix_length self.prefix_length = prefix_length
def get_prefix_length(self): def get_prefix_length(self) -> int:
""" """
Getter for prefix length property. Getter for prefix length property
Returns:
int: prefix length number
""" """
return self.prefix_length return self.prefix_length
@@ -60,29 +65,32 @@ class IPObject:
def _extract_ip_address(ip_address_with_prefix: str) -> str: def _extract_ip_address(ip_address_with_prefix: str) -> str:
""" """
Extracts the IP address from an IP with prefix length. Extracts the IP address from an IP with prefix length.
Example: gets '192.168.1.1' from '192.168.1.1/24'. Example: gets '192.168.1.1' from '192.168.1.1/24'.
Args: Args:
ip_address_with_prefix: an IP address with prefix length. ip_address_with_prefix (str): an IP address with prefix length.
Returns: Returns:
str: an ip_address without prefix length. str: an ip_address without prefix length.
""" """
return re.sub(r'/\d+', '', ip_address_with_prefix) return re.sub(r"/\d+", "", ip_address_with_prefix)
@staticmethod @staticmethod
def _extract_prefix_length(ip_address_with_prefix: str) -> int: def _extract_prefix_length(ip_address_with_prefix: str) -> int:
""" """
Extracts the prefix length from an IP with prefix length. Extracts the prefix length from an IP with prefix length.
Example: gets 24 from '192.168.1.1/24'. Example: gets 24 from '192.168.1.1/24'.
Args: Args:
ip_address_with_prefix: ip_address_with_prefix (str): an IP address with prefix length.
Returns: Returns:
int: the prefix_length of the IP passed as argument. int: the prefix_length of the IP passed as argument.
""" """
prefix_length = 0 prefix_length = 0
match = re.search(r'/(\d+)', ip_address_with_prefix) match = re.search(r"/(\d+)", ip_address_with_prefix)
if match: if match:
prefix_length = int(match.group(1)) prefix_length = int(match.group(1))
return prefix_length return prefix_length

View File

@@ -17,9 +17,10 @@ class KeyringKeywords(BaseKeyword):
Args: Args:
service (str): keyring service service (str): keyring service
identifier (str): keyring identifier identifier (str): keyring identifier
Returns: Returns:
The value from the keyring. str: The value from the keyring.
""" """
keyring_value = self.ssh_connection.send(f"keyring get {service} {identifier}") keyring_value = self.ssh_connection.send(f"keyring get {service} {identifier}")
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
return keyring_value[0].strip() return keyring_value[0].strip()

View File

@@ -1,3 +1,4 @@
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
@@ -6,25 +7,27 @@ class ProcessStatusArgsKeywords(BaseKeyword):
Class for "ps -o args" keywords Class for "ps -o args" keywords
""" """
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def get_process_arguments_as_string(self, process_name) -> str: def get_process_arguments_as_string(self, process_name: str) -> str:
""" """
This function will return the command line arguments associated with the specified process. This function will return the command line arguments associated with the specified process.
Args: Args:
process_name: The name of the process for which we want to get the command line arguments. process_name (str): The name of the process for which we want to get the command line arguments.
Returns: A string containing the process name with all command line arguments. Returns:
str: A string containing the process name with all command line arguments.
""" """
output = self.ssh_connection.send(f'ps -C {process_name} -o args= | cat') output = self.ssh_connection.send(f"ps -C {process_name} -o args= | cat")
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
# output is a list with one value # output is a list with one value

View File

@@ -1,3 +1,4 @@
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
@@ -6,24 +7,26 @@ class SystemCTLIsActiveKeywords(BaseKeyword):
Class for "systemctl is-active" keywords Class for "systemctl is-active" keywords
""" """
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def is_active(self, service_name) -> str: def is_active(self, service_name: str) -> str:
""" """
Checks if the service is active using "systemctl is-active <service_name>" Checks if the service is active using "systemctl is-active <service_name>"
Args: Args:
service_name: The name of the service service_name (str): The name of the service
Returns: 'active' or 'inactive'
Returns:
str: 'active' or 'inactive'
""" """
output = self.ssh_connection.send(f'systemctl is-active {service_name}') output = self.ssh_connection.send(f"systemctl is-active {service_name}")
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
# output is a List of 1 string. "active/n" # output is a List of 1 string. "active/n"

View File

@@ -1,12 +1,15 @@
from typing import Any, Dict
from framework.exceptions.keyword_exception import KeywordException from framework.exceptions.keyword_exception import KeywordException
from framework.logging.automation_logger import get_logger from framework.logging.automation_logger import get_logger
from keywords.openstack.openstack.stack.object.openstack_stack_list_object import OpenstackStackListObject
from keywords.openstack.openstack.openstack_json_parser import OpenstackJsonParser from keywords.openstack.openstack.openstack_json_parser import OpenstackJsonParser
from keywords.openstack.openstack.stack.object.openstack_stack_list_object import OpenstackStackListObject
class OpenstackStackListOutput: class OpenstackStackListOutput:
""" """
This class parses the output of the command 'openstack stack list' This class parses the output of the command 'openstack stack list'
The parsing result is a 'OpenstackStackListObject' instance. The parsing result is a 'OpenstackStackListObject' instance.
Example: Example:
@@ -19,13 +22,14 @@ class OpenstackStackListOutput:
""" """
def __init__(self, openstack_stack_list_output): def __init__(self, openstack_stack_list_output: list[str]):
""" """
Constructor Constructor for OpenstackStackListOutput class.
Args: Args:
openstack_stack_list_output: the output of the command 'openstack stack list'. openstack_stack_list_output (list[str]): the output of the command 'openstack stack list'.
""" """
self.openstack_stacks: [OpenstackStackListObject] = [] self.openstack_stacks: list[OpenstackStackListObject] = []
openstack_json_parser = OpenstackJsonParser(openstack_stack_list_output) openstack_json_parser = OpenstackJsonParser(openstack_stack_list_output)
output_values = openstack_json_parser.get_output_values_list() output_values = openstack_json_parser.get_output_values_list()
@@ -33,33 +37,38 @@ class OpenstackStackListOutput:
if self.is_valid_output(value): if self.is_valid_output(value):
self.openstack_stacks.append( self.openstack_stacks.append(
OpenstackStackListObject( OpenstackStackListObject(
value['ID'], value["ID"],
value['Stack Name'], value["Stack Name"],
value['Project'], value["Project"],
value['Stack Status'], value["Stack Status"],
value['Creation Time'], value["Creation Time"],
value['Updated Time'], value["Updated Time"],
) )
) )
else: else:
raise KeywordException(f"The output line {value} was not valid") raise KeywordException(f"The output line {value} was not valid")
def get_stacks(self) -> [OpenstackStackListObject]: def get_stacks(self) -> list[OpenstackStackListObject]:
""" """
Returns the list of stack objects Returns the list of stack objects
Returns:
Returns:
list[OpenstackStackListObject]: a list of OpenstackStackListObject instances representing the stacks
""" """
return self.openstack_stacks return self.openstack_stacks
def get_stack(self, stack_name: str) -> OpenstackStackListObject: def get_stack(self, stack_name: str) -> OpenstackStackListObject:
""" """
Gets the given stack Gets the given stack
Args: Args:
stack_name (): the name of the stack stack_name (str): the name of the stack
Returns: the stack object Returns:
OpenstackStackListObject: the OpenstackStackListObject instance representing the stack with the name 'stack_name'
Raises:
KeywordException: if no stack with the name 'stack_name' was found.
""" """
stacks = list(filter(lambda stack: stack.get_stack_name() == stack_name, self.openstack_stacks)) stacks = list(filter(lambda stack: stack.get_stack_name() == stack_name, self.openstack_stacks))
if len(stacks) == 0: if len(stacks) == 0:
@@ -68,30 +77,31 @@ class OpenstackStackListOutput:
return stacks[0] return stacks[0]
@staticmethod @staticmethod
def is_valid_output(value): def is_valid_output(value: Dict[str, Any]) -> bool:
""" """
Checks to ensure the output has the correct keys Checks to ensure the output has the correct keys
Args: Args:
value (): the value to check value (Dict[str, Any]): a dictionary representing a single row of the output
Returns: Returns:
bool: True if the output has the required keys; False otherwise
""" """
valid = True valid = True
if 'ID' not in value: if "ID" not in value:
get_logger().log_error(f'id is not in the output value: {value}') get_logger().log_error(f"id is not in the output value: {value}")
valid = False valid = False
if 'Stack Name' not in value: if "Stack Name" not in value:
get_logger().log_error(f'stack name is not in the output value: {value}') get_logger().log_error(f"stack name is not in the output value: {value}")
valid = False valid = False
if 'Project' not in value: if "Project" not in value:
get_logger().log_error(f'project is not in the output value: {value}') get_logger().log_error(f"project is not in the output value: {value}")
valid = False valid = False
if 'Stack Status' not in value: if "Stack Status" not in value:
get_logger().log_error(f'stack status is not in the output value: {value}') get_logger().log_error(f"stack status is not in the output value: {value}")
valid = False valid = False
if 'Creation Time' not in value: if "Creation Time" not in value:
get_logger().log_error(f'creation time is not in the output value: {value}') get_logger().log_error(f"creation time is not in the output value: {value}")
valid = False valid = False
return valid return valid

View File

@@ -1,10 +1,11 @@
from keywords.openstack.openstack.stack.object.openstack_stack_object import OpenstackStackObject
from keywords.openstack.openstack.openstack_json_parser import OpenstackJsonParser from keywords.openstack.openstack.openstack_json_parser import OpenstackJsonParser
from keywords.openstack.openstack.stack.object.openstack_stack_object import OpenstackStackObject
class OpenstackStackOutput: class OpenstackStackOutput:
""" """
This class parses the output of commands such as 'openstack stack create' This class parses the output of commands such as 'openstack stack create' that share the same output as shown in the example below.
that share the same output as shown in the example below.
The parsing result is a 'openstackStackObject' instance. The parsing result is a 'openstackStackObject' instance.
Example: Example:
@@ -20,47 +21,44 @@ class OpenstackStackOutput:
} }
""" """
def __init__(self, openstack_stack_output): def __init__(self, openstack_stack_output: list[str]):
""" """
Constructor. Create an internal OpenstackStackCreateObject from the passed parameter.
Create an internal OpenstackStackCreateObject from the passed parameter.
Args:
openstack_stack_output (list[str]): a list of strings representing the output of the
'openstack stack create' command.
Args:
openstack_stack_output (list[str]): a list of strings representing the output of the 'openstack stack create' command.
""" """
openstack_json_parser = OpenstackJsonParser(openstack_stack_output) openstack_json_parser = OpenstackJsonParser(openstack_stack_output)
output_values = openstack_json_parser.get_output_values_list() output_values = openstack_json_parser.get_output_values_list()
self.openstack_stack_object = OpenstackStackObject() self.openstack_stack_object = OpenstackStackObject()
if 'id' in output_values: if "id" in output_values:
self.openstack_stack_object.set_id(output_values['id']) self.openstack_stack_object.set_id(output_values["id"])
if 'stack_name' in output_values: if "stack_name" in output_values:
self.openstack_stack_object.set_stack_name(output_values['stack_name']) self.openstack_stack_object.set_stack_name(output_values["stack_name"])
if 'description' in output_values: if "description" in output_values:
self.openstack_stack_object.set_description(output_values['description']) self.openstack_stack_object.set_description(output_values["description"])
if 'creation_time' in output_values: if "creation_time" in output_values:
self.openstack_stack_object.set_creation_time(output_values['creation_time']) self.openstack_stack_object.set_creation_time(output_values["creation_time"])
if 'updated_time' in output_values: if "updated_time" in output_values:
self.openstack_stack_object.set_updated_time(output_values['updated_time']) self.openstack_stack_object.set_updated_time(output_values["updated_time"])
if 'stack_status' in output_values: if "stack_status" in output_values:
self.openstack_stack_object.set_stack_status(output_values['stack_status']) self.openstack_stack_object.set_stack_status(output_values["stack_status"])
if 'stack_status_reason' in output_values: if "stack_status_reason" in output_values:
self.openstack_stack_object.set_stack_status_reason(output_values['stack_status_reason']) self.openstack_stack_object.set_stack_status_reason(output_values["stack_status_reason"])
def get_openstack_stack_object(self) -> OpenstackStackObject: def get_openstack_stack_object(self) -> OpenstackStackObject:
""" """
Getter for OpenstackStackObject object. Getter for OpenstackStackObject object.
Returns: Returns:
A OpenstackStackObject instance representing the output of commands sucha as 'openstack stack create'. OpenstackStackObject: the openstack_stack_object
""" """
return self.openstack_stack_object return self.openstack_stack_object

View File

@@ -1,76 +1,69 @@
from framework.logging.automation_logger import get_logger from framework.logging.automation_logger import get_logger
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
from keywords.openstack.command_wrappers import source_admin_openrc from keywords.openstack.command_wrappers import source_admin_openrc
from keywords.openstack.openstack.stack.object.openstack_stack_create_input import OpenstackStackCreateInput from keywords.openstack.openstack.stack.object.openstack_stack_create_input import OpenstackStackCreateInput
from keywords.openstack.openstack.stack.openstack_stack_list_keywords import OpenstackStackListKeywords
from keywords.openstack.openstack.stack.object.openstack_stack_output import OpenstackStackOutput from keywords.openstack.openstack.stack.object.openstack_stack_output import OpenstackStackOutput
from keywords.openstack.openstack.stack.object.openstack_stack_status_enum import OpenstackStackStatusEnum from keywords.openstack.openstack.stack.object.openstack_stack_status_enum import OpenstackStackStatusEnum
from keywords.openstack.openstack.stack.openstack_stack_list_keywords import OpenstackStackListKeywords
from keywords.python.string import String from keywords.python.string import String
class OpenstackStackCreateKeywords(BaseKeyword): class OpenstackStackCreateKeywords(BaseKeyword):
""" """Class for Openstack Stack Create Keywords"""
Class for Openstack Stack Create
"""
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor for OpenstackStackCreateKeywords class.
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def openstack_stack_create(self, openstack_stack_create_input: OpenstackStackCreateInput) -> OpenstackStackOutput: def openstack_stack_create(self, openstack_stack_create_input: OpenstackStackCreateInput) -> OpenstackStackOutput:
""" """
Openstack stack create function, creates a given stack Openstack stack create function, creates a given stack
Args: Args:
openstack_stack_create_input (OpenstackStackCreateInput): an object with the required parameters openstack_stack_create_input (OpenstackStackCreateInput): an object with the required parameters
Returns: Returns:
openstack_stack_output: An object with the openstack stack create output OpenstackStackOutput: the output of the openstack stack create command
""" """
# Gets the command 'openstack stack create' with its parameters configured. # Gets the command 'openstack stack create' with its parameters configured.
cmd = self.get_command(openstack_stack_create_input) cmd = self.get_command(openstack_stack_create_input)
stack_name = openstack_stack_create_input.get_stack_name() stack_name = openstack_stack_create_input.get_stack_name()
# Executes the command 'openstack stack create'. # Executes the command 'openstack stack create'.
output = self.ssh_connection.send(source_admin_openrc(cmd),get_pty=True) output = self.ssh_connection.send(source_admin_openrc(cmd), get_pty=True)
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
openstack_stack_output = OpenstackStackOutput(output) openstack_stack_output = OpenstackStackOutput(output)
# Tracks the execution of the command 'openstack stack create' until its completion or a timeout. # Tracks the execution of the command 'openstack stack create' until its completion or a timeout.
openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection) openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection)
openstack_stack_list_keywords.validate_stack_status(stack_name, 'CREATE_COMPLETE') openstack_stack_list_keywords.validate_stack_status(stack_name, "CREATE_COMPLETE")
# If the execution arrived here the status of the stack is 'created'. # If the execution arrived here the status of the stack is 'created'.
openstack_stack_output.get_openstack_stack_object().set_stack_status('create_complete') openstack_stack_output.get_openstack_stack_object().set_stack_status("create_complete")
return openstack_stack_output return openstack_stack_output
def is_already_created(self, stack_name: str) -> bool: def is_already_created(self, stack_name: str) -> bool:
""" """
Verifies if the stack has already been created. Verifies if the stack has already been created.
Args: Args:
stack_name (str): a string representing the name of the stack. stack_name (str): a string representing the name of the stack.
Returns: Returns:
bool: True if the stack named 'stack_name' has already been created; False otherwise. bool: True if the stack named 'stack_name' has already been created; False otherwise.
""" """
try: try:
openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection) openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection)
if openstack_stack_list_keywords.get_openstack_stack_list().is_in_stack_list(stack_name): if openstack_stack_list_keywords.get_openstack_stack_list().is_in_stack_list(stack_name):
stack = OpenstackStackListKeywords(self.ssh_connection).get_openstack_stack_list().get_stack(stack_name) stack = OpenstackStackListKeywords(self.ssh_connection).get_openstack_stack_list().get_stack(stack_name)
return ( return stack.get_stack_status() == OpenstackStackStatusEnum.CREATE_IN_PROGRESS.value or stack.get_stack_status() == OpenstackStackStatusEnum.CREATE_COMPLETE.value or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_IN_PROGRESS.value or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_COMPLETE.value or stack.get_stack_status() == OpenstackStackStatusEnum.ROLLBACK_IN_PROGRESS.value or stack.get_stack_status() == OpenstackStackStatusEnum.ROLLBACK_COMPLETE.value
stack.get_stack_status() == OpenstackStackStatusEnum.CREATE_IN_PROGRESS.value
or stack.get_stack_status() == OpenstackStackStatusEnum.CREATE_COMPLETE.value
or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_IN_PROGRESS.value
or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_COMPLETE.value
or stack.get_stack_status() == OpenstackStackStatusEnum.ROLLBACK_IN_PROGRESS.value
or stack.get_stack_status() == OpenstackStackStatusEnum.ROLLBACK_COMPLETE.value
)
return False return False
except Exception as ex: except Exception as ex:
get_logger().log_exception(f"An error occurred while verifying whether the application named {stack_name} is already created.") get_logger().log_exception(f"An error occurred while verifying whether the application named {stack_name} is already created.")
@@ -78,18 +71,14 @@ class OpenstackStackCreateKeywords(BaseKeyword):
def get_command(self, openstack_stack_create_input: OpenstackStackCreateInput) -> str: def get_command(self, openstack_stack_create_input: OpenstackStackCreateInput) -> str:
""" """
Generates a string representing the 'openstack stack create' command with parameters based on the values in Generates the 'openstack stack create' command using values from the given input object.
the 'openstack_stack_create_input' argument.
Args: Args:
openstack_stack_create_input (OpenstackStackCreateInput): an instance of OpenstackStackCreateInput openstack_stack_create_input (OpenstackStackCreateInput): Input parameters for the create command
configured with the parameters needed to execute the 'openstack stack create' command properly.
Returns: Returns:
str: a string representing the 'openstack stack create' command, configured according to the parameters str: a string representing the 'openstack stack create' command, configured according to the parameters in the 'openstack_stack_create_input' argument.
in the 'openstack_stack_create_input' argument.
""" """
# 'template_file_path' and 'template_file_name' properties are required # 'template_file_path' and 'template_file_name' properties are required
template_file_path = openstack_stack_create_input.get_template_file_path() template_file_path = openstack_stack_create_input.get_template_file_path()
template_file_name = openstack_stack_create_input.get_template_file_name() template_file_name = openstack_stack_create_input.get_template_file_name()
@@ -97,9 +86,7 @@ class OpenstackStackCreateKeywords(BaseKeyword):
error_message = "Template path and name must be specified" error_message = "Template path and name must be specified"
get_logger().log_exception(error_message) get_logger().log_exception(error_message)
raise ValueError(error_message) raise ValueError(error_message)
template_file_path_as_param = ( template_file_path_as_param = f"--template={openstack_stack_create_input.get_template_file_path()}/{openstack_stack_create_input.get_template_file_name()}"
f'--template={openstack_stack_create_input.get_template_file_path()}/{openstack_stack_create_input.get_template_file_name()}'
)
# 'stack_name' is required # 'stack_name' is required
stack_name = openstack_stack_create_input.get_stack_name() stack_name = openstack_stack_create_input.get_stack_name()
@@ -107,11 +94,11 @@ class OpenstackStackCreateKeywords(BaseKeyword):
error_message = "Stack name is required" error_message = "Stack name is required"
get_logger().log_exception(error_message) get_logger().log_exception(error_message)
raise ValueError(error_message) raise ValueError(error_message)
# 'return_format' property is optional. # 'return_format' property is optional.
return_format_as_param = f'-f {openstack_stack_create_input.get_return_format()}' return_format_as_param = f"-f {openstack_stack_create_input.get_return_format()}"
# Assembles the command. # Assembles the command.
cmd = f'openstack stack create {return_format_as_param} {template_file_path_as_param} {stack_name}' cmd = f"openstack stack create {return_format_as_param} {template_file_path_as_param} {stack_name}"
return cmd return cmd

View File

@@ -1,24 +1,25 @@
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
from keywords.openstack.command_wrappers import source_admin_openrc from keywords.openstack.command_wrappers import source_admin_openrc
from keywords.openstack.openstack.stack.object.openstack_stack_delete_input import OpenstackStackDeleteInput from keywords.openstack.openstack.stack.object.openstack_stack_delete_input import OpenstackStackDeleteInput
class OpenstackStackDeleteKeywords(BaseKeyword): class OpenstackStackDeleteKeywords(BaseKeyword):
""" """Class for Openstack stack delete keywords"""
Class for Openstack stack delete keywords
"""
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor for OpenstackStackDeleteKeywords class
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def get_openstack_stack_delete(self, openstack_stack_delete_input: OpenstackStackDeleteInput) -> str: def get_openstack_stack_delete(self, openstack_stack_delete_input: OpenstackStackDeleteInput) -> str:
""" """
Delete a stack specified in the parameter 'openstack_stack_delete_input'. Delete a stack specified in the parameter 'openstack_stack_delete_input'.
Args: Args:
openstack_stack_delete_input (OpenstackStackDeleteInput): defines the stack name openstack_stack_delete_input (OpenstackStackDeleteInput): defines the stack name
@@ -28,23 +29,20 @@ class OpenstackStackDeleteKeywords(BaseKeyword):
'Stack-delete rejected: stack not found.\n' 'Stack-delete rejected: stack not found.\n'
""" """
cmd = self.get_command(openstack_stack_delete_input) cmd = self.get_command(openstack_stack_delete_input)
output = self.ssh_connection.send(source_admin_openrc(cmd),get_pty=True) output = self.ssh_connection.send(source_admin_openrc(cmd), get_pty=True)
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
return output[0] return output[0]
def get_command(self, openstack_stack_delete_input: OpenstackStackDeleteInput) -> str: def get_command(self, openstack_stack_delete_input: OpenstackStackDeleteInput) -> str:
""" """
Generates a string representing the 'openstack stack delete' command with parameters based on the values in Generates the 'openstack stack delete' command using values from the given input object.
the 'openstack_stack_delete_input' argument.
Args: Args:
openstack_stack_delete_input (OpenstackStackDeleteInput): an instance of OpenstackStackDeleteInput openstack_stack_delete_input (OpenstackStackDeleteInput): Input parameters for the delete command
configured with the parameters needed to execute the 'openstack stack delete' command properly.
Returns: Returns:
str: a string representing the 'openstack stack delete' command, configured according to the parameters str: a string representing the 'openstack stack delete' command, configured according to the parameters in the 'openstack_stack_delete_input' argument.
in the 'openstack_stack_delete_input' argument.
""" """
cmd = f'openstack stack delete -y {openstack_stack_delete_input.get_stack_name()}' cmd = f"openstack stack delete -y {openstack_stack_delete_input.get_stack_name()}"
return cmd return cmd

View File

@@ -1,4 +1,4 @@
from framework.logging.automation_logger import get_logger from framework.ssh.ssh_connection import SSHConnection
from framework.validation.validation import validate_equals_with_retry from framework.validation.validation import validate_equals_with_retry
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
from keywords.openstack.command_wrappers import source_admin_openrc from keywords.openstack.command_wrappers import source_admin_openrc
@@ -6,15 +6,14 @@ from keywords.openstack.openstack.stack.object.openstack_stack_list_output impor
class OpenstackStackListKeywords(BaseKeyword): class OpenstackStackListKeywords(BaseKeyword):
""" """Class for Openstack stack list keywords"""
Class for Openstack stack list keywords.
"""
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor for OpenstackStackListKeywords class.
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
@@ -22,27 +21,23 @@ class OpenstackStackListKeywords(BaseKeyword):
""" """
Gets a OpenstackStackListOutput object related to the execution of the 'openstack stack list' command. Gets a OpenstackStackListOutput object related to the execution of the 'openstack stack list' command.
Args: None
Returns: Returns:
OpenstackStackListOutput: an instance of the OpenstackStackListOutput object representing the OpenstackStackListOutput: an instance of the OpenstackStackListOutput object representing the
heat stacks on the host, as a result of the execution of the 'openstack stack list' command. heat stacks on the host, as a result of the execution of the 'openstack stack list' command.
""" """
output = self.ssh_connection.send(source_admin_openrc('openstack stack list -f json'),get_pty=True) output = self.ssh_connection.send(source_admin_openrc("openstack stack list -f json"), get_pty=True)
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
openstack_stack_list_output = OpenstackStackListOutput(output) openstack_stack_list_output = OpenstackStackListOutput(output)
return openstack_stack_list_output return openstack_stack_list_output
def validate_stack_status(self, stack_name: str, status: str): def validate_stack_status(self, stack_name: str, status: str) -> None:
""" """
This function will validate that the stack specified reaches the desired status. This function will validate that the stack specified reaches the desired status.
Args: Args:
stack_name: Name of the stack that we are waiting for. stack_name (str): Name of the stack that we are waiting for.
status: Status in which we want to wait for the stack to reach. status (str): Status in which we want to wait for the stack to reach.
Returns: None
""" """
def get_stack_status(): def get_stack_status():
@@ -52,4 +47,3 @@ class OpenstackStackListKeywords(BaseKeyword):
message = f"Openstack stack {stack_name}'s status is {status}" message = f"Openstack stack {stack_name}'s status is {status}"
validate_equals_with_retry(get_stack_status, status, message, timeout=300) validate_equals_with_retry(get_stack_status, status, message, timeout=300)

View File

@@ -1,35 +1,35 @@
from framework.logging.automation_logger import get_logger from framework.logging.automation_logger import get_logger
from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword from keywords.base_keyword import BaseKeyword
from keywords.openstack.command_wrappers import source_admin_openrc from keywords.openstack.command_wrappers import source_admin_openrc
from keywords.openstack.openstack.stack.object.openstack_stack_update_input import OpenstackStackUpdateInput
from keywords.openstack.openstack.stack.openstack_stack_list_keywords import OpenstackStackListKeywords
from keywords.openstack.openstack.stack.object.openstack_stack_output import OpenstackStackOutput from keywords.openstack.openstack.stack.object.openstack_stack_output import OpenstackStackOutput
from keywords.openstack.openstack.stack.object.openstack_stack_status_enum import OpenstackStackStatusEnum from keywords.openstack.openstack.stack.object.openstack_stack_status_enum import OpenstackStackStatusEnum
from keywords.openstack.openstack.stack.object.openstack_stack_update_input import OpenstackStackUpdateInput
from keywords.openstack.openstack.stack.openstack_stack_list_keywords import OpenstackStackListKeywords
from keywords.python.string import String from keywords.python.string import String
class OpenstackStackUpdateKeywords(BaseKeyword): class OpenstackStackUpdateKeywords(BaseKeyword):
""" """Class for Openstack Stack Update Keywords"""
Class for Openstack Stack Update
"""
def __init__(self, ssh_connection): def __init__(self, ssh_connection: SSHConnection):
""" """
Constructor Constructor for OpenstackStackUpdateKeywords class.
Args: Args:
ssh_connection: ssh_connection (SSHConnection): SSH connection to the active controller
""" """
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def openstack_stack_update(self, openstack_stack_update_input: OpenstackStackUpdateInput) -> OpenstackStackOutput: def openstack_stack_update(self, openstack_stack_update_input: OpenstackStackUpdateInput) -> OpenstackStackOutput:
""" """
Openstack stack update function, updates a given existing stack Openstack stack update function, updates a given existing stack
Args: Args:
openstack_stack_update_input (OpenstackStackUpdateInput): an object with the required parameters openstack_stack_update_input (OpenstackStackUpdateInput): an object with the required parameters
Returns: Returns:
openstack_stack_output: An object with the openstack stack update output OpenstackStackOutput: the output of the openstack stack update command
""" """
# Gets the command 'openstack stack update' with its parameters configured. # Gets the command 'openstack stack update' with its parameters configured.
cmd = self.get_command(openstack_stack_update_input) cmd = self.get_command(openstack_stack_update_input)
@@ -42,46 +42,39 @@ class OpenstackStackUpdateKeywords(BaseKeyword):
# Tracks the execution of the command 'openstack stack update' until its completion or a timeout. # Tracks the execution of the command 'openstack stack update' until its completion or a timeout.
openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection) openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection)
openstack_stack_list_keywords.validate_stack_status(stack_name, 'UPDATE_COMPLETE') openstack_stack_list_keywords.validate_stack_status(stack_name, "UPDATE_COMPLETE")
# If the execution arrived here the status of the stack is 'updated'. # If the execution arrived here the status of the stack is 'updated'.
openstack_stack_output.get_openstack_stack_object().set_stack_status('update_complete') openstack_stack_output.get_openstack_stack_object().set_stack_status("update_complete")
return openstack_stack_output return openstack_stack_output
def is_already_updated(self, stack_name: str) -> bool: def is_already_updated(self, stack_name: str) -> bool:
""" """
Verifies if the stack has already been updated. Verifies if the stack has already been updated.
Args: Args:
stack_name (str): a string representing the name of the stack. stack_name (str): a string representing the name of the stack.
Returns: Returns:
bool: True if the stack named 'stack_name' has already been updated; False otherwise. bool: True if the stack named 'stack_name' has already been updated; False otherwise.
""" """
openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection) openstack_stack_list_keywords = OpenstackStackListKeywords(self.ssh_connection)
if openstack_stack_list_keywords.get_openstack_stack_list().is_in_stack_list(stack_name): if openstack_stack_list_keywords.get_openstack_stack_list().is_in_stack_list(stack_name):
stack = OpenstackStackListKeywords(self.ssh_connection).get_openstack_stack_list().get_stack(stack_name) stack = OpenstackStackListKeywords(self.ssh_connection).get_openstack_stack_list().get_stack(stack_name)
return ( return stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_IN_PROGRESS.value or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_COMPLETE.value
stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_IN_PROGRESS.value
or stack.get_stack_status() == OpenstackStackStatusEnum.UPDATE_COMPLETE.value
)
return False return False
def get_command(self, openstack_stack_update_input: OpenstackStackUpdateInput) -> str: def get_command(self, openstack_stack_update_input: OpenstackStackUpdateInput) -> str:
""" """
Generates a string representing the 'openstack stack update' command with parameters based on the values in Generates the 'openstack stack update' command using values from the given input object.
the 'openstack_stack_update_input' argument.
Args: Args:
openstack_stack_update_input (OpenstackStackUpdateInput): an instance of OpenstackStackUpdateInput openstack_stack_update_input (OpenstackStackUpdateInput): Input parameters for the update command
configured with the parameters needed to execute the 'openstack stack update' command properly.
Returns: Returns:
str: a string representing the 'openstack stack update' command, configured according to the parameters str: a string representing the 'openstack stack update' command, configured according to the parameters in the 'openstack_stack_update_input' argument.
in the 'openstack_stack_update_input' argument.
""" """
# 'template_file_path' and 'template_file_name' properties are required # 'template_file_path' and 'template_file_name' properties are required
template_file_path = openstack_stack_update_input.get_template_file_path() template_file_path = openstack_stack_update_input.get_template_file_path()
template_file_name = openstack_stack_update_input.get_template_file_name() template_file_name = openstack_stack_update_input.get_template_file_name()
@@ -89,9 +82,7 @@ class OpenstackStackUpdateKeywords(BaseKeyword):
error_message = "Template path and name must be specified" error_message = "Template path and name must be specified"
get_logger().log_exception(error_message) get_logger().log_exception(error_message)
raise ValueError(error_message) raise ValueError(error_message)
template_file_path_as_param = ( template_file_path_as_param = f"--template={openstack_stack_update_input.get_template_file_path()}/{openstack_stack_update_input.get_template_file_name()}"
f'--template={openstack_stack_update_input.get_template_file_path()}/{openstack_stack_update_input.get_template_file_name()}'
)
# 'stack_name' is required # 'stack_name' is required
stack_name = openstack_stack_update_input.get_stack_name() stack_name = openstack_stack_update_input.get_stack_name()
@@ -101,9 +92,9 @@ class OpenstackStackUpdateKeywords(BaseKeyword):
raise ValueError(error_message) raise ValueError(error_message)
# 'return_format' property is optional. # 'return_format' property is optional.
return_format_as_param = f'-f {openstack_stack_update_input.get_return_format()}' return_format_as_param = f"-f {openstack_stack_update_input.get_return_format()}"
# Assembles the command. # Assembles the command.
cmd = f'openstack stack update {return_format_as_param} {template_file_path_as_param} {stack_name}' cmd = f"openstack stack update {return_format_as_param} {template_file_path_as_param} {stack_name}"
return cmd return cmd

View File

@@ -9,6 +9,12 @@ class CatPtpCguKeywords(BaseKeyword):
""" """
def __init__(self, ssh_connection: SSHConnection): def __init__(self, ssh_connection: SSHConnection):
"""
Constructor for CatPtpCguKeywords class.
Args:
ssh_connection (SSHConnection): SSH connection to the active controller.
"""
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def cat_ptp_cgu(self, cgu_location: str) -> PtpCguComponentOutput: def cat_ptp_cgu(self, cgu_location: str) -> PtpCguComponentOutput:
@@ -19,8 +25,7 @@ class CatPtpCguKeywords(BaseKeyword):
cgu_location (str): the cgu location. cgu_location (str): the cgu location.
Returns: Returns:
PtpCguComponentOutput - the PtpCguComponentOutput. PtpCguComponentOutput: the output of the cat ptp cgu command
""" """
output = self.ssh_connection.send_as_sudo(f"cat {cgu_location}") output = self.ssh_connection.send_as_sudo(f"cat {cgu_location}")
cat_ptp_cgu_component_output = PtpCguComponentOutput(output) cat_ptp_cgu_component_output = PtpCguComponentOutput(output)

View File

@@ -4,24 +4,28 @@ from keywords.ptp.cat.objects.cat_ptp_config_output import CATPtpConfigOutput
class CatPtpConfigKeywords(BaseKeyword): class CatPtpConfigKeywords(BaseKeyword):
""" """Class for Cat Ptp Config Keywords"""
Class for Cat Ptp Config Keywords
"""
def __init__(self, ssh_connection: SSHConnection): def __init__(self, ssh_connection: SSHConnection):
"""
Constructor for CatPtpConfigKeywords class.
Args:
ssh_connection (SSHConnection): SSH connection to the active controller.
"""
self.ssh_connection = ssh_connection self.ssh_connection = ssh_connection
def cat_ptp_config(self, config_file: str) -> CATPtpConfigOutput: def cat_ptp_config(self, config_file: str) -> CATPtpConfigOutput:
""" """
Run cat cpt config command This command reads the contents of a PTP configuration file.
Args: Args:
config_file (): the ptp config file config_file (str): the ptp config file
Returns: CatPtpConfigOutput
Returns:
CATPtpConfigOutput: the output of the cat ptp config command
""" """
output = self.ssh_connection.send(f'cat {config_file}') output = self.ssh_connection.send(f"cat {config_file}")
self.validate_success_return_code(self.ssh_connection) self.validate_success_return_code(self.ssh_connection)
cat_ptp_config_output = CATPtpConfigOutput(output) cat_ptp_config_output = CATPtpConfigOutput(output)
return cat_ptp_config_output return cat_ptp_config_output

View File

@@ -4,104 +4,98 @@ class ClockDescriptionObject:
""" """
def __init__(self): def __init__(self):
self.product_description: str = '' self.product_description: str = ""
self.revision_data: str = '' self.revision_data: str = ""
self.manufacturer_identity: str = '' self.manufacturer_identity: str = ""
self.user_description: str = '' self.user_description: str = ""
self.time_source: str = '' self.time_source: str = ""
def get_product_description(self) -> str: def get_product_description(self) -> str:
""" """
Getter for product_description Getter for product_description
Returns: product_description
Returns:
str: the product_description value
""" """
return self.product_description return self.product_description
def set_product_description(self, product_description: str): def set_product_description(self, product_description: str) -> None:
""" """
Setter for product_description Setter for product_description
Args: Args:
product_description (): the product_description value product_description (str): the product_description value
Returns:
""" """
self.product_description = product_description self.product_description = product_description
def get_revision_data(self) -> str: def get_revision_data(self) -> str:
""" """
Getter for revision_data Getter for revision_data
Returns: revision_data value
Returns:
str: the revision_data value
""" """
return self.revision_data return self.revision_data
def set_revision_data(self, revision_data: str): def set_revision_data(self, revision_data: str) -> None:
""" """
Setter for revision_data Setter for revision_data
Args: Args:
revision_data (): revision_data value revision_data (str): revision_data value
Returns:
""" """
self.revision_data = revision_data self.revision_data = revision_data
def get_manufacturer_identity(self) -> str: def get_manufacturer_identity(self) -> str:
""" """
Getter for manufacturer_identity Getter for manufacturer_identity
Returns: manufacturer_identity value
Returns:
str: the manufacturer_identity value
""" """
return self.manufacturer_identity return self.manufacturer_identity
def set_manufacturer_identity(self, manufacturer_identity: str): def set_manufacturer_identity(self, manufacturer_identity: str) -> None:
""" """
Setter for manufacturer_identity Setter for manufacturer_identity
Args: Args:
manufacturer_identity (): manufacturer_identity value manufacturer_identity (str): manufacturer_identity value
Returns:
""" """
self.manufacturer_identity = manufacturer_identity self.manufacturer_identity = manufacturer_identity
def get_user_description(self) -> str: def get_user_description(self) -> str:
""" """
Getter for user_description Getter for user_description
Returns: the user_description value
Returns:
str: the user_description value
""" """
return self.user_description return self.user_description
def set_user_description(self, user_description: str): def set_user_description(self, user_description: str) -> None:
""" """
Setter for user_description Setter for user_description
Args: Args:
user_description (): the user_description value user_description (str): the user_description value
Returns:
""" """
self.user_description = user_description self.user_description = user_description
def get_time_source(self) -> str: def get_time_source(self) -> str:
""" """
Getter for time_source Getter for time_source
Returns: 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:
""" """
self.time_source = time_source self.time_source = time_source

View File

@@ -15,39 +15,37 @@ class ClockDescriptionOutput:
""" """
def __init__(self, clock_description_output: [str]): def __init__(self, clock_description_output: list[str]):
""" """
Constructor. Create an internal ClockDescriptionObject from the passed parameter.
Create an internal ClockDescriptionObject from the passed parameter.
Args: Args:
clock_description_output (list[str]): a list of strings representing the clock description output clock_description_output (list[str]): a list of strings representing the clock description output
""" """
cat_ptp_table_parser = CatPtpTableParser(clock_description_output) cat_ptp_table_parser = CatPtpTableParser(clock_description_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.clock_description_object = ClockDescriptionObject() self.clock_description_object = ClockDescriptionObject()
if 'productDescription' in output_values: if "productDescription" in output_values:
self.clock_description_object.set_product_description(output_values['productDescription']) self.clock_description_object.set_product_description(output_values["productDescription"])
if 'revisionData' in output_values: if "revisionData" in output_values:
self.clock_description_object.set_revision_data(output_values['revisionData']) self.clock_description_object.set_revision_data(output_values["revisionData"])
if 'manufacturerIdentity' in output_values: if "manufacturerIdentity" in output_values:
self.clock_description_object.set_manufacturer_identity(output_values['manufacturerIdentity']) self.clock_description_object.set_manufacturer_identity(output_values["manufacturerIdentity"])
if 'userDescription' in output_values: if "userDescription" in output_values:
self.clock_description_object.set_user_description(output_values['userDescription']) self.clock_description_object.set_user_description(output_values["userDescription"])
if 'timeSource' in output_values: if "timeSource" in output_values:
self.clock_description_object.set_time_source(output_values['timeSource']) self.clock_description_object.set_time_source(output_values["timeSource"])
def get_clock_description_object(self) -> ClockDescriptionObject: def get_clock_description_object(self) -> ClockDescriptionObject:
""" """
Getter for ClockDescriptionObject object. Getter for ClockDescriptionObject object.
Returns: Returns:
A ClockDescriptionObject ClockDescriptionObject: the clock_description_object
""" """
return self.clock_description_object return self.clock_description_object

View File

@@ -4,12 +4,12 @@ class DefaultInterfaceOptionsObject:
""" """
def __init__(self): def __init__(self):
self.clock_type: str = '' self.clock_type: str = ""
self.network_transport: str = '' self.network_transport: str = ""
self.delay_mechanism: str = '' self.delay_mechanism: str = ""
self.time_stamping: str = '' self.time_stamping: str = ""
self.tsproc_mode: str = '' self.tsproc_mode: str = ""
self.delay_filter: str = '' self.delay_filter: str = ""
self.delay_filter_length: int = -1 self.delay_filter_length: int = -1
self.egress_latency: int = -1 self.egress_latency: int = -1
self.ingress_latency: int = -1 self.ingress_latency: int = -1
@@ -18,189 +18,179 @@ class DefaultInterfaceOptionsObject:
def get_clock_type(self) -> str: def get_clock_type(self) -> str:
""" """
Getter for clock_type Getter for clock_type
Returns: clock_type
Returns:
str: the clock_type value
""" """
return self.clock_type return self.clock_type
def set_clock_type(self, clock_type: str): def set_clock_type(self, clock_type: str) -> None:
""" """
Setter for clock_type Setter for clock_type
Args: Args:
clock_type (): the clock_type value clock_type (str): the clock_type value
Returns:
""" """
self.clock_type = clock_type self.clock_type = clock_type
def get_network_transport(self) -> str: def get_network_transport(self) -> str:
""" """
Getter for network_transport Getter for network_transport
Returns: network_transport value
Returns:
str: the network_transport value
""" """
return self.network_transport return self.network_transport
def set_network_transport(self, network_transport: str): def set_network_transport(self, network_transport: str) -> None:
""" """
Setter for network_transport Setter for network_transport
Args: Args:
network_transport (): network_transport value network_transport (str): network_transport value
Returns:
""" """
self.network_transport = network_transport self.network_transport = network_transport
def get_delay_mechanism(self) -> str: def get_delay_mechanism(self) -> str:
""" """
Getter for delay_mechanism Getter for delay_mechanism
Returns: delay_mechanism value
Returns:
str: the delay_mechanism value
""" """
return self.delay_mechanism return self.delay_mechanism
def set_delay_mechanism(self, delay_mechanism: str): def set_delay_mechanism(self, delay_mechanism: str) -> None:
""" """
Setter for delay_mechanism Setter for delay_mechanism
Args: Args:
delay_mechanism (): delay_mechanism value delay_mechanism (str): delay_mechanism value
Returns:
""" """
self.delay_mechanism = delay_mechanism self.delay_mechanism = delay_mechanism
def get_time_stamping(self) -> str: def get_time_stamping(self) -> str:
""" """
Getter for time_stamping Getter for time_stamping
Returns: the time_stamping value
Returns:
str: the time_stamping value
""" """
return self.time_stamping return self.time_stamping
def set_time_stamping(self, time_stamping: str): def set_time_stamping(self, time_stamping: str) -> None:
""" """
Setter for time_stamping Setter for time_stamping
Args: Args:
time_stamping (): the time_stamping value time_stamping (str): the time_stamping value
Returns:
""" """
self.time_stamping = time_stamping self.time_stamping = time_stamping
def get_tsproc_mode(self) -> str: def get_tsproc_mode(self) -> str:
""" """
Getter for tsproc_mode Getter for tsproc_mode
Returns: tsproc_mode value
Returns:
str: the tsproc_mode value
""" """
return self.tsproc_mode return self.tsproc_mode
def set_tsproc_mode(self, tsproc_mode: str): def set_tsproc_mode(self, tsproc_mode: str) -> None:
""" """
Setter for tsproc_mode Setter for tsproc_mode
Args: Args:
tsproc_mode (): the tsproc_mode value tsproc_mode (str): the tsproc_mode value
Returns:
""" """
self.tsproc_mode = tsproc_mode self.tsproc_mode = tsproc_mode
def get_delay_filter(self) -> str: def get_delay_filter(self) -> str:
""" """
Getter for delay_filter Getter for delay_filter
Returns: delay_filter value
Returns:
str: the delay_filter value
""" """
return self.delay_filter return self.delay_filter
def set_delay_filter(self, delay_filter: str): def set_delay_filter(self, delay_filter: str) -> None:
""" """
Setter for delay_filter Setter for delay_filter
Args: Args:
delay_filter (): the delay_filter value delay_filter (str): the delay_filter value
Returns:
""" """
self.delay_filter = delay_filter self.delay_filter = delay_filter
def get_delay_filter_length(self) -> int: def get_delay_filter_length(self) -> int:
""" """
Getter for delay_filter_length Getter for delay_filter_length
Returns: delay_filter_length value
Returns:
int: the delay_filter_length value
""" """
return self.delay_filter_length return self.delay_filter_length
def set_delay_filter_length(self, delay_filter_length: int): def set_delay_filter_length(self, delay_filter_length: int) -> None:
""" """
Setter for delay_filter_length Setter for delay_filter_length
Args: Args:
delay_filter_length (): the delay_filter_length value delay_filter_length (int): the delay_filter_length value
Returns:
""" """
self.delay_filter_length = delay_filter_length self.delay_filter_length = delay_filter_length
def get_egress_latency(self) -> int: def get_egress_latency(self) -> int:
""" """
Getter for egress_latency Getter for egress_latency
Returns: egress_latency value
Returns:
int: the egress_latency value
""" """
return self.egress_latency return self.egress_latency
def set_egress_latency(self, egress_latency: int): def set_egress_latency(self, egress_latency: int) -> None:
""" """
Setter for egress_latency Setter for egress_latency
Args: Args:
egress_latency (): the egress_latency value egress_latency (int): the egress_latency value
Returns:
""" """
self.egress_latency = egress_latency self.egress_latency = egress_latency
def get_ingress_latency(self) -> int: def get_ingress_latency(self) -> int:
""" """
Getter for ingress_latency Getter for ingress_latency
Returns: ingress_latency value
Returns:
int: the ingress_latency value
""" """
return self.ingress_latency return self.ingress_latency
def set_ingress_latency(self, ingress_latency: int): def set_ingress_latency(self, ingress_latency: int) -> None:
""" """
Setter for ingress_latency Setter for ingress_latency
Args: Args:
ingress_latency (): the ingress_latency value ingress_latency (int): the ingress_latency value
Returns:
""" """
self.ingress_latency = ingress_latency self.ingress_latency = ingress_latency
def get_boundary_clock_jbod(self) -> int: def get_boundary_clock_jbod(self) -> int:
""" """
Getter for boundary_clock_jbod Getter for boundary_clock_jbod
Returns: boundary_clock_jbod value
Returns:
int: the boundary_clock_jbod value
""" """
return self.boundary_clock_jbod return self.boundary_clock_jbod
def set_boundary_clock_jbod(self, boundary_clock_jbod: int): def set_boundary_clock_jbod(self, boundary_clock_jbod: int) -> None:
""" """
Setter for boundary_clock_jbod Setter for boundary_clock_jbod
Args: Args:
boundary_clock_jbod (): the boundary_clock_jbod value boundary_clock_jbod (int): the boundary_clock_jbod value
Returns:
""" """
self.boundary_clock_jbod = boundary_clock_jbod self.boundary_clock_jbod = boundary_clock_jbod

View File

@@ -20,54 +20,52 @@ class DefaultInterfaceOptionsOutput:
""" """
def __init__(self, default_interface_options_output: [str]): def __init__(self, default_interface_options_output: list[str]):
""" """
Constructor. Create an internal DefaultInterfaceOptionsObject from the passed parameter.
Create an internal DefaultInterfaceOptionsObject from the passed parameter.
Args: Args:
default_interface_options_output (list[str]): a list of strings representing the default interface options output default_interface_options_output (list[str]): a list of strings representing the default interface options output
""" """
cat_ptp_table_parser = CatPtpTableParser(default_interface_options_output) cat_ptp_table_parser = CatPtpTableParser(default_interface_options_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.default_interface_options_object = DefaultInterfaceOptionsObject() self.default_interface_options_object = DefaultInterfaceOptionsObject()
if 'clock_type' in output_values: if "clock_type" in output_values:
self.default_interface_options_object.set_clock_type(output_values['clock_type']) self.default_interface_options_object.set_clock_type(output_values["clock_type"])
if 'network_transport' in output_values: if "network_transport" in output_values:
self.default_interface_options_object.set_network_transport(output_values['network_transport']) self.default_interface_options_object.set_network_transport(output_values["network_transport"])
if 'delay_mechanism' in output_values: if "delay_mechanism" in output_values:
self.default_interface_options_object.set_delay_mechanism(output_values['delay_mechanism']) self.default_interface_options_object.set_delay_mechanism(output_values["delay_mechanism"])
if 'time_stamping' in output_values: if "time_stamping" in output_values:
self.default_interface_options_object.set_time_stamping(output_values['time_stamping']) self.default_interface_options_object.set_time_stamping(output_values["time_stamping"])
if 'tsproc_mode' in output_values: if "tsproc_mode" in output_values:
self.default_interface_options_object.set_tsproc_mode(output_values['tsproc_mode']) self.default_interface_options_object.set_tsproc_mode(output_values["tsproc_mode"])
if 'delay_filter' in output_values: if "delay_filter" in output_values:
self.default_interface_options_object.set_delay_filter(output_values['delay_filter']) self.default_interface_options_object.set_delay_filter(output_values["delay_filter"])
if 'delay_filter_length' in output_values: if "delay_filter_length" in output_values:
self.default_interface_options_object.set_delay_filter_length(int(output_values['delay_filter_length'])) self.default_interface_options_object.set_delay_filter_length(int(output_values["delay_filter_length"]))
if 'egressLatency' in output_values: if "egressLatency" in output_values:
self.default_interface_options_object.set_egress_latency(int(output_values['egressLatency'])) self.default_interface_options_object.set_egress_latency(int(output_values["egressLatency"]))
if 'ingressLatency' in output_values: if "ingressLatency" in output_values:
self.default_interface_options_object.set_ingress_latency(int(output_values['ingressLatency'])) self.default_interface_options_object.set_ingress_latency(int(output_values["ingressLatency"]))
if 'boundary_clock_jbod' in output_values: if "boundary_clock_jbod" in output_values:
self.default_interface_options_object.set_boundary_clock_jbod(int(output_values['boundary_clock_jbod'])) self.default_interface_options_object.set_boundary_clock_jbod(int(output_values["boundary_clock_jbod"]))
def get_default_interface_options_object(self) -> DefaultInterfaceOptionsObject: def get_default_interface_options_object(self) -> DefaultInterfaceOptionsObject:
""" """
Getter for DefaultInterfaceOptionsObject object. Getter for DefaultInterfaceOptionsObject object.
Returns: Returns:
A DefaultInterfaceOptionsObject DefaultInterfaceOptionsObject: The default interface options object containing parsed values.
""" """
return self.default_interface_options_object return self.default_interface_options_object

View File

@@ -1,7 +1,5 @@
class PortDataSetObject: class PortDataSetObject:
""" """Object to hold the values of port data set"""
Object to hold the values of port data set
"""
def __init__(self): def __init__(self):
self.log_announce_interval: int = -1 self.log_announce_interval: int = -1
@@ -16,336 +14,314 @@ class PortDataSetObject:
self.fault_reset_interval: int = -1 self.fault_reset_interval: int = -1
self.neighbor_prop_delay_thresh: int = -1 self.neighbor_prop_delay_thresh: int = -1
self.master_only: int = -1 self.master_only: int = -1
self.as_capable: str = '' self.as_capable: str = ""
self.bmca: str = '' self.bmca: str = ""
self.inhibit_announce: int = -1 self.inhibit_announce: int = -1
self.inhibit_delay_req: int = '' self.inhibit_delay_req: int = ""
self.ignore_source_id: int = -1 self.ignore_source_id: int = -1
def get_log_announce_interval(self) -> int: def get_log_announce_interval(self) -> int:
""" """
Getter for log_announce_interval Getter for log_announce_interval
Returns: log_announce_interval
Returns:
int: the log_announce_interval value
""" """
return self.log_announce_interval return self.log_announce_interval
def set_log_announce_interval(self, log_announce_interval: int): def set_log_announce_interval(self, log_announce_interval: int) -> None:
""" """
Setter for two_step_flag Setter for two_step_flag
Args: Args:
log_announce_interval (): the log_announce_interval value log_announce_interval (int): the log_announce_interval value
Returns:
""" """
self.log_announce_interval = log_announce_interval self.log_announce_interval = log_announce_interval
def get_log_sync_interval(self) -> int: def get_log_sync_interval(self) -> int:
""" """
Getter for log_sync_interval Getter for log_sync_interval
Returns: log_sync_interval value
Returns:
int: the log_sync_interval value
""" """
return self.log_sync_interval return self.log_sync_interval
def set_log_sync_interval(self, log_sync_interval: int): def set_log_sync_interval(self, log_sync_interval: int) -> None:
""" """
Setter for log_sync_interval Setter for log_sync_interval
Args: Args:
log_sync_interval (): log_sync_interval value log_sync_interval (int): log_sync_interval value
Returns:
""" """
self.log_sync_interval = log_sync_interval self.log_sync_interval = log_sync_interval
def get_oper_log_sync_interval(self) -> int: def get_oper_log_sync_interval(self) -> int:
""" """
Getter for oper_log_sync_interval Getter for oper_log_sync_interval
Returns: oper_log_sync_interval value
Returns:
int: the oper_log_sync_interval value
""" """
return self.oper_log_sync_interval return self.oper_log_sync_interval
def set_oper_log_sync_interval(self, oper_log_sync_interval: int): def set_oper_log_sync_interval(self, oper_log_sync_interval: int) -> None:
""" """
Setter for oper_log_sync_interval Setter for oper_log_sync_interval
Args: Args:
oper_log_sync_interval (): oper_log_sync_interval value oper_log_sync_interval (int): oper_log_sync_interval value
Returns:
""" """
self.oper_log_sync_interval = oper_log_sync_interval self.oper_log_sync_interval = oper_log_sync_interval
def get_log_min_delay_req_interval(self) -> int: def get_log_min_delay_req_interval(self) -> int:
""" """
Getter for log_min_delay_req_interval Getter for log_min_delay_req_interval
Returns: the log_min_delay_req_interval value
Returns:
int: the log_min_delay_req_interval value
""" """
return self.log_min_delay_req_interval return self.log_min_delay_req_interval
def set_log_min_delay_req_interval(self, log_min_delay_req_interval: int): def set_log_min_delay_req_interval(self, log_min_delay_req_interval: int) -> None:
""" """
Setter for log_min_delay_req_interval Setter for log_min_delay_req_interval
Args: Args:
log_min_delay_req_interval (): the log_min_delay_req_interval value log_min_delay_req_interval (int): the log_min_delay_req_interval value
Returns:
""" """
self.log_min_delay_req_interval = log_min_delay_req_interval self.log_min_delay_req_interval = log_min_delay_req_interval
def get_log_min_p_delay_req_interval(self) -> int: def get_log_min_p_delay_req_interval(self) -> int:
""" """
Getter for log_min_p_delay_req_interval Getter for log_min_p_delay_req_interval
Returns: log_min_p_delay_req_interval value
Returns:
int: the log_min_p_delay_req_interval value
""" """
return self.log_min_p_delay_req_interval return self.log_min_p_delay_req_interval
def set_log_min_p_delay_req_interval(self, log_min_p_delay_req_interval: int): def set_log_min_p_delay_req_interval(self, log_min_p_delay_req_interval: int) -> None:
""" """
Setter for log_min_p_delay_req_interval Setter for log_min_p_delay_req_interval
Args: Args:
log_min_p_delay_req_interval (): the log_min_p_delay_req_interval value log_min_p_delay_req_interval (int): the log_min_p_delay_req_interval value
Returns:
""" """
self.log_min_p_delay_req_interval = log_min_p_delay_req_interval self.log_min_p_delay_req_interval = log_min_p_delay_req_interval
def get_oper_log_p_delay_req_interval(self) -> int: def get_oper_log_p_delay_req_interval(self) -> int:
""" """
Getter for oper_log_p_delay_req_interval Getter for oper_log_p_delay_req_interval
Returns: the oper_log_p_delay_req_interval value
Returns:
int: the oper_log_p_delay_req_interval value
""" """
return self.oper_log_p_delay_req_interval return self.oper_log_p_delay_req_interval
def set_oper_log_p_delay_req_interval(self, oper_log_p_delay_req_interval: int): def set_oper_log_p_delay_req_interval(self, oper_log_p_delay_req_interval: int) -> None:
""" """
Setter for oper_log_p_delay_req_interval Setter for oper_log_p_delay_req_interval
Args: Args:
oper_log_p_delay_req_interval (): the oper_log_p_delay_req_interval value oper_log_p_delay_req_interval (int): the oper_log_p_delay_req_interval value
Returns:
""" """
self.oper_log_p_delay_req_interval = oper_log_p_delay_req_interval self.oper_log_p_delay_req_interval = oper_log_p_delay_req_interval
def get_announce_receipt_timeout(self) -> int: def get_announce_receipt_timeout(self) -> int:
""" """
Getter for announce_receipt_timeout Getter for announce_receipt_timeout
Returns: the announce_receipt_timeout value
Returns:
int: the announce_receipt_timeout value
""" """
return self.announce_receipt_timeout return self.announce_receipt_timeout
def set_announce_receipt_timeout(self, announce_receipt_timeout: int): def set_announce_receipt_timeout(self, announce_receipt_timeout: int) -> None:
""" """
Setter for announce_receipt_timeout Setter for announce_receipt_timeout
Args: Args:
announce_receipt_timeout (): the announce_receipt_timeout value announce_receipt_timeout (int): the announce_receipt_timeout value
Returns:
""" """
self.announce_receipt_timeout = announce_receipt_timeout self.announce_receipt_timeout = announce_receipt_timeout
def get_sync_receipt_timeout(self) -> int: def get_sync_receipt_timeout(self) -> int:
""" """
Getter for sync_receipt_timeout Getter for sync_receipt_timeout
Returns: the sync_receipt_timeout value
Returns:
int: the sync_receipt_timeout value
""" """
return self.sync_receipt_timeout return self.sync_receipt_timeout
def set_sync_receipt_timeout(self, sync_receipt_timeout: int): def set_sync_receipt_timeout(self, sync_receipt_timeout: int) -> None:
""" """
Setter for sync_receipt_timeout Setter for sync_receipt_timeout
Args: Args:
sync_receipt_timeout (): the sync_receipt_timeout value sync_receipt_timeout (int): the sync_receipt_timeout value
Returns:
""" """
self.sync_receipt_timeout = sync_receipt_timeout self.sync_receipt_timeout = sync_receipt_timeout
def get_delay_asymmetry(self) -> int: def get_delay_asymmetry(self) -> int:
""" """
Getter for delay_asymmetry Getter for delay_asymmetry
Returns: the delay_asymmetry value
Returns:
int: the delay_asymmetry value
""" """
return self.delay_asymmetry return self.delay_asymmetry
def set_delay_asymmetry(self, delay_asymmetry: int): def set_delay_asymmetry(self, delay_asymmetry: int) -> None:
""" """
Setter for delay_asymmetry Setter for delay_asymmetry
Args: Args:
delay_asymmetry (): the delay_asymmetry value delay_asymmetry (int): the delay_asymmetry value
Returns:
""" """
self.delay_asymmetry = delay_asymmetry self.delay_asymmetry = delay_asymmetry
def get_fault_reset_interval(self) -> int: def get_fault_reset_interval(self) -> int:
""" """
Getter for fault_reset_interval Getter for fault_reset_interval
Returns: the fault_reset_interval value
Returns:
int: the fault_reset_interval value
""" """
return self.fault_reset_interval return self.fault_reset_interval
def set_fault_reset_interval(self, fault_reset_interval: int): def set_fault_reset_interval(self, fault_reset_interval: int) -> None:
""" """
Setter for fault_reset_interval Setter for fault_reset_interval
Args: Args:
fault_reset_interval (): the fault_reset_interval value fault_reset_interval (int): the fault_reset_interval value
Returns:
""" """
self.fault_reset_interval = fault_reset_interval self.fault_reset_interval = fault_reset_interval
def get_neighbor_prop_delay_thresh(self) -> int: def get_neighbor_prop_delay_thresh(self) -> int:
""" """
Getter for neighbor_prop_delay_thresh Getter for neighbor_prop_delay_thresh
Returns: the neighbor_prop_delay_thresh value
Returns:
int: the neighbor_prop_delay_thresh value
""" """
return self.neighbor_prop_delay_thresh return self.neighbor_prop_delay_thresh
def set_neighbor_prop_delay_thresh(self, neighbor_prop_delay_thresh: int): def set_neighbor_prop_delay_thresh(self, neighbor_prop_delay_thresh: int) -> None:
""" """
Setter for neighbor_prop_delay_thresh Setter for neighbor_prop_delay_thresh
Args: Args:
neighbor_prop_delay_thresh (): the neighbor_prop_delay_thresh value neighbor_prop_delay_thresh (int): the neighbor_prop_delay_thresh value
Returns:
""" """
self.neighbor_prop_delay_thresh = neighbor_prop_delay_thresh self.neighbor_prop_delay_thresh = neighbor_prop_delay_thresh
def get_master_only(self) -> int: def get_master_only(self) -> int:
""" """
Getter for master_only Getter for master_only
Returns: the master_only value
Returns:
int: the master_only value
""" """
return self.master_only return self.master_only
def set_master_only(self, master_only: int): def set_master_only(self, master_only: int) -> None:
""" """
Setter for master_only Setter for master_only
Args: Args:
master_only (): the master_only value master_only (int): the master_only value
Returns:
""" """
self.master_only = master_only self.master_only = master_only
def get_as_capable(self) -> str: def get_as_capable(self) -> str:
""" """
Getter for as_capable Getter for as_capable
Returns: the as_capable value
Returns:
str: the as_capable value
""" """
return self.as_capable return self.as_capable
def set_as_capable(self, as_capable: str): def set_as_capable(self, as_capable: str) -> None:
""" """
Setter for as_capable Setter for as_capable
Args: Args:
as_capable (): the as_capable value as_capable (str): the as_capable value
Returns:
""" """
self.as_capable = as_capable self.as_capable = as_capable
def get_bmca(self) -> str: def get_bmca(self) -> str:
""" """
Getter for bmca Getter for bmca
Returns: the bmca value
Returns:
str: the bmca value
""" """
return self.bmca return self.bmca
def set_bmca(self, bmca: str): def set_bmca(self, bmca: str) -> None:
""" """
Setter for bmca Setter for bmca
Args: Args:
bmca (): the bmca value bmca (str): the bmca value
Returns:
""" """
self.bmca = bmca self.bmca = bmca
def get_inhibit_announce(self) -> int: def get_inhibit_announce(self) -> int:
""" """
Getter for inhibit_announce Getter for inhibit_announce
Returns: the inhibit_announce value
Returns:
int: the inhibit_announce value
""" """
return self.inhibit_announce return self.inhibit_announce
def set_inhibit_announce(self, inhibit_announce: int): def set_inhibit_announce(self, inhibit_announce: int) -> None:
""" """
Setter for inhibit_announce Setter for inhibit_announce
Args: Args:
inhibit_announce (): the inhibit_announce value inhibit_announce (int): the inhibit_announce value
Returns:
""" """
self.inhibit_announce = inhibit_announce self.inhibit_announce = inhibit_announce
def get_inhibit_delay_req(self) -> int: def get_inhibit_delay_req(self) -> int:
""" """
Getter for inhibit_delay_req Getter for inhibit_delay_req
Returns: the inhibit_delay_req value
Returns:
int: the inhibit_delay_req value
""" """
return self.inhibit_delay_req return self.inhibit_delay_req
def set_inhibit_delay_req(self, inhibit_delay_req: int): def set_inhibit_delay_req(self, inhibit_delay_req: int) -> None:
""" """
Setter for inhibit_delay_req Setter for inhibit_delay_req
Args: Args:
inhibit_delay_req (): the inhibit_delay_req value inhibit_delay_req (int): the inhibit_delay_req value
Returns:
""" """
self.inhibit_delay_req = inhibit_delay_req self.inhibit_delay_req = inhibit_delay_req
def get_ignore_source_id(self) -> int: def get_ignore_source_id(self) -> int:
""" """
Getter for ignore_source_id Getter for ignore_source_id
Returns: the ignore_source_id value
Returns:
int: the ignore_source_id value
""" """
return self.ignore_source_id return self.ignore_source_id
def set_ignore_source_id(self, ignore_source_id: int): def set_ignore_source_id(self, ignore_source_id: int) -> None:
""" """
Setter for ignore_source_id Setter for ignore_source_id
Args: Args:
ignore_source_id (): the ignore_source_id value ignore_source_id (int): the ignore_source_id value
Returns:
""" """
self.ignore_source_id = ignore_source_id self.ignore_source_id = ignore_source_id

View File

@@ -28,75 +28,73 @@ class PortDataSetOutput:
""" """
def __init__(self, port_data_set_output: [str]): def __init__(self, port_data_set_output: list[str]):
""" """
Constructor. Create an internal PortDataSetObject from the passed parameter.
Create an internal PortDataSetObject from the passed parameter.
Args: Args:
port_data_set_output (list[str]): a list of strings representing the port data set output port_data_set_output (list[str]): a list of strings representing the port data set output
""" """
cat_ptp_table_parser = CatPtpTableParser(port_data_set_output) cat_ptp_table_parser = CatPtpTableParser(port_data_set_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.port_data_set_object = PortDataSetObject() self.port_data_set_object = PortDataSetObject()
if 'logAnnounceInterval' in output_values: if "logAnnounceInterval" in output_values:
self.port_data_set_object.set_log_announce_interval(int(output_values['logAnnounceInterval'])) self.port_data_set_object.set_log_announce_interval(int(output_values["logAnnounceInterval"]))
if 'logSyncInterval' in output_values: if "logSyncInterval" in output_values:
self.port_data_set_object.set_log_sync_interval(int(output_values['logSyncInterval'])) self.port_data_set_object.set_log_sync_interval(int(output_values["logSyncInterval"]))
if 'operLogSyncInterval' in output_values: if "operLogSyncInterval" in output_values:
self.port_data_set_object.set_oper_log_sync_interval(int(output_values['operLogSyncInterval'])) self.port_data_set_object.set_oper_log_sync_interval(int(output_values["operLogSyncInterval"]))
if 'logMinDelayReqInterval' in output_values: if "logMinDelayReqInterval" in output_values:
self.port_data_set_object.set_log_min_delay_req_interval(int(output_values['logMinDelayReqInterval'])) self.port_data_set_object.set_log_min_delay_req_interval(int(output_values["logMinDelayReqInterval"]))
if 'logMinPdelayReqInterval' in output_values: if "logMinPdelayReqInterval" in output_values:
self.port_data_set_object.set_log_min_p_delay_req_interval(int(output_values['logMinPdelayReqInterval'])) self.port_data_set_object.set_log_min_p_delay_req_interval(int(output_values["logMinPdelayReqInterval"]))
if 'operLogPdelayReqInterval' in output_values: if "operLogPdelayReqInterval" in output_values:
self.port_data_set_object.set_oper_log_p_delay_req_interval(int(output_values['operLogPdelayReqInterval'])) self.port_data_set_object.set_oper_log_p_delay_req_interval(int(output_values["operLogPdelayReqInterval"]))
if 'announceReceiptTimeout' in output_values: if "announceReceiptTimeout" in output_values:
self.port_data_set_object.set_announce_receipt_timeout(int(output_values['announceReceiptTimeout'])) self.port_data_set_object.set_announce_receipt_timeout(int(output_values["announceReceiptTimeout"]))
if 'syncReceiptTimeout' in output_values: if "syncReceiptTimeout" in output_values:
self.port_data_set_object.set_sync_receipt_timeout(int(output_values['syncReceiptTimeout'])) self.port_data_set_object.set_sync_receipt_timeout(int(output_values["syncReceiptTimeout"]))
if 'delayAsymmetry' in output_values: if "delayAsymmetry" in output_values:
self.port_data_set_object.set_delay_asymmetry(int(output_values['delayAsymmetry'])) self.port_data_set_object.set_delay_asymmetry(int(output_values["delayAsymmetry"]))
if 'fault_reset_interval' in output_values: if "fault_reset_interval" in output_values:
self.port_data_set_object.set_fault_reset_interval(int(output_values['fault_reset_interval'])) self.port_data_set_object.set_fault_reset_interval(int(output_values["fault_reset_interval"]))
if 'neighborPropDelayThresh' in output_values: if "neighborPropDelayThresh" in output_values:
self.port_data_set_object.set_neighbor_prop_delay_thresh(int(output_values['neighborPropDelayThresh'])) self.port_data_set_object.set_neighbor_prop_delay_thresh(int(output_values["neighborPropDelayThresh"]))
if 'masterOnly' in output_values: if "masterOnly" in output_values:
self.port_data_set_object.set_master_only(int(output_values['masterOnly'])) self.port_data_set_object.set_master_only(int(output_values["masterOnly"]))
if 'asCapable' in output_values: if "asCapable" in output_values:
self.port_data_set_object.set_as_capable(output_values['asCapable']) self.port_data_set_object.set_as_capable(output_values["asCapable"])
if 'BMCA' in output_values: if "BMCA" in output_values:
self.port_data_set_object.set_bmca(output_values['BMCA']) self.port_data_set_object.set_bmca(output_values["BMCA"])
if 'inhibit_announce' in output_values: if "inhibit_announce" in output_values:
self.port_data_set_object.set_inhibit_announce(int(output_values['inhibit_announce'])) self.port_data_set_object.set_inhibit_announce(int(output_values["inhibit_announce"]))
if 'inhibit_delay_req' in output_values: if "inhibit_delay_req" in output_values:
self.port_data_set_object.set_inhibit_delay_req(int(output_values['inhibit_delay_req'])) self.port_data_set_object.set_inhibit_delay_req(int(output_values["inhibit_delay_req"]))
if 'ignore_source_id' in output_values: if "ignore_source_id" in output_values:
self.port_data_set_object.set_ignore_source_id(int(output_values['ignore_source_id'])) self.port_data_set_object.set_ignore_source_id(int(output_values["ignore_source_id"]))
def get_port_data_set_object(self) -> PortDataSetObject: def get_port_data_set_object(self) -> PortDataSetObject:
""" """
Getter for port_data_set_object object. Getter for port_data_set_object object.
Returns: Returns:
A PortDataSetObject PortDataSetObject: The port data set object containing parsed values.
""" """
return self.port_data_set_object return self.port_data_set_object

View File

@@ -16,7 +16,6 @@ class PtpCguComponentOutput:
Gets the cgu component. Gets the cgu component.
Returns: Returns:
PtpCguComponentObject - the PtpCguComponentObject PtpCguComponentObject: The cgu component object containing parsed values.
""" """
return self.cgu_component return self.cgu_component

View File

@@ -19,334 +19,311 @@ class RunTimeOptionsObject:
self.use_syslog: int = -1 self.use_syslog: int = -1
self.verbose: int = -1 self.verbose: int = -1
self.summary_interval: int = -1 self.summary_interval: int = -1
self.kernel_leap: int = '' self.kernel_leap: int = ""
self.check_fup_sync: int = -1 self.check_fup_sync: int = -1
def get_assume_two_step(self) -> int: def get_assume_two_step(self) -> int:
""" """
Getter for assume_two_step Getter for assume_two_step
Returns: assume_two_step
Returns:
int: the assume_two_step value
""" """
return self.assume_two_step return self.assume_two_step
def set_assume_two_step(self, assume_two_step: int): def set_assume_two_step(self, assume_two_step: int) -> None:
""" """
Setter for assume_two_step Setter for assume_two_step
Args: Args:
assume_two_step (): the assume_two_step value assume_two_step (int): the assume_two_step value
Returns:
""" """
self.assume_two_step = assume_two_step self.assume_two_step = assume_two_step
def get_logging_level(self) -> int: def get_logging_level(self) -> int:
""" """
Getter for logging_level Getter for logging_level
Returns: logging_level value
Returns:
int: the logging_level value
""" """
return self.logging_level return self.logging_level
def set_logging_level(self, logging_level: int): def set_logging_level(self, logging_level: int) -> None:
""" """
Setter for logging_level Setter for logging_level
Args: Args:
log_sync_interval (): log_sync_interval value logging_level (int): the logging_level value
Returns:
""" """
self.logging_level = logging_level self.logging_level = logging_level
def get_path_trace_enabled(self) -> int: def get_path_trace_enabled(self) -> int:
""" """
Getter for path_trace_enabled Getter for path_trace_enabled
Returns: path_trace_enabled value
Returns:
int: the path_trace_enabled value
""" """
return self.path_trace_enabled return self.path_trace_enabled
def set_path_trace_enabled(self, path_trace_enabled: int): def set_path_trace_enabled(self, path_trace_enabled: int) -> None:
""" """
Setter for path_trace_enabled Setter for path_trace_enabled
Args: Args:
path_trace_enabled (): path_trace_enabled value path_trace_enabled (int): path_trace_enabled value
Returns:
""" """
self.path_trace_enabled = path_trace_enabled self.path_trace_enabled = path_trace_enabled
def get_follow_up_info(self) -> int: def get_follow_up_info(self) -> int:
""" """
Getter for follow_up_info Getter for follow_up_info
Returns: the follow_up_info value
Returns:
int: the follow_up_info value
""" """
return self.follow_up_info return self.follow_up_info
def set_follow_up_info(self, follow_up_info: int): def set_follow_up_info(self, follow_up_info: int) -> None:
""" """
Setter for follow_up_info Setter for follow_up_info
Args: Args:
follow_up_info (): the follow_up_info value follow_up_info (int): the follow_up_info value
Returns:
""" """
self.follow_up_info = follow_up_info self.follow_up_info = follow_up_info
def get_hybrid_e2e(self) -> int: def get_hybrid_e2e(self) -> int:
""" """
Getter for hybrid_e2e Getter for hybrid_e2e
Returns: hybrid_e2e value
Returns:
int: the hybrid_e2e value
""" """
return self.hybrid_e2e return self.hybrid_e2e
def set_hybrid_e2e(self, hybrid_e2e: int): def set_hybrid_e2e(self, hybrid_e2e: int) -> None:
""" """
Setter for hybrid_e2e Setter for hybrid_e2e
Args: Args:
hybrid_e2e (): the hybrid_e2e value hybrid_e2e (int): the hybrid_e2e value
Returns:
""" """
self.hybrid_e2e = hybrid_e2e self.hybrid_e2e = hybrid_e2e
def get_inhibit_multicast_service(self) -> int: def get_inhibit_multicast_service(self) -> int:
""" """
Getter for inhibit_multicast_service Getter for inhibit_multicast_service
Returns: the inhibit_multicast_service value
Returns:
int: the inhibit_multicast_service value
""" """
return self.inhibit_multicast_service return self.inhibit_multicast_service
def set_inhibit_multicast_service(self, inhibit_multicast_service: int): def set_inhibit_multicast_service(self, inhibit_multicast_service: int) -> None:
""" """
Setter for inhibit_multicast_service Setter for inhibit_multicast_service
Args: Args:
inhibit_multicast_service (): the inhibit_multicast_service value inhibit_multicast_service (int): the inhibit_multicast_service value
Returns:
""" """
self.inhibit_multicast_service = inhibit_multicast_service self.inhibit_multicast_service = inhibit_multicast_service
def get_net_sync_monitor(self) -> int: def get_net_sync_monitor(self) -> int:
""" """
Getter for net_sync_monitor Getter for net_sync_monitor
Returns: the net_sync_monitor value
Returns:
int: the net_sync_monitor value
""" """
return self.net_sync_monitor return self.net_sync_monitor
def set_net_sync_monitor(self, net_sync_monitor: int): def set_net_sync_monitor(self, net_sync_monitor: int) -> None:
""" """
Setter for net_sync_monitor Setter for net_sync_monitor
Args: Args:
net_sync_monitor (): the net_sync_monitor value net_sync_monitor (int): the net_sync_monitor value
Returns:
""" """
self.net_sync_monitor = net_sync_monitor self.net_sync_monitor = net_sync_monitor
def get_tc_spanning_tree(self) -> int: def get_tc_spanning_tree(self) -> int:
""" """
Getter for tc_spanning_tree Getter for tc_spanning_tree
Returns: the tc_spanning_tree value
Returns:
int: the tc_spanning_tree value
""" """
return self.tc_spanning_tree return self.tc_spanning_tree
def set_tc_spanning_tree(self, tc_spanning_tree: int): def set_tc_spanning_tree(self, tc_spanning_tree: int) -> None:
""" """
Setter for sync_receipt_timeout Setter for sync_receipt_timeout
Args: Args:
tc_spanning_tree (): the tc_spanning_tree value tc_spanning_tree (int): the tc_spanning_tree value
Returns:
""" """
self.tc_spanning_tree = tc_spanning_tree self.tc_spanning_tree = tc_spanning_tree
def get_tx_timestamp_timeout(self) -> int: def get_tx_timestamp_timeout(self) -> int:
""" """
Getter for tx_timestamp_timeout Getter for tx_timestamp_timeout
Returns: the tx_timestamp_timeout value
Returns:
int: the tx_timestamp_timeout value
""" """
return self.tx_timestamp_timeout return self.tx_timestamp_timeout
def set_tx_timestamp_timeout(self, tx_timestamp_timeout: int): def set_tx_timestamp_timeout(self, tx_timestamp_timeout: int) -> None:
""" """
Setter for tx_timestamp_timeout Setter for tx_timestamp_timeout
Args: Args:
tx_timestamp_timeout (): the tx_timestamp_timeout value tx_timestamp_timeout (int): the tx_timestamp_timeout value
Returns:
""" """
self.tx_timestamp_timeout = tx_timestamp_timeout self.tx_timestamp_timeout = tx_timestamp_timeout
def get_unicast_listen(self) -> int: def get_unicast_listen(self) -> int:
""" """
Getter for unicast_listen Getter for unicast_listen
Returns: the unicast_listen value
Returns:
int: the unicast_listen value
""" """
return self.unicast_listen return self.unicast_listen
def set_unicast_listen(self, unicast_listen: int): def set_unicast_listen(self, unicast_listen: int) -> None:
""" """
Setter for unicast_listen Setter for unicast_listen
Args: Args:
unicast_listen (): the unicast_listen value unicast_listen (int): the unicast_listen value
Returns:
""" """
self.unicast_listen = unicast_listen self.unicast_listen = unicast_listen
def get_unicast_master_table(self) -> int: def get_unicast_master_table(self) -> int:
""" """
Getter for unicast_master_table Getter for unicast_master_table
Returns: the unicast_master_table value
Returns:
int: the unicast_master_table value
""" """
return self.unicast_master_table return self.unicast_master_table
def set_unicast_master_table(self, unicast_master_table: int): def set_unicast_master_table(self, unicast_master_table: int) -> None:
""" """
Setter for unicast_master_table Setter for unicast_master_table
Args: Args:
unicast_master_table (): the unicast_master_table value unicast_master_table (int): the unicast_master_table value
Returns:
""" """
self.unicast_master_table = unicast_master_table self.unicast_master_table = unicast_master_table
def get_unicast_req_duration(self) -> int: def get_unicast_req_duration(self) -> int:
""" """
Getter for unicast_req_duration Getter for unicast_req_duration
Returns: the unicast_req_duration value
Returns:
int: the unicast_req_duration value
""" """
return self.unicast_req_duration return self.unicast_req_duration
def set_unicast_req_duration(self, unicast_req_duration: int): def set_unicast_req_duration(self, unicast_req_duration: int) -> None:
""" """
Setter for unicast_req_duration Setter for unicast_req_duration
Args: Args:
unicast_req_duration (): the unicast_req_duration value unicast_req_duration (int): the unicast_req_duration value
Returns:
""" """
self.unicast_req_duration = unicast_req_duration self.unicast_req_duration = unicast_req_duration
def get_use_syslog(self) -> int: def get_use_syslog(self) -> int:
""" """
Getter for use_syslog Getter for use_syslog
Returns: the use_syslog value
Returns:
int: the use_syslog value
""" """
return self.use_syslog return self.use_syslog
def set_use_syslog(self, use_syslog: int): def set_use_syslog(self, use_syslog: int) -> None:
""" """
Setter for use_syslog Setter for use_syslog
Args: Args:
use_syslog (): the use_syslog value use_syslog (int): the use_syslog value
Returns:
""" """
self.use_syslog = use_syslog self.use_syslog = use_syslog
def get_verbose(self) -> int: def get_verbose(self) -> int:
""" """
Getter for verbose Getter for verbose
Returns: the verbose value
Returns:
int: the verbose value
""" """
return self.verbose return self.verbose
def set_verbose(self, verbose: int): def set_verbose(self, verbose: int) -> None:
""" """
Setter for verbose Setter for verbose
Args: Args:
verbose (): the verbose value verbose (int): the verbose value
Returns:
""" """
self.verbose = verbose self.verbose = verbose
def get_summary_interval(self) -> int: def get_summary_interval(self) -> int:
""" """
Getter for summary_interval Getter for summary_interval
Returns: the summary_interval value
Returns:
int: the summary_interval value
""" """
return self.summary_interval return self.summary_interval
def set_summary_interval(self, summary_interval: int): def set_summary_interval(self, summary_interval: int) -> None:
""" """
Setter for summary_interval Setter for summary_interval
Args: Args:
summary_interval (): the summary_interval value summary_interval (int): the summary_interval value
Returns:
""" """
self.summary_interval = summary_interval self.summary_interval = summary_interval
def get_kernel_leap(self) -> int: def get_kernel_leap(self) -> int:
""" """
Getter for kernel_leap Getter for kernel_leap
Returns: the kernel_leap value
Returns:
int: the kernel_leap value
""" """
return self.kernel_leap return self.kernel_leap
def set_kernel_leap(self, kernel_leap: int): def set_kernel_leap(self, kernel_leap: int) -> None:
""" """
Setter for kernel_leap Setter for kernel_leap
Args: Args:
kernel_leap (): the kernel_leap value kernel_leap (int): the kernel_leap value
Returns:
""" """
self.kernel_leap = kernel_leap self.kernel_leap = kernel_leap
def get_check_fup_sync(self) -> int: def get_check_fup_sync(self) -> int:
""" """
Getter for check_fup_sync Getter for check_fup_sync
Returns: the check_fup_sync value
Returns:
int: the check_fup_sync value
""" """
return self.check_fup_sync return self.check_fup_sync
def set_check_fup_sync(self, check_fup_sync: int): def set_check_fup_sync(self, check_fup_sync: int) -> None:
""" """
Setter for check_fup_sync Setter for check_fup_sync
Args: Args:
check_fup_sync (): the check_fup_sync value check_fup_sync (int): the check_fup_sync value
Returns:
""" """
self.check_fup_sync = check_fup_sync self.check_fup_sync = check_fup_sync

View File

@@ -27,75 +27,73 @@ class RunTimeOptionsOutput:
""" """
def __init__(self, run_time_options_output: [str]): def __init__(self, run_time_options_output: list[str]):
""" """
Constructor. Create an internal RunTimeOptionsObject from the passed parameter.
Create an internal RunTimeOptionsObject from the passed parameter.
Args: Args:
run_time_options_output (list[str]): a list of strings representing the run time options output run_time_options_output (list[str]): a list of strings representing the run time options output
""" """
cat_ptp_table_parser = CatPtpTableParser(run_time_options_output) cat_ptp_table_parser = CatPtpTableParser(run_time_options_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.run_time_options_object = RunTimeOptionsObject() self.run_time_options_object = RunTimeOptionsObject()
if 'assume_two_step' in output_values: if "assume_two_step" in output_values:
self.run_time_options_object.set_assume_two_step(int(output_values['assume_two_step'])) self.run_time_options_object.set_assume_two_step(int(output_values["assume_two_step"]))
if 'logging_level' in output_values: if "logging_level" in output_values:
self.run_time_options_object.set_logging_level(int(output_values['logging_level'])) self.run_time_options_object.set_logging_level(int(output_values["logging_level"]))
if 'path_trace_enabled' in output_values: if "path_trace_enabled" in output_values:
self.run_time_options_object.set_path_trace_enabled(int(output_values['path_trace_enabled'])) self.run_time_options_object.set_path_trace_enabled(int(output_values["path_trace_enabled"]))
if 'follow_up_info' in output_values: if "follow_up_info" in output_values:
self.run_time_options_object.set_follow_up_info(int(output_values['follow_up_info'])) self.run_time_options_object.set_follow_up_info(int(output_values["follow_up_info"]))
if 'hybrid_e2e' in output_values: if "hybrid_e2e" in output_values:
self.run_time_options_object.set_hybrid_e2e(int(output_values['hybrid_e2e'])) self.run_time_options_object.set_hybrid_e2e(int(output_values["hybrid_e2e"]))
if 'inhibit_multicast_service' in output_values: if "inhibit_multicast_service" in output_values:
self.run_time_options_object.set_inhibit_multicast_service(int(output_values['inhibit_multicast_service'])) self.run_time_options_object.set_inhibit_multicast_service(int(output_values["inhibit_multicast_service"]))
if 'net_sync_monitor' in output_values: if "net_sync_monitor" in output_values:
self.run_time_options_object.set_net_sync_monitor(int(output_values['net_sync_monitor'])) self.run_time_options_object.set_net_sync_monitor(int(output_values["net_sync_monitor"]))
if 'tc_spanning_tree' in output_values: if "tc_spanning_tree" in output_values:
self.run_time_options_object.set_tc_spanning_tree(int(output_values['tc_spanning_tree'])) self.run_time_options_object.set_tc_spanning_tree(int(output_values["tc_spanning_tree"]))
if 'tx_timestamp_timeout' in output_values: if "tx_timestamp_timeout" in output_values:
self.run_time_options_object.set_tx_timestamp_timeout(int(output_values['tx_timestamp_timeout'])) self.run_time_options_object.set_tx_timestamp_timeout(int(output_values["tx_timestamp_timeout"]))
if 'unicast_listen' in output_values: if "unicast_listen" in output_values:
self.run_time_options_object.set_unicast_listen(int(output_values['unicast_listen'])) self.run_time_options_object.set_unicast_listen(int(output_values["unicast_listen"]))
if 'unicast_master_table' in output_values: if "unicast_master_table" in output_values:
self.run_time_options_object.set_unicast_master_table(int(output_values['unicast_master_table'])) self.run_time_options_object.set_unicast_master_table(int(output_values["unicast_master_table"]))
if 'unicast_req_duration' in output_values: if "unicast_req_duration" in output_values:
self.run_time_options_object.set_unicast_req_duration(int(output_values['unicast_req_duration'])) self.run_time_options_object.set_unicast_req_duration(int(output_values["unicast_req_duration"]))
if 'use_syslog' in output_values: if "use_syslog" in output_values:
self.run_time_options_object.set_use_syslog(int(output_values['use_syslog'])) self.run_time_options_object.set_use_syslog(int(output_values["use_syslog"]))
if 'verbose' in output_values: if "verbose" in output_values:
self.run_time_options_object.set_verbose(int(output_values['verbose'])) self.run_time_options_object.set_verbose(int(output_values["verbose"]))
if 'summary_interval' in output_values: if "summary_interval" in output_values:
self.run_time_options_object.set_summary_interval(int(output_values['summary_interval'])) self.run_time_options_object.set_summary_interval(int(output_values["summary_interval"]))
if 'kernel_leap' in output_values: if "kernel_leap" in output_values:
self.run_time_options_object.set_kernel_leap(int(output_values['kernel_leap'])) self.run_time_options_object.set_kernel_leap(int(output_values["kernel_leap"]))
if 'check_fup_sync' in output_values: if "check_fup_sync" in output_values:
self.run_time_options_object.set_check_fup_sync(int(output_values['check_fup_sync'])) self.run_time_options_object.set_check_fup_sync(int(output_values["check_fup_sync"]))
def get_run_time_options_object(self) -> RunTimeOptionsObject: def get_run_time_options_object(self) -> RunTimeOptionsObject:
""" """
Getter for run_time_options_object object. Getter for run_time_options_object object.
Returns: Returns:
A RunTimeOptionsObject RunTimeOptionsObject: The run time options object containing parsed values.
""" """
return self.run_time_options_object return self.run_time_options_object

View File

@@ -1,7 +1,5 @@
class ServoOptionsObject: class ServoOptionsObject:
""" """Object to hold the values of Servo Options Options"""
Object to hold the values of Servo Options Options
"""
def __init__(self): def __init__(self):
self.pi_proportional_const: float = None self.pi_proportional_const: float = None
@@ -15,7 +13,7 @@ class ServoOptionsObject:
self.step_threshold: float = None self.step_threshold: float = None
self.first_step_threshold: float = None self.first_step_threshold: float = None
self.max_frequency: int = None self.max_frequency: int = None
self.clock_servo: str = '' self.clock_servo: str = ""
self.sanity_freq_limit: int = -1 self.sanity_freq_limit: int = -1
self.ntpshm_segment: int = -1 self.ntpshm_segment: int = -1
self.msg_interval_request: int = -1 self.msg_interval_request: int = -1
@@ -26,348 +24,323 @@ class ServoOptionsObject:
def get_pi_proportional_const(self) -> float: def get_pi_proportional_const(self) -> float:
""" """
Getter for pi_proportional Getter for pi_proportional
Returns: pi_proportional
Returns:
float: the pi_proportional_const value
""" """
return self.pi_proportional_const return self.pi_proportional_const
def set_pi_proportional_const(self, pi_proportional_const: float): def set_pi_proportional_const(self, pi_proportional_const: float) -> None:
""" """
Setter for pi_proportional_const Setter for pi_proportional_const
Args: Args:
pi_proportional_const (): the pi_proportional_const value pi_proportional_const (float): the pi_proportional_const value
Returns:
""" """
self.pi_proportional_const = pi_proportional_const self.pi_proportional_const = pi_proportional_const
def get_pi_integral_const(self) -> float: def get_pi_integral_const(self) -> float:
""" """
Getter for pi_integral_const Getter for pi_integral_const
Returns: pi_integral_const value
Returns:
float: the pi_integral_const value
""" """
return self.pi_integral_const return self.pi_integral_const
def set_pi_integral_const(self, pi_integral_const: float): def set_pi_integral_const(self, pi_integral_const: float) -> None:
""" """
Setter for pi_integral_const Setter for pi_integral_const
Args: Args:
pi_integral_const (): pi_integral_const value pi_integral_const (float): pi_integral_const value
Returns:
""" """
self.pi_integral_const = pi_integral_const self.pi_integral_const = pi_integral_const
def get_pi_proportional_scale(self) -> float: def get_pi_proportional_scale(self) -> float:
""" """
Getter for pi_proportional_scale Getter for pi_proportional_scale
Returns: pi_proportional_scale value
Returns:
float: the pi_proportional_scale value
""" """
return self.pi_proportional_scale return self.pi_proportional_scale
def set_pi_proportional_scale(self, pi_proportional_scale: float): def set_pi_proportional_scale(self, pi_proportional_scale: float) -> None:
""" """
Setter for pi_proportional_scale Setter for pi_proportional_scale
Args: Args:
pi_proportional_scale (): pi_proportional_scale value pi_proportional_scale (float): pi_proportional_scale value
Returns:
""" """
self.pi_proportional_scale = pi_proportional_scale self.pi_proportional_scale = pi_proportional_scale
def get_pi_proportional_exponent(self) -> float: def get_pi_proportional_exponent(self) -> float:
""" """
Getter for pi_proportional_exponent Getter for pi_proportional_exponent
Returns: the pi_proportional_exponent value
Returns:
float: the pi_proportional_exponent value
""" """
return self.pi_proportional_exponent return self.pi_proportional_exponent
def set_pi_proportional_exponent(self, pi_proportional_exponent: float): def set_pi_proportional_exponent(self, pi_proportional_exponent: float) -> None:
""" """
Setter for pi_proportional_exponent Setter for pi_proportional_exponent
Args: Args:
pi_proportional_exponent (): the pi_proportional_exponent value pi_proportional_exponent (float): the pi_proportional_exponent value
Returns:
""" """
self.pi_proportional_exponent = pi_proportional_exponent self.pi_proportional_exponent = pi_proportional_exponent
def get_pi_proportional_norm_max(self) -> float: def get_pi_proportional_norm_max(self) -> float:
""" """
Getter for pi_proportional_norm_max Getter for pi_proportional_norm_max
Returns: pi_proportional_norm_max value
Returns:
float: the pi_proportional_norm_max value
""" """
return self.pi_proportional_norm_max return self.pi_proportional_norm_max
def set_pi_proportional_norm_max(self, pi_proportional_norm_max: float): def set_pi_proportional_norm_max(self, pi_proportional_norm_max: float) -> None:
""" """
Setter for pi_proportional_norm_max Setter for pi_proportional_norm_max
Args: Args:
pi_proportional_norm_max (): the pi_proportional_norm_max value pi_proportional_norm_max (float): the pi_proportional_norm_max value
Returns:
""" """
self.pi_proportional_norm_max = pi_proportional_norm_max self.pi_proportional_norm_max = pi_proportional_norm_max
def get_pi_integral_scale(self) -> float: def get_pi_integral_scale(self) -> float:
""" """
Getter for pi_integral_scale Getter for pi_integral_scale
Returns: pi_integral_scale value
Returns:
float: the pi_integral_scale value
""" """
return self.pi_integral_scale return self.pi_integral_scale
def set_pi_integral_scale(self, pi_integral_scale: float): def set_pi_integral_scale(self, pi_integral_scale: float) -> None:
""" """
Setter for pi_integral_scale Setter for pi_integral_scale
Args: Args:
pi_integral_scale (): the pi_integral_scale value pi_integral_scale (float): the pi_integral_scale value
Returns:
""" """
self.pi_integral_scale = pi_integral_scale self.pi_integral_scale = pi_integral_scale
def get_pi_integral_exponent(self) -> float: def get_pi_integral_exponent(self) -> float:
""" """
Getter for pi_integral_exponent Getter for pi_integral_exponent
Returns: pi_integral_exponent value
Returns:
float: pi_integral_exponent value
""" """
return self.pi_integral_exponent return self.pi_integral_exponent
def set_pi_integral_exponent(self, pi_integral_exponent: float): def set_pi_integral_exponent(self, pi_integral_exponent: float) -> None:
""" """
Setter for pi_integral_exponent Setter for pi_integral_exponent
Args: Args:
pi_integral_exponent (): the pi_integral_exponent value pi_integral_exponent (float): the pi_integral_exponent value
Returns:
""" """
self.pi_integral_exponent = pi_integral_exponent self.pi_integral_exponent = pi_integral_exponent
def get_pi_integral_norm_max(self) -> float: def get_pi_integral_norm_max(self) -> float:
""" """
Getter for pi_integral_norm_max Getter for pi_integral_norm_max
Returns: pi_integral_norm_max value
Returns:
float: the pi_integral_norm_max value
""" """
return self.pi_integral_norm_max return self.pi_integral_norm_max
def set_pi_integral_norm_max(self, pi_integral_norm_max: float): def set_pi_integral_norm_max(self, pi_integral_norm_max: float) -> None:
""" """
Setter for pi_integral_norm_max Setter for pi_integral_norm_max
Args: Args:
pi_integral_norm_max (): the pi_integral_norm_max value pi_integral_norm_max (float): the pi_integral_norm_max value
Returns:
""" """
self.pi_integral_norm_max = pi_integral_norm_max self.pi_integral_norm_max = pi_integral_norm_max
def get_step_threshold(self) -> float: def get_step_threshold(self) -> float:
""" """
Getter for step_threshold Getter for step_threshold
Returns: the step_threshold value
Returns:
float: the step_threshold value
""" """
return self.step_threshold return self.step_threshold
def set_step_threshold(self, step_threshold: float): def set_step_threshold(self, step_threshold: float) -> None:
""" """
Setter for step_threshold Setter for step_threshold
Args: Args:
step_threshold (): the step_threshold value step_threshold (float): the step_threshold value
Returns:
""" """
self.step_threshold = step_threshold self.step_threshold = step_threshold
def get_first_step_threshold(self) -> float: def get_first_step_threshold(self) -> float:
""" """
Getter for first_step_threshold Getter for first_step_threshold
Returns: the first_step_threshold value
Returns:
float: the first_step_threshold value
""" """
return self.first_step_threshold return self.first_step_threshold
def set_first_step_threshold(self, first_step_threshold: float): def set_first_step_threshold(self, first_step_threshold: float) -> None:
""" """
Setter for first_step_threshold Setter for first_step_threshold
Args: Args:
first_step_threshold (): the first_step_threshold value first_step_threshold (float): the first_step_threshold value
Returns:
""" """
self.first_step_threshold = first_step_threshold self.first_step_threshold = first_step_threshold
def get_max_frequency(self) -> int: def get_max_frequency(self) -> int:
""" """
Getter for max_frequency Getter for max_frequency
Returns: the max_frequency value
Returns:
int: the max_frequency value
""" """
return self.max_frequency return self.max_frequency
def set_max_frequency(self, max_frequency: int): def set_max_frequency(self, max_frequency: int) -> None:
""" """
Setter for max_frequency Setter for max_frequency
Args: Args:
max_frequency (): the max_frequency value max_frequency (int): the max_frequency value
Returns:
""" """
self.max_frequency = max_frequency self.max_frequency = max_frequency
def get_clock_servo(self) -> str: def get_clock_servo(self) -> str:
""" """
Getter for clock_servo Getter for clock_servo
Returns: the clock_servo value
Returns:
str: the clock_servo value
""" """
return self.clock_servo return self.clock_servo
def set_clock_servo(self, clock_servo: str): def set_clock_servo(self, clock_servo: str) -> None:
""" """
Setter for clock_servo Setter for clock_servo
Args: Args:
clock_servo (): the clock_servo value clock_servo (str): the clock_servo value
Returns:
""" """
self.clock_servo = clock_servo self.clock_servo = clock_servo
def get_sanity_freq_limit(self) -> int: def get_sanity_freq_limit(self) -> int:
""" """
Getter for sanity_freq_limit Getter for sanity_freq_limit
Returns: the sanity_freq_limit value
Returns:
int: the sanity_freq_limit value
""" """
return self.sanity_freq_limit return self.sanity_freq_limit
def set_sanity_freq_limit(self, sanity_freq_limit: int): def set_sanity_freq_limit(self, sanity_freq_limit: int) -> None:
""" """
Setter for sanity_freq_limit Setter for sanity_freq_limit
Args: Args:
sanity_freq_limit (): the sanity_freq_limit value sanity_freq_limit (int): the sanity_freq_limit value
Returns:
""" """
self.sanity_freq_limit = sanity_freq_limit self.sanity_freq_limit = sanity_freq_limit
def get_ntpshm_segment(self) -> int: def get_ntpshm_segment(self) -> int:
""" """
Getter for ntpshm_segment Getter for ntpshm_segment
Returns: the ntpshm_segment value
Returns:
int: the ntpshm_segment value
""" """
return self.ntpshm_segment return self.ntpshm_segment
def set_ntpshm_segment(self, ntpshm_segment: int): def set_ntpshm_segment(self, ntpshm_segment: int) -> None:
""" """
Setter for ntpshm_segment Setter for ntpshm_segment
Args: Args:
ntpshm_segment (): the ntpshm_segment value ntpshm_segment (int): the ntpshm_segment value
Returns:
""" """
self.ntpshm_segment = ntpshm_segment self.ntpshm_segment = ntpshm_segment
def get_msg_interval_request(self) -> int: def get_msg_interval_request(self) -> int:
""" """
Getter for msg_interval_request Getter for msg_interval_request
Returns: the msg_interval_request value
Returns:
int: the msg_interval_request value
""" """
return self.msg_interval_request return self.msg_interval_request
def set_msg_interval_request(self, msg_interval_request: int): def set_msg_interval_request(self, msg_interval_request: int) -> None:
""" """
Setter for msg_interval_request Setter for msg_interval_request
Args: Args:
msg_interval_request (): the msg_interval_request value msg_interval_request (int): the msg_interval_request value
Returns:
""" """
self.msg_interval_request = msg_interval_request self.msg_interval_request = msg_interval_request
def get_servo_num_offset_values(self) -> int: def get_servo_num_offset_values(self) -> int:
""" """
Getter for servo_num_offset_values Getter for servo_num_offset_values
Returns: the servo_num_offset_values value
Returns:
int: the servo_num_offset_values value
""" """
return self.servo_num_offset_values return self.servo_num_offset_values
def set_servo_num_offset_values(self, servo_num_offset_values: int): def set_servo_num_offset_values(self, servo_num_offset_values: int) -> None:
""" """
Setter for servo_num_offset_values Setter for servo_num_offset_values
Args: Args:
servo_num_offset_values (): the servo_num_offset_values value servo_num_offset_values (int): the servo_num_offset_values value
Returns:
""" """
self.servo_num_offset_values = servo_num_offset_values self.servo_num_offset_values = servo_num_offset_values
def get_servo_offset_threshold(self) -> int: def get_servo_offset_threshold(self) -> int:
""" """
Getter for servo_offset_threshold Getter for servo_offset_threshold
Returns: the servo_offset_threshold value
Returns:
int: the servo_offset_threshold value
""" """
return self.servo_offset_threshold return self.servo_offset_threshold
def set_servo_offset_threshold(self, servo_offset_threshold: int): def set_servo_offset_threshold(self, servo_offset_threshold: int) -> None:
""" """
Setter for servo_offset_threshold Setter for servo_offset_threshold
Args: Args:
servo_offset_threshold (): the servo_offset_threshold value servo_offset_threshold (int): the servo_offset_threshold value
Returns:
""" """
self.servo_offset_threshold = servo_offset_threshold self.servo_offset_threshold = servo_offset_threshold
def get_write_phase_mode(self) -> int: def get_write_phase_mode(self) -> int:
""" """
Getter for write_phase_mode Getter for write_phase_mode
Returns: the write_phase_mode value
Returns:
int: the write_phase_mode value
""" """
return self.write_phase_mode return self.write_phase_mode
def set_write_phase_mode(self, write_phase_mode: int): def set_write_phase_mode(self, write_phase_mode: int) -> None:
""" """
Setter for write_phase_mode Setter for write_phase_mode
Args: Args:
write_phase_mode (): the write_phase_mode value write_phase_mode (int): the write_phase_mode value
Returns:
""" """
self.write_phase_mode = write_phase_mode self.write_phase_mode = write_phase_mode

View File

@@ -28,78 +28,76 @@ class ServoOptionsOutput:
""" """
def __init__(self, servo_options_output: [str]): def __init__(self, servo_options_output: list[str]):
""" """
Constructor. Create an internal ServoOptionsObject from the passed parameter.
Create an internal ServoOptionsObject from the passed parameter.
Args: Args:
servo_options_output (list[str]): a list of strings representing the servo options output servo_options_output (list[str]): a list of strings representing the servo options output
""" """
cat_ptp_table_parser = CatPtpTableParser(servo_options_output) cat_ptp_table_parser = CatPtpTableParser(servo_options_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.servo_options_object = ServoOptionsObject() self.servo_options_object = ServoOptionsObject()
if 'pi_proportional_const' in output_values: if "pi_proportional_const" in output_values:
self.servo_options_object.set_pi_proportional_const(float(output_values['pi_proportional_const'])) self.servo_options_object.set_pi_proportional_const(float(output_values["pi_proportional_const"]))
if 'pi_integral_const' in output_values: if "pi_integral_const" in output_values:
self.servo_options_object.set_pi_integral_const(float(output_values['pi_integral_const'])) self.servo_options_object.set_pi_integral_const(float(output_values["pi_integral_const"]))
if 'pi_proportional_scale' in output_values: if "pi_proportional_scale" in output_values:
self.servo_options_object.set_pi_proportional_scale(float(output_values['pi_proportional_scale'])) self.servo_options_object.set_pi_proportional_scale(float(output_values["pi_proportional_scale"]))
if 'pi_proportional_exponent' in output_values: if "pi_proportional_exponent" in output_values:
self.servo_options_object.set_pi_proportional_exponent(float(output_values['pi_proportional_exponent'])) self.servo_options_object.set_pi_proportional_exponent(float(output_values["pi_proportional_exponent"]))
if 'pi_proportional_norm_max' in output_values: if "pi_proportional_norm_max" in output_values:
self.servo_options_object.set_pi_proportional_norm_max(float(output_values['pi_proportional_norm_max'])) self.servo_options_object.set_pi_proportional_norm_max(float(output_values["pi_proportional_norm_max"]))
if 'pi_integral_scale' in output_values: if "pi_integral_scale" in output_values:
self.servo_options_object.set_pi_integral_scale(float(output_values['pi_integral_scale'])) self.servo_options_object.set_pi_integral_scale(float(output_values["pi_integral_scale"]))
if 'pi_integral_exponent' in output_values: if "pi_integral_exponent" in output_values:
self.servo_options_object.set_pi_integral_exponent(float(output_values['pi_integral_exponent'])) self.servo_options_object.set_pi_integral_exponent(float(output_values["pi_integral_exponent"]))
if 'pi_integral_norm_max' in output_values: if "pi_integral_norm_max" in output_values:
self.servo_options_object.set_pi_integral_norm_max(float(output_values['pi_integral_norm_max'])) self.servo_options_object.set_pi_integral_norm_max(float(output_values["pi_integral_norm_max"]))
if 'step_threshold' in output_values: if "step_threshold" in output_values:
self.servo_options_object.set_step_threshold(float(output_values['step_threshold'])) self.servo_options_object.set_step_threshold(float(output_values["step_threshold"]))
if 'first_step_threshold' in output_values: if "first_step_threshold" in output_values:
self.servo_options_object.set_first_step_threshold(float(output_values['first_step_threshold'])) self.servo_options_object.set_first_step_threshold(float(output_values["first_step_threshold"]))
if 'max_frequency' in output_values: if "max_frequency" in output_values:
self.servo_options_object.set_max_frequency(int(output_values['max_frequency'])) self.servo_options_object.set_max_frequency(int(output_values["max_frequency"]))
if 'clock_servo' in output_values: if "clock_servo" in output_values:
self.servo_options_object.set_clock_servo(output_values['clock_servo']) self.servo_options_object.set_clock_servo(output_values["clock_servo"])
if 'sanity_freq_limit' in output_values: if "sanity_freq_limit" in output_values:
self.servo_options_object.set_sanity_freq_limit(int(output_values['sanity_freq_limit'])) self.servo_options_object.set_sanity_freq_limit(int(output_values["sanity_freq_limit"]))
if 'ntpshm_segment' in output_values: if "ntpshm_segment" in output_values:
self.servo_options_object.set_ntpshm_segment(int(output_values['ntpshm_segment'])) self.servo_options_object.set_ntpshm_segment(int(output_values["ntpshm_segment"]))
if 'msg_interval_request' in output_values: if "msg_interval_request" in output_values:
self.servo_options_object.set_msg_interval_request(int(output_values['msg_interval_request'])) self.servo_options_object.set_msg_interval_request(int(output_values["msg_interval_request"]))
if 'servo_num_offset_values' in output_values: if "servo_num_offset_values" in output_values:
self.servo_options_object.set_servo_num_offset_values(int(output_values['servo_num_offset_values'])) self.servo_options_object.set_servo_num_offset_values(int(output_values["servo_num_offset_values"]))
if 'servo_offset_threshold' in output_values: if "servo_offset_threshold" in output_values:
self.servo_options_object.set_servo_offset_threshold(int(output_values['servo_offset_threshold'])) self.servo_options_object.set_servo_offset_threshold(int(output_values["servo_offset_threshold"]))
if 'write_phase_mode' in output_values: if "write_phase_mode" in output_values:
self.servo_options_object.set_write_phase_mode(int(output_values['write_phase_mode'])) self.servo_options_object.set_write_phase_mode(int(output_values["write_phase_mode"]))
def get_servo_options_object(self) -> ServoOptionsObject: def get_servo_options_object(self) -> ServoOptionsObject:
""" """
Getter for servo_options_object object. Getter for servo_options_object object.
Returns: Returns:
A ServoOptionsObject ServoOptionsObject: The servo options object containing parsed values.
""" """
return self.servo_options_object return self.servo_options_object

View File

@@ -4,143 +4,136 @@ class TransportOptionsObject:
""" """
def __init__(self): def __init__(self):
self.transport_specific: str = '' self.transport_specific: str = ""
self.ptp_dst_mac: str = '' self.ptp_dst_mac: str = ""
self.p2p_dst_mac: str = '' self.p2p_dst_mac: str = ""
self.udp_ttl: int = -1 self.udp_ttl: int = -1
self.udp6_scope: str = '' self.udp6_scope: str = ""
self.uds_address: str = '' self.uds_address: str = ""
self.uds_ro_address: str = '' self.uds_ro_address: str = ""
def get_transport_specific(self) -> str: def get_transport_specific(self) -> str:
""" """
Getter for transport_specific Getter for transport_specific
Returns: transport_specific
Returns:
str: the transport_specific value
""" """
return self.transport_specific return self.transport_specific
def set_transport_specific(self, transport_specific: str): def set_transport_specific(self, transport_specific: str) -> None:
""" """
Setter for transport_specific Setter for transport_specific
Args: Args:
transport_specific (): the transport_specific value transport_specific (str): the transport_specific value
Returns:
""" """
self.transport_specific = transport_specific self.transport_specific = transport_specific
def get_ptp_dst_mac(self) -> str: def get_ptp_dst_mac(self) -> str:
""" """
Getter for ptp_dst_mac Getter for ptp_dst_mac
Returns: ptp_dst_mac value
Returns:
str: the ptp_dst_mac value
""" """
return self.ptp_dst_mac return self.ptp_dst_mac
def set_ptp_dst_mac(self, ptp_dst_mac: str): def set_ptp_dst_mac(self, ptp_dst_mac: str) -> None:
""" """
Setter for ptp_dst_mac Setter for ptp_dst_mac
Args: Args:
ptp_dst_mac (): ptp_dst_mac value ptp_dst_mac (str): the ptp_dst_mac value
Returns:
""" """
self.ptp_dst_mac = ptp_dst_mac self.ptp_dst_mac = ptp_dst_mac
def get_p2p_dst_mac(self) -> str: def get_p2p_dst_mac(self) -> str:
""" """
Getter for p2p_dst_mac Getter for p2p_dst_mac
Returns: p2p_dst_mac value
Returns:
str: the p2p_dst_mac value
""" """
return self.p2p_dst_mac return self.p2p_dst_mac
def set_p2p_dst_mac(self, p2p_dst_mac: str): def set_p2p_dst_mac(self, p2p_dst_mac: str) -> None:
""" """
Setter for p2p_dst_mac Setter for p2p_dst_mac
Args: Args:
p2p_dst_mac (): p2p_dst_mac value p2p_dst_mac (str): p2p_dst_mac value
Returns:
""" """
self.p2p_dst_mac = p2p_dst_mac self.p2p_dst_mac = p2p_dst_mac
def get_udp_ttl(self) -> int: def get_udp_ttl(self) -> int:
""" """
Getter for udp_ttl Getter for udp_ttl
Returns: the udp_ttl value
Returns:
int: the udp_ttl value
""" """
return self.udp_ttl return self.udp_ttl
def set_udp_ttl(self, udp_ttl: int): def set_udp_ttl(self, udp_ttl: int) -> None:
""" """
Setter for udp_ttl Setter for udp_ttl
Args: Args:
udp_ttl (): the udp_ttl value udp_ttl (int): the udp_ttl value
Returns:
""" """
self.udp_ttl = udp_ttl self.udp_ttl = udp_ttl
def get_udp6_scope(self) -> str: def get_udp6_scope(self) -> str:
""" """
Getter for udp6_scope Getter for udp6_scope
Returns: udp6_scope value
Returns:
str: the udp6_scope value
""" """
return self.udp6_scope return self.udp6_scope
def set_udp6_scope(self, udp6_scope: str): def set_udp6_scope(self, udp6_scope: str) -> None:
""" """
Setter for udp6_scope Setter for udp6_scope
Args: Args:
udp6_scope (): the udp6_scope value udp6_scope (str): the udp6_scope value
Returns:
""" """
self.udp6_scope = udp6_scope self.udp6_scope = udp6_scope
def get_uds_address(self) -> str: def get_uds_address(self) -> str:
""" """
Getter for uds_address Getter for uds_address
Returns: uds_address value
Returns:
str: uds_address value
""" """
return self.uds_address return self.uds_address
def set_uds_address(self, uds_address: str): def set_uds_address(self, uds_address: str) -> None:
""" """
Setter for uds_address Setter for uds_address
Args: Args:
uds_address (): the uds_address value uds_address (str): the uds_address value
Returns:
""" """
self.uds_address = uds_address self.uds_address = uds_address
def get_uds_ro_address(self) -> str: def get_uds_ro_address(self) -> str:
""" """
Getter for uds_ro_address Getter for uds_ro_address
Returns: uds_ro_address value
Returns:
str: uds_ro_address value
""" """
return self.uds_ro_address return self.uds_ro_address
def set_uds_ro_address(self, uds_ro_address: str): def set_uds_ro_address(self, uds_ro_address: str) -> None:
""" """
Setter for uds_ro_address Setter for uds_ro_address
Args: Args:
uds_ro_address (): the uds_ro_address value uds_ro_address (str): the uds_ro_address value
Returns:
""" """
self.uds_ro_address = uds_ro_address self.uds_ro_address = uds_ro_address

View File

@@ -17,45 +17,43 @@ class TransportOptionsOutput:
""" """
def __init__(self, transport_options_output: [str]): def __init__(self, transport_options_output: list[str]):
""" """
Constructor. Create an internal ServoOptionsObject from the passed parameter.
Create an internal ServoOptionsObject from the passed parameter.
Args: Args:
transport_options_output (list[str]): a list of strings representing the servo options output transport_options_output (list[str]): a list of strings representing the servo options output
""" """
cat_ptp_table_parser = CatPtpTableParser(transport_options_output) cat_ptp_table_parser = CatPtpTableParser(transport_options_output)
output_values = cat_ptp_table_parser.get_output_values_dict() output_values = cat_ptp_table_parser.get_output_values_dict()
self.transport_options_object = TransportOptionsObject() self.transport_options_object = TransportOptionsObject()
if 'transportSpecific' in output_values: if "transportSpecific" in output_values:
self.transport_options_object.set_transport_specific(output_values['transportSpecific']) self.transport_options_object.set_transport_specific(output_values["transportSpecific"])
if 'ptp_dst_mac' in output_values: if "ptp_dst_mac" in output_values:
self.transport_options_object.set_ptp_dst_mac(output_values['ptp_dst_mac']) self.transport_options_object.set_ptp_dst_mac(output_values["ptp_dst_mac"])
if 'p2p_dst_mac' in output_values: if "p2p_dst_mac" in output_values:
self.transport_options_object.set_p2p_dst_mac(output_values['p2p_dst_mac']) self.transport_options_object.set_p2p_dst_mac(output_values["p2p_dst_mac"])
if 'udp_ttl' in output_values: if "udp_ttl" in output_values:
self.transport_options_object.set_udp_ttl(int(output_values['udp_ttl'])) self.transport_options_object.set_udp_ttl(int(output_values["udp_ttl"]))
if 'udp6_scope' in output_values: if "udp6_scope" in output_values:
self.transport_options_object.set_udp6_scope(output_values['udp6_scope']) self.transport_options_object.set_udp6_scope(output_values["udp6_scope"])
if 'uds_address' in output_values: if "uds_address" in output_values:
self.transport_options_object.set_uds_address(output_values['uds_address']) self.transport_options_object.set_uds_address(output_values["uds_address"])
if 'uds_ro_address' in output_values: if "uds_ro_address" in output_values:
self.transport_options_object.set_uds_ro_address(output_values['uds_ro_address']) self.transport_options_object.set_uds_ro_address(output_values["uds_ro_address"])
def get_transport_options_object(self) -> TransportOptionsObject: def get_transport_options_object(self) -> TransportOptionsObject:
""" """
Getter for TransportOptionsObject object. Getter for TransportOptionsObject object.
Returns: Returns:
A TransportOptionsObject TransportOptionsObject: The transport options object containing parsed values.
""" """
return self.transport_options_object return self.transport_options_object

View File

@@ -4,6 +4,7 @@ from typing import List
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.cloud_platform.fault_management.alarms.alarm_list_keywords import AlarmListKeywords from keywords.cloud_platform.fault_management.alarms.alarm_list_keywords import AlarmListKeywords
from keywords.cloud_platform.fault_management.alarms.objects.alarm_list_object import AlarmListObject from keywords.cloud_platform.fault_management.alarms.objects.alarm_list_object import AlarmListObject
@@ -11,19 +12,14 @@ from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKey
class PhcCtlKeywords(BaseKeyword): class PhcCtlKeywords(BaseKeyword):
""" """Directly control PHC device clock using given SSH connection."""
Directly control PHC device clock using given SSH connection.
Attributes: def __init__(self, ssh_connection: SSHConnection):
ssh_connection: An instance of an SSH connection.
"""
def __init__(self, ssh_connection):
""" """
Initializes the PhcCtlKeywords with an SSH connection. Initializes the PhcCtlKeywords 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
@@ -120,9 +116,7 @@ class PhcCtlKeywords(BaseKeyword):
def wait_for_phc_ctl_adjustment_alarm(self, interface: str, alarms: List[AlarmListObject], timeout: int = 120, polling_interval: int = 10) -> None: def wait_for_phc_ctl_adjustment_alarm(self, interface: str, alarms: List[AlarmListObject], timeout: int = 120, polling_interval: int = 10) -> None:
""" """
Run a remote phc_ctl adjustment loop on the controller as root, Run a remote phc_ctl adjustment loop on the controller as root, and stop it once the specified PTP alarm(s) are detected or a timeout occurs.
and stop it once the specified PTP alarm(s) are detected or
a timeout occurs.
Args: Args:
interface (str): The interface to apply phc_ctl adjustments to. interface (str): The interface to apply phc_ctl adjustments to.
@@ -130,8 +124,6 @@ class PhcCtlKeywords(BaseKeyword):
timeout (int): Maximum wait time in seconds (default: 120). timeout (int): Maximum wait time in seconds (default: 120).
polling_interval (int): Interval in seconds between polling attempts (default: 10). polling_interval (int): Interval in seconds between polling attempts (default: 10).
Returns: None
Raises: Raises:
TimeoutError: If the expected alarms are not observed within the timeout period. TimeoutError: If the expected alarms are not observed within the timeout period.
""" """
@@ -145,9 +137,6 @@ class PhcCtlKeywords(BaseKeyword):
Args: Args:
command (str): The shell command to be executed with root privileges. command (str): The shell command to be executed with root privileges.
Returns:
None
""" """
root_prompt = PromptResponse("#", command) root_prompt = PromptResponse("#", command)
self.ssh_connection.send_expect_prompts("sudo su", [password_prompt, root_prompt]) self.ssh_connection.send_expect_prompts("sudo su", [password_prompt, root_prompt])