smia.utilities.smia_archive_utils module

File to group useful methods for accessing and managing the AAS Archive.

smia.utilities.smia_archive_utils.initialize_smia_archive()[source]

This method initializes the SMIA Archive, performing the necessary actions to let the archive in the initial necessary conditions to start the software.

smia.utilities.smia_archive_utils.safe_open_file(file_path)[source]

This method opens a file in a safe way. If the file does not exist, it will be created, and then opened.

Parameters:

file_path (str) – The path to the file to be opened.

smia.utilities.smia_archive_utils.create_archive_folders()[source]

This method ensures that all main folders of the archive exist, as well ass the parent archive folder.

smia.utilities.smia_archive_utils.create_status_file()[source]

This method creates the status file of the SMIA and sets it to “initializing”. If the file exists because the SMIA has been restarted without terminating the Pod where it is running, the status file will be rewritten.

smia.utilities.smia_archive_utils.create_properties_file()[source]

This method creates the properties file of the SMIA adding default values for each attribute. If the file exists because the SMIA has been restarted without terminating the Pod where it is running, the file will be rewritten.

smia.utilities.smia_archive_utils.create_interaction_files()[source]

This method creates the necessary interaction files to exchange information between AAS Core and AAS Manager.

smia.utilities.smia_archive_utils.create_log_files()[source]

This method creates the necessary log files to save services information.

smia.utilities.smia_archive_utils.save_cli_added_files(init_config=None, aas_model=None)[source]

This method saves the specified files in the Command Line Interface into the SMIA Archive.

Parameters:
  • init_config (str) – path to the initialization configuration properties file.

  • aas_model (str) – path to the AAS model file.

smia.utilities.smia_archive_utils.copy_file_into_archive(source_file, dest_file)[source]

This method copies a file into the SMIA archive.

Parameters:
  • source_file (str) – path of the source file.

  • dest_file (str) – path of the destiny file (it must be inside the SMIA archive).

smia.utilities.smia_archive_utils.get_log_file_by_service_type(log_type, svc_type)[source]

This method obtains the path to the log file associated to the type of the service. :param log_type: the type of the log. :type log_type: str :param svc_type: type of the service. :type svc_type: str

Returns:

path to the log file

Return type:

str

smia.utilities.smia_archive_utils.save_completed_svc_log_info(started_timestamp, finished_timestamp, acl_info, result, svc_type)[source]

This method saves the information about a realized service in the log file associated to the type of the service.

Parameters:
  • started_timestamp (int) – the timestamp when the service has been requested.

  • finished_timestamp (int) – the timestamp when the service has finished.

  • acl_info (dict) – JSON object with the information of the service request.

  • result – the result of the service execution.

  • svc_type (str) – type of the service.

smia.utilities.smia_archive_utils.get_file_by_extension(folder_path, file_extension)[source]

This method obtains the path of a file inside a given folder with a given extension.

Parameters:
  • folder_path (str) – path to the folder to be searched.

  • file_extension (str) – extension of the file (without dot ‘.’).

Returns:

path of the file to search (None if it does not exist).

Return type:

str

smia.utilities.smia_archive_utils.save_svc_error_log_info(occurrence_timestamp, acl_info, reason, svc_type)[source]

This method saves the information about a realized service in the log file associated to the type of the service.

Parameters:
  • occurrence_timestamp (int) – the timestamp when the error occurred.

  • acl_info (dict) – JSON object with the information of the service request.

  • reason (str) – the reason of the error.

  • svc_type (str) – type of the service.

smia.utilities.smia_archive_utils.update_status(new_status)[source]

This method updated the status of an SMIA instance.

Parameters:

new_status (str) – the new status of the SMIA instance.

smia.utilities.smia_archive_utils.get_status(entity)[source]

This method gets the status of the requested entity.

Parameters:

entity (str) – The entity to get the status for.

Returns:

status in JSON format.

Return type:

dict

smia.utilities.smia_archive_utils.check_core_initialization()[source]

This method checks if the core has initialized so the Manager can be started.

smia.utilities.smia_archive_utils.file_to_json(file_path)[source]

This method gets the content of a JSON file.

Parameters:

file_path (str) – the path of the JSON file.

Returns:

content of the file in JSON format.

Return type:

dict

smia.utilities.smia_archive_utils.update_json_file(file_path, content)[source]

This method updates the content of a JSON file.

Parameters:
  • file_path (str) – the path to the JSON file.

  • content (dict) – the content of the JSON file.

smia.utilities.smia_archive_utils.xml_to_file(file_path, xml_content)[source]

This method writes the content of an XML in a file.

Parameters:
  • file_path (str) – the path to the XML file.

  • xml_content (bytes) – the content of the XML file.