class Crowbar::Client::Command::Server::Check

Implementation for the server check command

Public Instance Methods

execute() click to toggle source
# File lib/crowbar/client/command/server/check.rb, line 34
def execute
  request.process do |request|
    formatter = Formatter::Array.new(
      format: provide_format,
      headings: ["Errors"],
      values: Filter::Array.new(
        filter: provide_filter,
        values: content_from(request)
      ).result
    )

    case request.code
    when 200
      if formatter.empty?
        say "Crowbar is in a sane state"
      else
        say formatter.result
      end
    when 409
      err "Could not perform sanity checks: #{request.parsed_response["error"]}"
    else
      err request.parsed_response["error"]
    end
  end
end
request() click to toggle source
# File lib/crowbar/client/command/server/check.rb, line 28
def request
  @request ||= Request::Server::Check.new(
    args
  )
end

Protected Instance Methods

content_from(request) click to toggle source
# File lib/crowbar/client/command/server/check.rb, line 62
def content_from(request)
  [].tap do |row|
    request.parsed_response.each do |child|
      row.push(
        child
      )
    end
  end
end