# File lib/rhc/rest/application.rb, line 178 def <=>(other) c = name.downcase <=> other.name.downcase return c unless c == 0 domain_id <=> other.domain_id end
# File lib/rhc/rest/application.rb, line 93 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 24 def add_cartridge(name, options={}) debug "Adding cartridge #{name}" @cartridges = nil attributes['cartridges'] = nil rest_method "ADD_CARTRIDGE", {:name => name}, options end
# File lib/rhc/rest/application.rb, line 107 def aliases debug "Getting all aliases for application #{name}" if (client.api_version_negotiated >= 1.4) rest_method "LIST_ALIASES" else attributes['aliases'] end end
# File lib/rhc/rest/application.rb, line 31 def cartridges debug "Getting all cartridges for application #{name}" @cartridges ||= unless (carts = attributes['cartridges']).nil? carts.map{|x| Cartridge.new(x, client) } else rest_method "LIST_CARTRIDGES" end end
# File lib/rhc/rest/application.rb, line 77 def destroy debug "Deleting application #{name}" rest_method "DELETE" end
# File lib/rhc/rest/application.rb, line 116 def find_alias(name, options={}) debug "Finding alias #{name} in app #{@name}" if name.is_a?(Hash) options = name name = options[:name] end aliases.each { |a| return a if a.is_a?(String) || a.id == name } raise RHC::AliasNotFoundException.new("Alias #{name} can't be found in application #{@name}.") end
Find Cartridge by name
# File lib/rhc/rest/application.rb, line 128 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 145 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(%r(?i:#{regex})/) and (type.nil? or cart.type == type) else filtered.push(cart) if cart.name.downcase == name.downcase and (type.nil? or cart.type == type) end end filtered end
# File lib/rhc/rest/application.rb, line 45 def gear_groups debug "Getting all gear groups for application #{name}" rest_method "GET_GEAR_GROUPS" end
# File lib/rhc/rest/application.rb, line 41 def gear_info { :gear_count => gear_count, :gear_profile => gear_profile } unless gear_count.nil? end
# File lib/rhc/rest/application.rb, line 166 def host @host ||= URI.parse(app_url).host rescue nil end
# File lib/rhc/rest/application.rb, line 83 def reload debug "Reload application #{name}" rest_method "RELOAD", :event => "reload" end
# File lib/rhc/rest/application.rb, line 98 def remove_alias(app_alias) debug "Running remove_alias for #{name}" if (client.api_version_negotiated >= 1.4) find_alias(app_alias).destroy else rest_method "REMOVE_ALIAS", :event => "remove-alias", :alias => app_alias end end
# File lib/rhc/rest/application.rb, line 72 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 13 def scalable? scalable end
# File lib/rhc/rest/application.rb, line 17 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 170 def ssh_string uri = URI.parse(ssh_url) "#{uri.user}@#{uri.host}" rescue => e RHC::Helpers.debug_error(e) ssh_url end
# File lib/rhc/rest/application.rb, line 55 def start debug "Starting application #{name}" rest_method 'START', :event => "start" end
# File lib/rhc/rest/application.rb, line 60 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
# File lib/rhc/rest/application.rb, line 88 def threaddump debug "Running thread dump for #{name}" rest_method "THREAD_DUMP", :event => "thread-dump" end
# File lib/rhc/rest/application.rb, line 50 def tidy debug "Starting application #{name}" rest_method 'TIDY', :event => "tidy" end