# File lib/rhc/rest/application.rb, line 195 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 109 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(cart, options={}) debug "Adding cartridge #{name}" clear_attribute :cartridges rest_method( "ADD_CARTRIDGE", if cart.is_a? String {:name => cart} elsif cart.respond_to? :[] cart else cart.url ? {:url => cart.url} : {:name => cart.name} end, options ) end
# File lib/rhc/rest/application.rb, line 123 def aliases debug "Getting all aliases for application #{name}" @aliases ||= begin aliases = attributes['aliases'] if aliases.nil? or not aliases.is_a?(Array) supports?('LIST_ALIASES') ? rest_method("LIST_ALIASES") : [] else aliases.map do |a| Alias.new(a.is_a?(String) ? {'id' => a} : a, client) end end end end
# File lib/rhc/rest/application.rb, line 40 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 93 def destroy debug "Deleting application #{name}" rest_method "DELETE" end
# File lib/rhc/rest/application.rb, line 137 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 149 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 166 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(/(?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 54 def gear_groups debug "Getting all gear groups for application #{name}" rest_method "GET_GEAR_GROUPS" end
# File lib/rhc/rest/application.rb, line 50 def gear_info { :gear_count => gear_count, :gear_profile => gear_profile } unless gear_count.nil? end
# File lib/rhc/rest/application.rb, line 59 def gear_ssh_url(gear_id) gear = gear_groups.map { |group| group.gears }.flatten.find { |g| g['id'] == gear_id } raise ArgumentError.new("Gear #{gear_id} not found") if gear.nil? gear['ssh_url'] or raise OperationNotSupportedException.new("The server does not support per gear operations") end
# File lib/rhc/rest/application.rb, line 187 def host @host ||= URI.parse(app_url).host rescue nil end
# File lib/rhc/rest/application.rb, line 99 def reload debug "Reload application #{name}" rest_method "RELOAD", :event => "reload" end
# File lib/rhc/rest/application.rb, line 114 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 88 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 191 def ssh_string RHC::Helpers.ssh_string(ssh_url) end
# File lib/rhc/rest/application.rb, line 71 def start debug "Starting application #{name}" rest_method 'START', :event => "start" end
# File lib/rhc/rest/application.rb, line 76 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 104 def threaddump debug "Running thread dump for #{name}" rest_method "THREAD_DUMP", :event => "thread-dump" end
# File lib/rhc/rest/application.rb, line 66 def tidy debug "Starting application #{name}" rest_method 'TIDY', :event => "tidy" end