module Chef::Knife::Cloud::Helpers
Public Instance Methods
after_exec_command()
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 41 def after_exec_command; end
before_exec_command()
click to toggle source
Derived classes can override before_exec_command
and after_exec_command
# File lib/chef/knife/cloud/helpers.rb, line 39 def before_exec_command; end
create_service_instance()
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 30 def create_service_instance raise Chef::Exceptions::Override, "You must override create_service_instance in #{self} to create cloud specific service" end
execute_command()
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 34 def execute_command raise Chef::Exceptions::Override, "You must override execute_command in #{self}" end
msg_pair(label, value, color = :cyan)
click to toggle source
Additional helpers
# File lib/chef/knife/cloud/helpers.rb, line 24 def msg_pair(label, value, color = :cyan) if value && !value.to_s.empty? puts "#{ui.color(label, color)}: #{value}" end end
pretty_key(key)
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 58 def pretty_key(key) key.to_s.tr("_", " ").gsub(/\w+/) { |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize } end
set_default_config()
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 43 def set_default_config; end
validate!(*keys)
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 45 def validate!(*keys) # validates necessary options/params to carry out the command. # subclasses to implement this. errors = [] keys.each do |k| errors << "You did not provide a valid '#{pretty_key(k)}' value." if config[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!()
click to toggle source
# File lib/chef/knife/cloud/helpers.rb, line 56 def validate_params!; end