Class: Chef::Knife::Cloud::Command
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Helpers
#locate_config_value, #msg_pair
Instance Attribute Details
#custom_arguments ⇒ Object
Returns the value of attribute custom_arguments.
29
30
31
|
# File 'lib/chef/knife/cloud/command.rb', line 29
def custom_arguments
@custom_arguments
end
|
#service ⇒ Object
Returns the value of attribute service.
29
30
31
|
# File 'lib/chef/knife/cloud/command.rb', line 29
def service
@service
end
|
Instance Method Details
#after_exec_command ⇒ Object
73
74
|
# File 'lib/chef/knife/cloud/command.rb', line 73
def after_exec_command
end
|
#before_exec_command ⇒ Object
Derived classes can override before_exec_command and after_exec_command
70
71
|
# File 'lib/chef/knife/cloud/command.rb', line 70
def before_exec_command
end
|
#create_service_instance ⇒ Object
61
62
63
|
# File 'lib/chef/knife/cloud/command.rb', line 61
def create_service_instance
raise Chef::Exceptions::Override, "You must override create_service_instance in #{self.to_s} to create cloud specific service"
end
|
#execute_command ⇒ Object
65
66
67
|
# File 'lib/chef/knife/cloud/command.rb', line 65
def execute_command
raise Chef::Exceptions::Override, "You must override execute_command in #{self.to_s}"
end
|
#pretty_key(key) ⇒ Object
93
94
95
|
# File 'lib/chef/knife/cloud/command.rb', line 93
def pretty_key(key)
key.to_s.gsub(/_/, ' ').gsub(/\w+/){ |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize }
end
|
#run ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/chef/knife/cloud/command.rb', line 31
def run
begin
set_default_config
validate!
validate_params!
@service = create_service_instance
service.ui = ui
before_exec_command
execute_command
after_exec_command
rescue CloudExceptions::KnifeCloudError => e
Chef::Log.debug(e.message)
exit 1
end
end
|
#set_default_config ⇒ Object
76
77
|
# File 'lib/chef/knife/cloud/command.rb', line 76
def set_default_config
end
|
#validate!(*keys) ⇒ Object
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/chef/knife/cloud/command.rb', line 79
def validate!(*keys)
errors = []
keys.each do |k|
errors << "You did not provide a valid '#{pretty_key(k)}' value." if locate_config_value(k).nil?
end
error_message = ""
raise CloudExceptions::ValidationError, error_message if errors.each{|e| ui.error(e); error_message = "#{error_message} #{e}."}.any?
end
|
#validate_params! ⇒ Object
90
91
|
# File 'lib/chef/knife/cloud/command.rb', line 90
def validate_params!
end
|