class Chef::Knife::Cloud::ServerShowCommand

Public Class Methods

new(argv = []) click to toggle source
Calls superclass method
# File lib/chef/knife/cloud/server/show_command.rb, line 26
def initialize(argv = [])
  super argv
  # columns_with_info is array of hash with label, key and attribute extraction callback, ex [{:label => "Label text", :key => 'key', value_callback => callback_method to extract/format the required value}, ...]
  @columns_with_info = []
end

Public Instance Methods

execute_command() click to toggle source
# File lib/chef/knife/cloud/server/show_command.rb, line 42
def execute_command
  server = service.get_server(config[:instance_id])
  if server.nil?
    error_message = "Server doesn't exists for this #{config[:instance_id]} instance id."
    ui.error(error_message)
    raise CloudExceptions::ServerShowError, error_message
  else
    service.server_summary(server, @columns_with_info)
  end
end
validate_params!() click to toggle source
# File lib/chef/knife/cloud/server/show_command.rb, line 32
def validate_params!
  errors = []
  config[:instance_id] = @name_args.first
  if config[:instance_id].nil?
    errors << "You must provide a valid Instance Id"
  end
  error_message = ""
  raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
end