From e93f3f71204713d9256caac79e49797a39975205 Mon Sep 17 00:00:00 2001 From: Jan Kessler Date: Fri, 5 Apr 2024 18:15:54 +0200 Subject: [PATCH] Fixes & improvements for servers:yaml rake task (#1056) * 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] --- lib/server_sync.rb | 14 +++++++------- lib/tasks/servers.rake | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/server_sync.rb b/lib/server_sync.rb index 39367b00..1b644fc6 100644 --- a/lib/server_sync.rb +++ b/lib/server_sync.rb @@ -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 diff --git a/lib/tasks/servers.rake b/lib/tasks/servers.rake index 1e396dc4..e0c0108b 100644 --- a/lib/tasks/servers.rake +++ b/lib/tasks/servers.rake @@ -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')