# File lib/rhc/rest/application.rb, line 84 def add_alias(app_alias) debug "Running add_alias for #{name}" rest_method "ADD_ALIAS", :event => "add-alias", :alias => app_alias end
# File lib/rhc/rest/application.rb, line 26 def add_cartridge(name, timeout=nil) debug "Adding cartridge #{name}" rest_method "ADD_CARTRIDGE", {:name => name}, timeout end
# File lib/rhc/rest/application.rb, line 31 def cartridges debug "Getting all cartridges for application #{name}" rest_method "LIST_CARTRIDGES" end
# File lib/rhc/rest/application.rb, line 68 def destroy debug "Deleting application #{name}" rest_method "DELETE" end
Find Cartridge by name
# File lib/rhc/rest/application.rb, line 95 def find_cartridge(sought, options={}) debug "Finding cartridge #{sought} in app #{name}" type = options[:type] cartridges.each { |cart| return cart if cart.name == sought and (type.nil? or cart.type == type) } suggested_msg = "" valid_cartridges = cartridges.select {|c| type.nil? or c.type == type} unless valid_cartridges.empty? suggested_msg = "\n\nValid cartridges:" valid_cartridges.each { |cart| suggested_msg += "\n#{cart.name}" } end raise RHC::CartridgeNotFoundException.new("Cartridge #{sought} can't be found in application #{name}.#{suggested_msg}") end
Find Cartridges by name or regex
# File lib/rhc/rest/application.rb, line 112 def find_cartridges(name, options={}) if name.is_a?(Hash) options = name name = options[:name] end type = options[:type] regex = options[:regex] debug "Finding cartridge #{name || regex} in app #{@name}" filtered = Array.new cartridges.each do |cart| if regex filtered.push(cart) if cart.name.match(regex) and (type.nil? or cart.type == type) else filtered.push(cart) if cart.name == name and (type.nil? or cart.type == type) end end filtered end
# File lib/rhc/rest/application.rb, line 36 def gear_groups debug "Getting all gear groups for application #{name}" rest_method "GET_GEAR_GROUPS" end
# File lib/rhc/rest/application.rb, line 133 def host @host ||= URI(app_url).host end
# File lib/rhc/rest/application.rb, line 74 def reload debug "Reload application #{name}" rest_method "RELOAD", :event => "reload" end
# File lib/rhc/rest/application.rb, line 89 def remove_alias(app_alias) debug "Running add_alias for #{name}" rest_method "REMOVE_ALIAS", :event => "remove-alias", :alias => app_alias end
# File lib/rhc/rest/application.rb, line 63 def restart debug "Restarting application #{name}" rest_method "RESTART", :event => "restart" end
Query helper to say consistent with cartridge
# File lib/rhc/rest/application.rb, line 15 def scalable? scalable end
# File lib/rhc/rest/application.rb, line 19 def scalable_carts return [] unless scalable? carts = cartridges.select(&:scalable?) scales_with = carts.map(&:scales_with) carts.delete_if{|x| scales_with.include?(x.name)} end
# File lib/rhc/rest/application.rb, line 46 def start debug "Starting application #{name}" rest_method 'START', :event => "start" end
# File lib/rhc/rest/application.rb, line 51 def stop(force=false) debug "Stopping application #{name} force-#{force}" if force payload = {:event=> "force-stop"} else payload = {:event=> "stop"} end rest_method "STOP", payload end
Application log file tailing
# File lib/rhc/rest/application.rb, line 138 def tail(options) debug "Tail in progress for #{name}" file_glob = options.files ? options.files : "#{cartridges.first.name}/logs/*" remote_cmd = "tail#{options.opts ? ' --opts ' + Base64::encode64(options.opts).chomp : ''} #{file_glob}" ssh_cmd = "ssh -t #{uuid}@#{host} '#{remote_cmd}'" begin #Use ssh -t to tail the logs debug ssh_cmd ssh_ruby(host, uuid, remote_cmd) rescue SocketError => e msg ="Could not connect: #{e.message} You can try to run this manually if you have ssh installed: #{ssh_cmd} " debug "DEBUG: #{e.message}\n" raise SocketError, msg end end
# File lib/rhc/rest/application.rb, line 79 def threaddump debug "Running thread dump for #{name}" rest_method "THREAD_DUMP", :event => "thread-dump" end
# File lib/rhc/rest/application.rb, line 41 def tidy debug "Starting application #{name}" rest_method 'TIDY', :event => "tidy" end