Merge "Modified delete all keywords and added PTP configurations for compute node"

This commit is contained in:
Zuul
2025-04-07 17:19:50 +00:00
committed by Gerrit Code Review
13 changed files with 472 additions and 145 deletions

View File

@@ -20,6 +20,9 @@ class PTPConfig:
ptp_dict = json5.load(json_data)
# what kind of device it is.
self.external_ptp_device_type = ptp_dict["external_ptp_device_type"]
# GNSS server information
self.gnss_server_host = ptp_dict["gnss_server_host"]
self.gnss_server_username = ptp_dict["gnss_server_username"]
@@ -28,6 +31,15 @@ class PTPConfig:
# Extract the NIC Connections and Host information from the dictionary
self.ptp_hosts = self._extract_ptp_hosts(ptp_dict)
def get_external_ptp_device_type(self) -> str:
"""
Getter for the external ptp device type.
Returns:
str: external ptp device type
"""
return self.external_ptp_device_type
def get_gnss_server_host(self) -> str:
"""
Getter for the GNSS server host.

View File

@@ -30,6 +30,8 @@ class PTPNic:
self.nic_connection = None
self.conn_to_spirent = None
self.spirent_port = None
self.conn_to_proxmox = None
self.proxmox_port = None
if "gpio_switch_port" in nic_dict and nic_dict["gpio_switch_port"]:
self.gpio_switch_port = nic_dict["gpio_switch_port"]
@@ -49,6 +51,12 @@ class PTPNic:
if "spirent_port" in nic_dict and nic_dict["spirent_port"]:
self.spirent_port = nic_dict["spirent_port"]
if "conn_to_proxmox" in nic_dict and nic_dict["conn_to_proxmox"]:
self.conn_to_proxmox = nic_dict["conn_to_proxmox"]
if "proxmox_port" in nic_dict and nic_dict["proxmox_port"]:
self.proxmox_port = nic_dict["proxmox_port"]
def __str__(self):
"""
String representation of this object.
@@ -100,6 +108,8 @@ class PTPNic:
"nic_connection": nic_connection_dict,
"conn_to_spirent": self.conn_to_spirent,
"spirent_port": self.spirent_port,
"conn_to_proxmox": self.conn_to_proxmox,
"proxmox_port": self.proxmox_port,
}
return ptp_nic_dictionary
@@ -243,3 +253,21 @@ class PTPNic:
The Spirent port.
"""
return self.spirent_port
def get_conn_to_proxmox(self) -> str:
"""
Gets the connection to proxmox.
Returns (str):
The connection to proxmox.
"""
return self.conn_to_proxmox
def get_proxmox_port(self) -> str:
"""
Gets the proxmox port.
Returns (str):
The proxmox port.
"""
return self.proxmox_port

View File

@@ -17,23 +17,23 @@ class SystemHostOutput:
for value in output_values:
if self.is_valid_output(value):
system_host_object = SystemHostObject(
int(value['id']),
value['hostname'],
value['personality'],
value['administrative'],
value['operational'],
value['availability'],
int(value["id"]),
value["hostname"],
value["personality"],
value["administrative"],
value["operational"],
value["availability"],
)
if 'capabilities' in value:
system_host_object.set_capabilities(value['capabilities'])
if 'uptime' in value:
system_host_object.set_uptime(int(value['uptime']))
if 'subfunctions' in value:
system_host_object.set_sub_functions(value['subfunctions'].split(','))
if 'bm_ip' in value:
system_host_object.set_bm_ip(value['bm_ip'])
if 'bm_username' in value:
system_host_object.set_bm_username(value['bm_username'])
if "capabilities" in value:
system_host_object.set_capabilities(value["capabilities"])
if "uptime" in value:
system_host_object.set_uptime(int(value["uptime"]))
if "subfunctions" in value:
system_host_object.set_sub_functions(value["subfunctions"].split(","))
if "bm_ip" in value:
system_host_object.set_bm_ip(value["bm_ip"])
if "bm_username" in value:
system_host_object.set_bm_username(value["bm_username"])
self.system_hosts.append(system_host_object)
else:
@@ -42,19 +42,21 @@ class SystemHostOutput:
def get_hosts(self) -> [SystemHostObject]:
"""
Returns the list of system host objects
Returns:
Returns:
list: list of SystemHostObject
"""
return self.system_hosts
def get_host(self, host_name: str) -> SystemHostObject:
"""
Returns the host with the given name
Args:
host_name (): the name of the host
host_name (str): the name of the host
Returns:
SystemHostObject: system host object
"""
hosts = list(filter(lambda host: host.get_host_name() == host_name, self.system_hosts))
if len(hosts) == 0:
@@ -65,12 +67,13 @@ class SystemHostOutput:
def get_standby_controller(self) -> SystemHostObject:
"""
Gets the standby controller
Returns: the standby controller
Returns:
SystemHostObject: the standby controller
"""
hosts = list(
filter(
lambda host: host.get_capabilities().get_personality() == 'Controller-Standby',
lambda host: host.get_capabilities().get_personality() == "Controller-Standby",
self.system_hosts,
)
)
@@ -82,12 +85,13 @@ class SystemHostOutput:
def get_active_controller(self) -> SystemHostObject:
"""
Gets the active controller
Returns: the active controller
Returns:
SystemHostObject: the active controller
"""
hosts = list(
filter(
lambda host: host.get_capabilities().get_personality() == 'Controller-Active',
lambda host: host.get_capabilities().get_personality() == "Controller-Active",
self.system_hosts,
)
)
@@ -99,12 +103,13 @@ class SystemHostOutput:
def get_controllers(self) -> list[SystemHostObject]:
"""
Gets the list of controllers
Returns (list[SystemHostObject]): the list of controllers
Returns
list[SystemHostObject]: the list of controllers
"""
hosts = list(
filter(
lambda host: 'controller' in host.get_personality(),
lambda host: "controller" in host.get_personality(),
self.system_hosts,
)
)
@@ -113,6 +118,24 @@ class SystemHostOutput:
return hosts
def get_controllers_and_computes(self) -> [SystemHostObject]:
"""
Gets the controllers and computes
Returns:
list[SystemHostObject]: list of controllers and computes
"""
hosts = list(
filter(
lambda host: host.get_personality() == "worker" or "controller" in host.get_personality(),
self.system_hosts,
)
)
if len(hosts) == 0:
raise KeywordException("No hosts were found")
return hosts
def get_computes(self) -> [SystemHostObject]:
"""
Gets the compute
@@ -121,7 +144,7 @@ class SystemHostOutput:
"""
hosts = list(
filter(
lambda host: host.get_personality() == 'worker',
lambda host: host.get_personality() == "worker",
self.system_hosts,
)
)
@@ -138,7 +161,7 @@ class SystemHostOutput:
"""
hosts = list(
filter(
lambda host: host.get_personality() == 'storage',
lambda host: host.get_personality() == "storage",
self.system_hosts,
)
)
@@ -158,23 +181,23 @@ class SystemHostOutput:
"""
valid = True
if 'id' not in value:
get_logger().log_error(f'id is not in the output value: {value}')
if "id" not in value:
get_logger().log_error(f"id is not in the output value: {value}")
valid = False
if 'hostname' not in value:
get_logger().log_error(f'host_name is not in the output value: {value}')
if "hostname" not in value:
get_logger().log_error(f"host_name is not in the output value: {value}")
valid = False
if 'personality' not in value:
get_logger().log_error(f'personality is not in the output value: {value}')
if "personality" not in value:
get_logger().log_error(f"personality is not in the output value: {value}")
valid = False
if 'administrative' not in value:
get_logger().log_error(f'adminstrative is not in the output value: {value}')
if "administrative" not in value:
get_logger().log_error(f"adminstrative is not in the output value: {value}")
valid = False
if 'operational' not in value:
get_logger().log_error(f'operational is not in the output value: {value}')
if "operational" not in value:
get_logger().log_error(f"operational is not in the output value: {value}")
valid = False
if 'availability' not in value:
get_logger().log_error(f'id is not in the output value: {value}')
if "availability" not in value:
get_logger().log_error(f"id is not in the output value: {value}")
valid = False
return valid

View File

@@ -1,6 +1,5 @@
from keywords.cloud_platform.system.ptp.objects.system_host_if_ptp_assign_object import SystemHostIfPTPAssignObject
from keywords.cloud_platform.system.system_table_parser import SystemTableParser
from keywords.python.type_converter import TypeConverter
class SystemHostIfPTPAssignOutput:
@@ -13,7 +12,7 @@ class SystemHostIfPTPAssignOutput:
Constructor
Args:
system_host_if_ptp_assign_output (str): Output of the 'system host-if-ptp-assign' and 'system host-if-ptp-remove' command.
system_host_if_ptp_assign_output (str): Output of the 'system host-if-ptp-assign' and 'system host-if-ptp-remove' command.
"""
self.system_host_if_ptp_assign_output: list[SystemHostIfPTPAssignObject] = []
system_table_parser = SystemTableParser(system_host_if_ptp_assign_output)
@@ -21,22 +20,23 @@ class SystemHostIfPTPAssignOutput:
for value in output_values:
system_host_if_ptp_assign_object = SystemHostIfPTPAssignObject()
if 'uuid' in value:
system_host_if_ptp_assign_object.set_uuid(value['uuid'])
if "uuid" in value:
system_host_if_ptp_assign_object.set_uuid(value["uuid"])
if 'name' in value:
system_host_if_ptp_assign_object.set_name(value['name'])
if "name" in value:
system_host_if_ptp_assign_object.set_name(value["name"])
if 'ptp_instance_name' in value:
system_host_if_ptp_assign_object.set_ptp_instance_name(value['ptp_instance_name'])
if "ptp_instance_name" in value:
system_host_if_ptp_assign_object.set_ptp_instance_name(value["ptp_instance_name"])
if 'parameters' in value:
system_host_if_ptp_assign_object.set_parameters(TypeConverter.parse_string_to_list(value['parameters']))
if "parameters" in value:
system_host_if_ptp_assign_object.set_parameters(eval(value["parameters"]))
self.system_host_if_ptp_assign_output.append(system_host_if_ptp_assign_object)
def get_host_if_ptp_assign_and_remove(self) -> list[SystemHostIfPTPAssignObject]:
"""Returns the parsed system host-if-ptp-assign and system host-if-ptp-remove object
Returns:
list: list of SystemHostIfPTPAssignObject
"""
return self.system_host_if_ptp_assign_output

View File

@@ -14,7 +14,7 @@ class SystemPTPInstanceOutput:
Constructor
Args:
system_ptp_instance_output (str): Output of the system ptp-instance command.
system_ptp_instance_output (str): Output of the system ptp-instance command.
"""
system_vertical_table_parser = SystemVerticalTableParser(system_ptp_instance_output)
@@ -22,27 +22,28 @@ class SystemPTPInstanceOutput:
self.system_ptp_instance_object = SystemPTPInstanceObject()
if 'uuid' not in output_values:
if "uuid" not in output_values:
raise KeywordException(f"The output line {output_values} was not valid because it is missing an 'uuid'.")
self.system_ptp_instance_object.set_uuid(output_values['uuid'])
self.system_ptp_instance_object.set_uuid(output_values["uuid"])
if 'name' in output_values:
self.system_ptp_instance_object.set_name(output_values['name'])
if "name" in output_values:
self.system_ptp_instance_object.set_name(output_values["name"])
if 'service' in output_values:
self.system_ptp_instance_object.set_service(output_values['service'])
if "service" in output_values:
self.system_ptp_instance_object.set_service(output_values["service"])
if 'hostnames' in output_values:
self.system_ptp_instance_object.set_hostnames(TypeConverter.parse_string_to_list(output_values['hostnames']))
if "hostnames" in output_values:
self.system_ptp_instance_object.set_hostnames(TypeConverter.parse_string_to_list(output_values["hostnames"]))
if 'parameters' in output_values:
self.system_ptp_instance_object.set_parameters(TypeConverter.parse_string_to_list(output_values['parameters']))
if "parameters" in output_values:
self.system_ptp_instance_object.set_parameters(eval(output_values["parameters"]))
def get_ptp_instance(self) -> SystemPTPInstanceObject:
"""
Returns the parsed system ptp-instance
Returns:
SystemPTPInstanceObject: parsed system ptp-instance
"""
return self.system_ptp_instance_object
@@ -51,8 +52,8 @@ class SystemPTPInstanceOutput:
Returns the parameters of the parsed system ptp-instance
Returns:
str : ptp instance parameters
str: ptp instance parameters
Example : 'cmdline_opts=-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24
Example : "cmdline_opts='-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24"
"""
return " ".join(map(lambda parameter: f"'{parameter}'" if " " in parameter else parameter, self.system_ptp_instance_object.get_parameters()))
return repr(" ".join(self.system_ptp_instance_object.get_parameters()))

View File

@@ -1,6 +1,5 @@
from keywords.cloud_platform.system.ptp.objects.system_ptp_interface_list_object import SystemPTPInterfaceListObject
from keywords.cloud_platform.system.system_table_parser import SystemTableParser
from keywords.python.type_converter import TypeConverter
class SystemPTPInterfaceListOutput:
@@ -13,7 +12,7 @@ class SystemPTPInterfaceListOutput:
Constructor
Args:
system_ptp_interface_list_output (str): Output of the system ptp-interface-list command.
system_ptp_interface_list_output (str): Output of the system ptp-interface-list command.
"""
self.system_ptp_interface_list_output: list[SystemPTPInterfaceListObject] = []
system_table_parser = SystemTableParser(system_ptp_interface_list_output)
@@ -21,17 +20,17 @@ class SystemPTPInterfaceListOutput:
for value in output_values:
system_ptp_interface_list_object = SystemPTPInterfaceListObject()
if 'uuid' in value:
system_ptp_interface_list_object.set_uuid(value['uuid'])
if "uuid" in value:
system_ptp_interface_list_object.set_uuid(value["uuid"])
if 'name' in value:
system_ptp_interface_list_object.set_name(value['name'])
if "name" in value:
system_ptp_interface_list_object.set_name(value["name"])
if 'ptp_instance_name' in value:
system_ptp_interface_list_object.set_ptp_instance_name(value['ptp_instance_name'])
if "ptp_instance_name" in value:
system_ptp_interface_list_object.set_ptp_instance_name(value["ptp_instance_name"])
if 'parameters' in value:
system_ptp_interface_list_object.set_parameters(TypeConverter.parse_string_to_list(value['parameters']))
if "parameters" in value:
system_ptp_interface_list_object.set_parameters(eval(value["parameters"]))
self.system_ptp_interface_list_output.append(system_ptp_interface_list_object)
def get_ptp_interface_list(self) -> list[SystemPTPInterfaceListObject]:
@@ -39,20 +38,20 @@ class SystemPTPInterfaceListOutput:
Returns the parsed system ptp-interface-list
Returns:
list[SystemPTPInterfaceListObject] : List representation of system ptp-interface-list objects
list[SystemPTPInterfaceListObject]: List representation of system ptp-interface-list objects
"""
return self.system_ptp_interface_list_output
def get_ptp_interface_parameters(self, ptp_interface_obj : SystemPTPInterfaceListObject) -> str :
def get_ptp_interface_parameters(self, ptp_interface_obj: SystemPTPInterfaceListObject) -> str:
"""
Returns the ptp interface parameters for the specified name
Args:
ptp_interface_obj : PTP interface object
ptp_interface_obj (obj): PTP interface object
Returns:
str : ptp interface parameters
str: ptp interface parameters
Example : 'cmdline_opts=-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24
Example : "cmdline_opts='-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24"
"""
return " ".join(map(lambda parameter: f"'{parameter}'" if " " in parameter else parameter, ptp_interface_obj.get_parameters()))
return repr(" ".join(ptp_interface_obj.get_parameters()))

View File

@@ -14,7 +14,7 @@ class SystemPTPInterfaceOutput:
Constructor
Args:
system_ptp_interface_output (str): Output of the system ptp-interface command.
system_ptp_interface_output (str): Output of the system ptp-interface command.
"""
system_vertical_table_parser = SystemVerticalTableParser(system_ptp_interface_output)
@@ -36,14 +36,14 @@ class SystemPTPInterfaceOutput:
self.system_ptp_interface_object.set_ptp_instance_name(output_values["ptp_instance_name"])
if "parameters" in output_values:
self.system_ptp_interface_object.set_parameters(TypeConverter.parse_string_to_list(output_values["parameters"]))
self.system_ptp_interface_object.set_parameters(eval(output_values["parameters"]))
def get_ptp_interface(self) -> SystemPTPInterfaceObject:
"""
Returns the parsed system ptp-interface
Returns:
SystemPTPInterfaceObject : system ptp-interface object
SystemPTPInterfaceObject: system ptp-interface object
"""
return self.system_ptp_interface_object
@@ -55,7 +55,7 @@ class SystemPTPInterfaceOutput:
hostname (str): Hostname or id
Returns:
list : list representation of matching interface names on specified host
list: list representation of matching interface names on specified host
"""
interface_names = list(filter(lambda interface_name: hostname in interface_name, self.system_ptp_interface_object.get_interface_names()))
@@ -66,8 +66,8 @@ class SystemPTPInterfaceOutput:
Returns the parameters of the parsed ptp-interface-parameter
Returns:
str : ptp interface parameters
str: ptp interface parameters
Example : 'cmdline_opts=-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24
Example : "cmdline_opts='-s xxxx -O -37 -m' boundary_clock_jbod=1 domainNumber=24"
"""
return " ".join(map(lambda parameter: f"'{parameter}'" if " " in parameter else parameter, self.system_ptp_interface_object.get_parameters()))
return repr(" ".join(self.system_ptp_interface_object.get_parameters()))

View File

@@ -1,6 +1,7 @@
from framework.validation.validation import validate_equals
from keywords.base_keyword import BaseKeyword
from keywords.cloud_platform.ssh.lab_connection_keywords import LabConnectionKeywords
from keywords.cloud_platform.system.host.objects.system_host_object import SystemHostObject
from keywords.cloud_platform.system.host.system_host_list_keywords import SystemHostListKeywords
from keywords.cloud_platform.system.ptp.system_host_if_ptp_keywords import SystemHostIfPTPKeywords
from keywords.cloud_platform.system.ptp.system_host_ptp_instance_keywords import SystemHostPTPInstanceKeywords
@@ -25,7 +26,7 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
ssh_connection: An instance of an SSH connection.
"""
def delete_all_ptp_configurations(self):
def delete_all_ptp_configurations(self) -> None:
"""
Delete all PTP configurations
"""
@@ -33,10 +34,11 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
system_ptp_instance_keywords = SystemPTPInstanceKeywords(ssh_connection)
hostnames = SystemHostListKeywords(ssh_connection).get_system_host_list().get_controllers()
for hostname in hostnames:
self.remove_all_interfaces_by_hostname(hostname.get_host_name())
self.remove_all_ptp_instances_by_hostname(hostname.get_host_name())
hostnames = SystemHostListKeywords(ssh_connection).get_system_host_list().get_controllers_and_computes()
self.remove_all_interfaces(hostnames)
self.remove_all_ptp_instances(hostnames)
self.delete_all_ptp_interface_parameters()
@@ -47,14 +49,14 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
self.delete_all_ptp_instances()
system_ptp_instance_output = system_ptp_instance_keywords.get_system_ptp_instance_list()
validate_equals(len(system_ptp_instance_output.get_ptp_instance_list()), 0, "Failed to clean up all PTP configurations")
validate_equals(len(system_ptp_instance_output.get_ptp_instance_list()), 0, "clean up all PTP configurations")
def remove_all_interfaces_by_hostname(self, hostname: str):
def remove_all_interfaces(self, hostnames: list[SystemHostObject]) -> None:
"""
Remove all PTP interfaces on the specified host
Remove all PTP interfaces
Args:
hostname: Hostname or id
hostnames (list): the list of controllers
"""
lab_connect_keywords = LabConnectionKeywords()
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
@@ -67,28 +69,31 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
ptp_interface = ptp_inteface_obj.get_name()
system_ptp_interface_output = system_ptp_interface_keywords.get_system_ptp_interface_show(ptp_interface)
interface_names_on_host = system_ptp_interface_output.get_interface_names_on_host(hostname)
for interface in interface_names_on_host :
system_host_if_ptp_keywords.system_host_if_ptp_remove(hostname, interface, ptp_interface)
for hostname in hostnames:
interface_names_on_host = system_ptp_interface_output.get_interface_names_on_host(hostname.get_host_name())
def remove_all_ptp_instances_by_hostname(self, hostname: str):
for interface in interface_names_on_host:
system_host_if_ptp_keywords.system_host_if_ptp_remove(hostname.get_host_name(), interface, ptp_interface)
def remove_all_ptp_instances(self, hostnames: list[SystemHostObject]) -> None:
"""
Remove all host association
Args:
hostname : hostname or id
hostname (list): the list of controllers
"""
lab_connect_keywords = LabConnectionKeywords()
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
system_host_ptp_instance_keywords = SystemHostPTPInstanceKeywords(ssh_connection)
system_host_ptp_instance_output = system_host_ptp_instance_keywords.get_system_host_ptp_instance_list(hostname)
for hostname in hostnames:
system_host_ptp_instance_output = system_host_ptp_instance_keywords.get_system_host_ptp_instance_list(hostname.get_host_name())
for host_ptp_instance_name_obj in system_host_ptp_instance_output.get_host_ptp_instance():
system_host_ptp_instance_keywords.system_host_ptp_instance_remove(hostname, host_ptp_instance_name_obj.get_name())
for host_ptp_instance_name_obj in system_host_ptp_instance_output.get_host_ptp_instance():
system_host_ptp_instance_keywords.system_host_ptp_instance_remove(hostname.get_host_name(), host_ptp_instance_name_obj.get_name())
def delete_all_ptp_interface_parameters(self):
def delete_all_ptp_interface_parameters(self) -> None:
"""
Delete all ptp interface level parameters
"""
@@ -99,10 +104,10 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
system_ptp_interface_output = system_ptp_interface_keywords.get_system_ptp_interface_list()
for ptp_interface_obj in system_ptp_interface_output.get_ptp_interface_list():
parameters = system_ptp_interface_output.get_ptp_interface_parameters(ptp_interface_obj)
if parameters :
if parameters:
system_ptp_interface_keywords.system_ptp_interface_parameter_delete(ptp_interface_obj.get_name(), parameters)
def delete_all_ptp_interfaces(self):
def delete_all_ptp_interfaces(self) -> None:
"""
Delete all ptp interfaces
"""
@@ -113,7 +118,7 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
for ptp_interface_obj in system_ptp_interface_output:
system_ptp_interface_keywords.system_ptp_interface_delete(ptp_interface_obj.get_name())
def delete_all_ptp_instance_parameters(self):
def delete_all_ptp_instance_parameters(self) -> None:
"""
Delete all parameter to instance
"""
@@ -126,10 +131,10 @@ class PTPTeardownExecutorKeywords(BaseKeyword):
for get_ptp_instance_obj in system_ptp_instance_list_output.get_ptp_instance_list():
system_ptp_instance_show_output = SystemPTPInstanceKeywords(ssh_connection).get_system_ptp_instance_show(get_ptp_instance_obj.get_name())
parameters = system_ptp_instance_show_output.get_ptp_instance_parameters()
if parameters :
if parameters:
system_ptp_instance_parameter_keywords.system_ptp_instance_parameter_delete(get_ptp_instance_obj.get_name(), parameters)
def delete_all_ptp_instances(self):
def delete_all_ptp_instances(self) -> None:
"""
Delete all ptp instances
"""

View File

@@ -9,7 +9,7 @@ from keywords.ptp.cat.objects.transport_options_output import TransportOptionsOu
class CATPtpConfigOutput:
"""
This class parses the output of command cat ' /etc/linuxptp/ptp4l.conf'
This class parses the output of command cat ' /etc/linuxptp/ptpinstance/ptp4l.conf'
Example:
[global]
@@ -147,15 +147,15 @@ class CATPtpConfigOutput:
in_header = False
in_body = False
config_object = ''
config_object = ""
body_str = []
for line in cat_config_output:
if not in_header and line == '#\n':
if not in_header and line == "#\n":
self.create_config_object(config_object, body_str)
in_header = True
elif in_header and line != '#\n':
elif in_header and line != "#\n":
config_object = line.strip()
elif line == '#\n' and in_header: # we are exiting the header
elif line == "#\n" and in_header: # we are exiting the header
in_header = False
in_body = True
# reset the body str
@@ -175,19 +175,19 @@ class CATPtpConfigOutput:
Returns:
"""
if 'Default Data Set' in config_object:
if "Default Data Set" in config_object:
self.data_set_output = DefaultDataSetOutput(body_str)
if 'Port Data Set' in config_object:
if "Port Data Set" in config_object:
self.port_data_set_output = PortDataSetOutput(body_str)
if 'Run time options' in config_object:
if "Run time options" in config_object:
self.run_time_options_output = RunTimeOptionsOutput(body_str)
if 'Servo Options' in config_object:
if "Servo Options" in config_object:
self.servo_options_output = ServoOptionsOutput(body_str)
if 'Transport options' in config_object:
if "Transport options" in config_object:
self.transport_options_output = TransportOptionsOutput(body_str)
if 'Default interface options' in config_object:
if "Default interface options" in config_object:
self.default_interface_options_output = DefaultInterfaceOptionsOutput(body_str)
if 'Clock description' in config_object:
if "Clock description" in config_object:
self.clock_description_output = ClockDescriptionOutput(body_str)
def get_data_set_output(self) -> DefaultDataSetOutput:

View File

@@ -50,7 +50,7 @@
{
name: "phc1",
instance_hostnames : ["controller-0", "controller-1"],
instance_parameters: "'cmdline_opts=-s {{controller_0.nic1.conn_to_spirent}} -O -37 -m'",
instance_parameters: "cmdline_opts='-s {{controller_0.nic1.conn_to_spirent}} -O -37 -m'",
ptp_interface_names: [
"phc1if1",
],

View File

@@ -0,0 +1,240 @@
{
ptp_instances: {
ptp4l: [
{
name: "ptp1",
instance_hostnames : ["controller-0", "controller-1","compute-0"] ,
instance_parameters: "tx_timestamp_timeout=700 domainNumber=24 dataset_comparison=G.8275.x priority2=100 boundary_clock_jbod=1",
ptp_interface_names: [
"ptp1if1",
"ptp1if2",
]
},
{
name: "ptp2",
instance_hostnames : [],
instance_parameters: "dataset_comparison=G.8275.x domainNumber=24 tx_timestamp_timeout=700 boundary_clock_jbod=1 priority2=110",
ptp_interface_names: [
"ptp2if1",
"ptp2if2"
],
},
{
name: "ptp3",
instance_hostnames : ["controller-0"],
instance_parameters: "dataset_comparison=G.8275.x domainNumber=24 tx_timestamp_timeout=700 boundary_clock_jbod=1 priority2=100",
ptp_interface_names: [
"ptp3if1",
"ptp3if2"
],
},
{
name: "ptp4",
instance_hostnames : ["controller-1"],
instance_parameters: "priority2=110 dataset_comparison=G.8275.x domainNumber=24 tx_timestamp_timeout=700 boundary_clock_jbod=1",
ptp_interface_names: [
"ptp4if1",
"ptp4if2"
],
}
],
phc2sys : [
{
name: "phc1",
instance_hostnames : ["controller-0", "controller-1","compute-0"],
instance_parameters: "cmdline_opts='-s {{controller_0.nic1.conn_to_proxmox}} -O -37 -m'",
ptp_interface_names: [
"phc1if1",
],
},
{
name: "phc2",
instance_hostnames : [],
instance_parameters: "uds_address=/var/run/ptp4l-ptp2 domainNumber=24",
ptp_interface_names: [
"phc2if1",
],
},
{
name: "phc3",
instance_hostnames : [],
instance_parameters: "uds_address=/var/run/ptp4l-ptp3 domainNumber=24",
ptp_interface_names: [
"phc3if1",
],
},
{
name: "phc4",
instance_hostnames : [],
instance_parameters: "uds_address=/var/run/ptp4l-ptp4 domainNumber=24",
ptp_interface_names: [
"phc4if1",
],
},
],
ts2phc : [
{
name: "ts1",
instance_hostnames : ["controller-0"],
instance_parameters: "ts2phc.nmea_serialport=/dev/gnss0",
ptp_interface_names: [
"ts1if1",
],
}
],
clock : [
{
name: "clock1",
instance_hostnames : ["controller-0"],
instance_parameters: "",
ptp_interface_names: [
"clock1if1",
"clock1if2",
],
}
],
},
ptp_host_ifs: [
{
name: "ptp1if1",
controller_0_interfaces: ["{{ controller_0.nic1.nic_connection.interface }}"], // Connection to controller1-nic1
controller_1_interfaces: ["{{ controller_1.nic1.nic_connection.interface }}"], // Connection to controller0-nic1
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp1if2",
controller_0_interfaces: ["{{ controller_0.nic1.conn_to_proxmox }}"],
controller_1_interfaces: ["{{ controller_1.nic1.conn_to_proxmox }}"],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp2if1",
controller_0_interfaces: [],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp2if2",
controller_0_interfaces: [],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp3if1",
controller_0_interfaces: ["{{ controller_0.nic2.nic_connection.interface }}"], // Connection to Controller1 Nic 2
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp3if2",
controller_0_interfaces: ["{{ controller_0.nic2.conn_to_proxmox }}"],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp4if1",
controller_0_interfaces: [],
controller_1_interfaces: ["{{ controller_0.nic2.nic_connection.interface }}"], // Connection to Controller1 Nic 2
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "ptp4if2",
controller_0_interfaces: [],
controller_1_interfaces: ["{{ controller_1.nic2.conn_to_proxmox }}"],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "phc1if1",
controller_0_interfaces: [],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "phc2if1",
controller_0_interfaces: [],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "phc3if1",
controller_0_interfaces: [],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "phc4if1",
controller_0_interfaces: [],
controller_1_interfaces: ["{{ controller_1.nic1.base_port }}", "{{ controller_1.nic2.base_port }}"],
compute_0_interfaces: [],
ptp_interface_parameter :"",
},
{
name: "ts1if1",
controller_0_interfaces: ["{{ controller_0.nic1.conn_to_proxmox }}", "{{ controller_0.nic2.base_port }}"],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "",
},
{
name: "clock1if1",
controller_0_interfaces: ["{{ controller_0.nic1.conn_to_proxmox }}"],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "sma1={{ controller_0.nic1.sma1.name }}",
},
{
name: "clock1if2",
controller_0_interfaces: ["{{ controller_0.nic2.base_port }}"],
controller_1_interfaces: [],
compute_0_interfaces: [],
ptp_interface_parameter : "sma1={{ controller_0.nic2.sma1.name }}",
},
],
}

View File

@@ -24,3 +24,22 @@ def test_delete_and_add_all_ptp_configuration():
ptp_setup_template_path = get_stx_resource_path("resources/ptp/setup/ptp_setup_template.json5")
ptp_setup_keywords = PTPSetupExecutorKeywords(ssh_connection, ptp_setup_template_path)
ptp_setup_keywords.add_all_ptp_configurations()
@mark.p0
@mark.lab_has_compute
def test_delete_and_add_all_ptp_configuration_for_compute():
"""
Delete and Add all PTP configurations
"""
lab_connect_keywords = LabConnectionKeywords()
ssh_connection = lab_connect_keywords.get_active_controller_ssh()
get_logger().log_info("Delete all PTP configuration")
ptp_teardown_keywords = PTPTeardownExecutorKeywords(ssh_connection)
ptp_teardown_keywords.delete_all_ptp_configurations()
get_logger().log_info("Add all PTP configuration")
ptp_setup_template_path = get_stx_resource_path("resources/ptp/setup/ptp_setup_template_with_compute.json5")
ptp_setup_keywords = PTPSetupExecutorKeywords(ssh_connection, ptp_setup_template_path)
ptp_setup_keywords.add_all_ptp_configurations()

View File

@@ -29,7 +29,7 @@ def test_generate_ptp_setup_from_template():
phc2sys_setup_list = ptp_setup.get_phc2sys_setup_list()
assert len(phc2sys_setup_list) == 4
phc1 = ptp_setup.get_phc2sys_setup("phc1")
assert phc1.get_instance_parameters() == "'cmdline_opts=-s conn_spirent_placeholder -O -37 -m'"
assert phc1.get_instance_parameters() == "cmdline_opts='-s conn_spirent_placeholder -O -37 -m'"
# ts2phc Validations
ts2phc_setup_list = ptp_setup.get_ts2phc_setup_list()