class Crowbar::Client::Command::Node::Status

Implementation for the node status command

Public Instance Methods

execute() click to toggle source
# File lib/crowbar/client/command/node/status.rb, line 34
def execute
  request.process do |request|
    case request.code
    when 200
      formatter = Formatter::Hash.new(
        format: provide_format,
        headings: ["Name", "Status"],
        values: Filter::Hash.new(
          filter: provide_filter,
          values: content_from(request)
        ).result
      )

      if formatter.empty?
        err "No nodes"
      else
        say formatter.result
      end
    else
      err request.parsed_response["error"]
    end
  end
end
request() click to toggle source
# File lib/crowbar/client/command/node/status.rb, line 28
def request
  @request ||= Request::Node::Status.new(
    args
  )
end

Protected Instance Methods

content_from(request) click to toggle source
# File lib/crowbar/client/command/node/status.rb, line 60
def content_from(request)
  [].tap do |row|
    request.parsed_response["nodes"].each do |name, value|
      next if value["status"] == "Ready" && !options["ready"]

      row.push(
        name: name,
        status: value["status"]
      )
    end
  end
end