Skip to content

Commit

Permalink
Fixes & improvements for servers:yaml rake task (#1056)
Browse files Browse the repository at this point in the history
* use string keys over symbols in hash produced by servers:yaml task, such that YAML.safe_load consumes it correctly (with default arguments), and for better human write-/readability

* fix 'enabled' value in servers:yaml output

* fix server.enabled? in servers:yaml[verbose]

* fix logic mistake which prevented state 'cordoned' to be outputted in output of servers:yaml[verbose]
  • Loading branch information
Ithanil authored Apr 5, 2024
1 parent e5ecdae commit e93f3f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/server_sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ def self.sync(servers, mode = 'cordon', dryrun = false)
def self.dump(verbose)
Server.all.to_h do |server|
info = {
url: server.url,
secret: server.secret,
load_multiplier: server.load_multiplier.to_f || 1.0,
enabled: server.enabled,
"url" => server.url,
"secret" => server.secret,
"load_multiplier" => server.load_multiplier.to_f || 1.0,
"enabled" => server.enabled?,
}
if verbose
info[:state] = server.state.presence || server.enabled ? 'enabled' : 'disabled'
info[:load] = server.load.presence || -1.0
info[:online] = server.online
info["state"] = server.state.presence || (server.enabled? ? 'enabled' : 'disabled')
info["load"] = server.load.presence || -1.0
info["online"] = server.online
end
[server.id, info]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/servers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ namespace :servers do

desc 'Return a yaml compatible with servers:sync'
task :yaml, [:verbose] => :environment do |_t, args|
puts({ servers: ServerSync.dump(!!args.verbose) }.to_yaml)
puts({ "servers" => ServerSync.dump(!!args.verbose) }.to_yaml)
end

desc('List all meetings running in specific BigBlueButton servers')
Expand Down

0 comments on commit e93f3f7

Please sign in to comment.