Class: HammerCLIForeman::CommandExtensions::Ping

Inherits:
HammerCLI::CommandExtensions
  • Object
show all
Defined in:
lib/hammer_cli_foreman/command_extensions/ping.rb

Class Method Summary collapse

Class Method Details

.check_for_unrecognized(plugins, output_definition) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hammer_cli_foreman/command_extensions/ping.rb', line 13

def self.check_for_unrecognized(plugins, output_definition)
  failed = plugins.select { |_, data| data['services'] }
                  .each_with_object([]) { |(_, d), s| s << d['services'] }
                  .reduce({}, :merge)
                  .select do |name, data|
    begin
      output_definition.find_field(name)
      false
    rescue ArgumentError
      data['status'] == _('FAIL')
    end
  end
  return if failed.empty?

  warn [_('%{count} more service(s) failed, but not shown:') % { count: failed.size },
        failed.keys.join(', '),
        ''].join("\n")
end

.failed?(services) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/hammer_cli_foreman/command_extensions/ping.rb', line 32

def self.failed?(services)
  services['foreman']['database']['active'] == 'FAIL' ||
    services.each_value.any? { |s| s['status'] == _('FAIL') }
end