Skip to content

Commit

Permalink
fix se bools, avoid mutating se bools in the component
Browse files Browse the repository at this point in the history
  • Loading branch information
emiltin committed Dec 13, 2024
1 parent de86403 commit 48e7b7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/rsmp/site_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions lib/rsmp/supervisor_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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
Expand Down

0 comments on commit 48e7b7d

Please sign in to comment.