Class: Chef::Knife::Cloud::ServerShowCommand
- Inherits:
-
Command
- Object
- Chef::Knife
- Command
- Chef::Knife::Cloud::ServerShowCommand
- Defined in:
- lib/chef/knife/cloud/server/show_command.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #execute_command ⇒ Object
-
#initialize(argv = []) ⇒ ServerShowCommand
constructor
A new instance of ServerShowCommand.
- #validate_params! ⇒ Object
Methods inherited from Command
Methods included from Helpers
#after_exec_command, #before_exec_command, #create_service_instance, #msg_pair, #pretty_key, #set_default_config, #validate!
Constructor Details
#initialize(argv = []) ⇒ ServerShowCommand
Returns a new instance of ServerShowCommand.
26 27 28 29 30 |
# 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 |
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? = "Server doesn't exists for this #{config[:instance_id]} instance id." ui.error() raise CloudExceptions::ServerShowError, 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 = "" raise CloudExceptions::ValidationError, if errors.each { |e| ui.error(e); = "#{} #{e}." }.any? end |