From 2a737ac4c90753020ef7d990dd7fe0ebaa3553ce Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Fri, 13 Dec 2024 13:19:58 +0100 Subject: [PATCH] fix se bools, avoid mutating se bools in the component --- lib/rsmp/site_proxy.rb | 2 +- lib/rsmp/supervisor_proxy.rb | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/rsmp/site_proxy.rb b/lib/rsmp/site_proxy.rb index 527ad26..bbca79d 100644 --- a/lib/rsmp/site_proxy.rb +++ b/lib/rsmp/site_proxy.rb @@ -137,7 +137,7 @@ def validate_aggregated_status message, se def process_aggregated_status message se = message.attribute("se") - validate_aggregated_status(message,se) == false + validate_aggregated_status(message,se) c_id = message.attributes["cId"] component = find_component c_id unless component diff --git a/lib/rsmp/supervisor_proxy.rb b/lib/rsmp/supervisor_proxy.rb index 1f6cecf..6817e4e 100644 --- a/lib/rsmp/supervisor_proxy.rb +++ b/lib/rsmp/supervisor_proxy.rb @@ -172,19 +172,24 @@ def version_accepted message def send_aggregated_status component, options={} m_id = options[:m_id] || RSMP::Message.make_m_id + + # For core <=3.1.2, se items must be send as strings + # For core > 3.1.2, se items must be send as booleans + if Proxy::version_meets_requirement?(core_version,"<=3.1.2") + se = component.aggregated_status_bools.map {|bool| bool ? "true" : "false"} + else + se = component.aggregated_status_bools + end + message = AggregatedStatus.new({ "aSTS" => clock.to_s, "cId" => component.c_id, "fP" => nil, "fS" => nil, - "se" => component.aggregated_status_bools, + "se" => se, "mId" => m_id, }) - # Core 3.1.2 or earlier requires that se items to be send as strings - if Proxy::version_meets_requirement?(core_version,"<=3.1.2") - message.attributes["se"].map! {|bool| bool ? "true" : "false"} - end set_nts_message_attributes message send_and_optionally_collect message, options do |collect_options| @@ -200,7 +205,7 @@ def send_alarm component, alarm, options={} def process_aggregated_status message se = message.attribute("se") - validate_aggregated_status(message,se) == false + validate_aggregated_status(message,se) on = set_aggregated_status se log "Received #{message.type} status [#{on.join(', ')}]", message: message, level: :log acknowledge message