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
71
72
|
# File 'lib/chef/knife/cloud/command.rb', line 71
def after_exec_command
end
|
#before_exec_command ⇒ Object
Derived classes can override before_exec_command and after_exec_command
68
69
|
# File 'lib/chef/knife/cloud/command.rb', line 68
def before_exec_command
end
|
#create_service_instance ⇒ Object
59
60
61
|
# File 'lib/chef/knife/cloud/command.rb', line 59
def create_service_instance
raise Chef::Exceptions::Override, "You must override create_service_instance in #{self} to create cloud specific service"
end
|
#execute_command ⇒ Object
63
64
65
|
# File 'lib/chef/knife/cloud/command.rb', line 63
def execute_command
raise Chef::Exceptions::Override, "You must override execute_command in #{self}"
end
|
#pretty_key(key) ⇒ Object
91
92
93
|
# File 'lib/chef/knife/cloud/command.rb', line 91
def pretty_key(key)
key.to_s.tr("_", " ").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
|
# File 'lib/chef/knife/cloud/command.rb', line 31
def run
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
|
#set_default_config ⇒ Object
74
75
|
# File 'lib/chef/knife/cloud/command.rb', line 74
def set_default_config
end
|
#validate!(*keys) ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/chef/knife/cloud/command.rb', line 77
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
88
89
|
# File 'lib/chef/knife/cloud/command.rb', line 88
def validate_params!
end
|