def _init_thermal_impact(self): """Initialize thermal imact based on the saved inter-connections""" with self._graph_ref.get_session() as session: thermal_sensor_rel_details = GraphReference.get_affected_sensors( session, self._server_key, self._s_name) # for each target & for each set of relationships with the target for target in thermal_sensor_rel_details["targets"]: for rel in target["rel"]: self._launch_thermal_sensor_thread(target["name"], rel["event"]) thermal_storage_rel_details = GraphReference.get_affected_hd_elements( session, self._server_key, self._s_name) for target in thermal_storage_rel_details["targets"]: if "DID" in target and target["DID"]: hd_type = HDComponents.PhysicalDrive hd_element = target["DID"] else: hd_type = HDComponents.CacheVault hd_element = target["serialNumber"] for rel in target["rel"]: self._launch_thermal_storage_thread( target["controller"]["controllerNum"], hd_element, hd_type, rel["event"], ) self._launch_thermal_cpu_thread()
def __str__(self): with self._graph_ref.get_session() as session: thermal_rel = GraphReference.get_affected_sensors( session, self._server_key, self._s_name) s_str = [] s_str.append("[{}/{}]: '{}' located at {};".format( self._s_group, self._s_type, self._s_name, self._s_addr)) # display sensor file location s_str.append(" - Sensor File: '{}'".format( self._get_sensor_file_path())) # print any thermal connections if thermal_rel["targets"]: targets = thermal_rel["targets"] s_str.append(" - Thermal Impact:") # format relationships rfmt = "{:55}".format( "{action} by {degrees}°/{rate} sec on '{event}' event up until {pauseAt}°" ) mfmt = "{:55}".format( "{action} using {model} model every {rate} sec on, limit at {pauseAt}°" ) map_to_rel_format = (lambda r: mfmt.format(**r) if "model" in r else rfmt.format(**r)) tfmt = lambda rel: (" | ").format().join( map(map_to_rel_format, rel)) # add targets & relationships to the output list( map( lambda t: s_str.append(" --> t:[{}] {}".format( t["name"], tfmt(t["rel"]))), targets, )) return "\n".join(s_str)