in src/core/src/service_interfaces/StatusHandler.py [0:0]
def __init__(self, env_layer, execution_config, composite_logger, telemetry_writer, vm_cloud_type):
# Map supporting components for operation
self.env_layer = env_layer
self.execution_config = execution_config
self.composite_logger = composite_logger
self.telemetry_writer = telemetry_writer # not used immediately but need to know if there are issues persisting status
self.complete_status_file_path = self.execution_config.complete_status_file_path
self.status_file_path = self.execution_config.status_file_path
self.__log_file_path = self.execution_config.log_file_path
self.vm_cloud_type = vm_cloud_type
# Status components
self.__high_level_status_message = ""
# Internal in-memory representation of Patch Installation data
self.__installation_substatus_json = None
self.__installation_summary_json = None
self.__installation_packages = []
self.__installation_errors = []
self.__installation_total_error_count = 0 # All errors during install, includes errors not in error objects due to size limit
self.__maintenance_window_exceeded = False
self.__installation_reboot_status = Constants.RebootStatus.NOT_NEEDED
self.__installation_packages_map = collections.OrderedDict()
self.__installation_substatus_msg_copy = None # store copy of message json for truncation and avoid reference modification
self.__installation_patches_copy = [] # store copy of installation patches for truncation and avoid reference modification
self.__installation_patches_removed = [] # store truncated patches for tombstone and logging
# Internal in-memory representation of Patch Assessment data
self.__assessment_substatus_json = None
self.__assessment_summary_json = None
self.__assessment_packages = []
self.__assessment_errors = []
self.__assessment_total_error_count = 0 # All errors during assess, includes errors not in error objects due to size limit
self.__assessment_packages_map = collections.OrderedDict()
self.__assessment_substatus_msg_copy = None # store copy of message json for truncation and avoid reference modification
self.__assessment_patches_copy = [] # store copy of assessment patches for truncation and avoid reference modification
self.__assessment_patches_removed = [] # store truncated patches for tombstone and logging
# Internal in-memory representation of Patch Metadata for HealthStore
self.__metadata_for_healthstore_substatus_json = None
self.__metadata_for_healthstore_summary_json = None
self.__report_to_healthstore = False
self.__patch_version = Constants.PATCH_VERSION_UNKNOWN
# Internal in-memory representation of Configure Patching data
self.__configure_patching_substatus_json = None
self.__configure_patching_summary_json = None
self.__configure_patching_errors = []
self.__configure_patching_top_level_error_count = 0 # All errors during configure patching (excluding auto-assessment), includes errors not in error objects due to size limit
self.__configure_patching_auto_assessment_errors = []
self.__configure_patching_auto_assessment_error_count = 0 # All errors relating to auto-assessment configuration.
# Load the currently persisted status file into memory
self.load_status_file_components(initial_load=True)
# Tracker for reboot pending status, the value is updated externally(PatchInstaller.py) whenever package is installed. As this var is directly written in status file, setting the default to False, instead of Empty/Unknown, to maintain a true bool field as per Agent team's architecture
self.is_reboot_pending = False
# Discovers OS name and version for package id composition
self.__os_name_and_version = self.get_os_name_and_version()
self.__current_operation = None
self.__truncation_timestamp = datetime.datetime(1971, 1, 1, 0, 0, 0) # January 1, 1971, 00:00:00, to allow truncation on upcoming operation when timestamp > 60 sec (tentatively)
self.__truncated_status_file_json_dumps = None # To keep status file truncated (not overwritten) when timestamp < 60 sec (tentatively)
self.__force_truncation_on = False # When true apply truncation ignore track timestamp during terminal state operation
# Update patch metadata summary in status for auto patching installation requests, to be reported to healthstore
if (execution_config.maintenance_run_id is not None or execution_config.health_store_id is not None) and execution_config.operation.lower() == Constants.INSTALLATION.lower():
if self.__installation_reboot_status != Constants.RebootStatus.STARTED:
self.set_patch_metadata_for_healthstore_substatus_json(report_to_healthstore=True, wait_after_update=True)
# updating metadata summary again with reporting to healthstore turned off
self.set_patch_metadata_for_healthstore_substatus_json(report_to_healthstore=False, wait_after_update=False)
else:
self.composite_logger.log_debug("Since this is the previous patch operation re-triggered after a reboot, healthstore has the operation commencement details. "
"So, not sending another report to healthstore")
# Enable reboot completion status capture
if self.__installation_reboot_status == Constants.RebootStatus.STARTED:
self.set_installation_reboot_status(Constants.RebootStatus.COMPLETED) # switching to completed after the reboot