Class: Chef::Knife::Cloud::ServerShowCommand
- Inherits:
-
Command
show all
- Defined in:
- lib/chef/knife/cloud/server/show_command.rb
Instance Attribute Summary
Attributes inherited from Command
#custom_arguments, #service
Instance Method Summary
collapse
Methods inherited from Command
#run
Methods included from Helpers
#after_exec_command, #before_exec_command, #create_service_instance, #msg_pair, #pretty_key, #set_default_config, #validate!
Constructor Details
26
27
28
29
30
|
# File 'lib/chef/knife/cloud/server/show_command.rb', line 26
def initialize(argv = [])
super argv
@columns_with_info = []
end
|
Instance Method Details
#execute_command ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# 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! ⇒ Object
32
33
34
35
36
37
38
39
40
|
# 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
|