• Kirill Smelkov's avatar
    promise/plugin/*: Do not replace ' -> " in input JSON data · b067cc0e
    Kirill Smelkov authored
    Adjust promises correspondingly to slapos!1447
    which changed ors-amarisoft software-release to emit log payload via
    json.dumps instead of py %s.
    
    Do this for both promises code and JSON-loading utilities in slapos/promise/plugin/util.py also used inside ORS promises code.
    We can adjust the utilities because there are two of them (get_json_log_data_interval and get_json_log_latest_timestamp) with
    get_json_log_latest_timestamp being used only in ORS-promises:
    
        slapos.toolbox$ git grep get_json_log_latest_timestamp
        slapos/promise/plugin/check_amarisoft_stats_log.py:from .util import get_json_log_latest_timestamp
        slapos/promise/plugin/check_amarisoft_stats_log.py:    latest_timestamp = get_json_log_latest_timestamp(self.amarisoft_stats_log)
        slapos/promise/plugin/util.py:def get_json_log_latest_timestamp(json_log_file):
    
    and get_json_log_data_interval being used in ORS promises and
    check_cpu_temperature, check_network_transit and check_ram_usage:
    
        slapos.toolbox$ git grep get_json_log_data_interval
        slapos/promise/plugin/check_baseband_latency.py:from .util import get_json_log_data_interval
        slapos/promise/plugin/check_baseband_latency.py:    data_list = get_json_log_data_interval(self.amarisoft_stats_log, self.stats_period * 5)
        slapos/promise/plugin/check_cpu_temperature.py:      temp_list = self.get_json_log_data_interval(self.avg_temp_duration)
        slapos/promise/plugin/check_network_transit.py:      temp_list = self.get_json_log_data_interval(self.transit_period)
        slapos/promise/plugin/check_ram_usage.py:      temp_list = self.get_json_log_data_interval(self.avg_ram_period)
        slapos/promise/plugin/check_rx_saturated.py:from .util import get_json_log_data_interval
        slapos/promise/plugin/check_rx_saturated.py:    data_list = get_json_log_data_interval(self.amarisoft_stats_log, self.stats_period * 2)
        slapos/promise/plugin/util.py:def get_json_log_data_interval(json_log_file, interval):
        slapos/promise/plugin/util.py:  def get_json_log_data_interval(self, interval):
        slapos/promise/plugin/util.py:    return get_json_log_data_interval(self.__json_log_file, interval)
    
    However all check_cpu_temperature, check_network_transit and
    check_ram_usage produce their *.json.log files themselves and already
    emit `data` via json.dumps:
    
    https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_cpu_temperature.py#L41-54
    https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_network_transit.py#L29-42
    https://lab.nexedi.com/nexedi/slapos.toolbox/blob/453dce5f/slapos/promise/plugin/check_ram_usage.py#L34-46
    
    So it is safe to adjust the utilities.
    b067cc0e