# File lib/rhc/rest/application.rb, line 206 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 120 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 cart = if cart.is_a? String {:name => cart} elsif cart.respond_to? :[] cart else cart.url ? {:url => cart.url} : {:name => cart.name} end if cart.respond_to?(:[]) and cart[:url] and !has_param?('ADD_CARTRIDGE', 'url') raise RHC::Rest::DownloadingCartridgesNotSupported, "The server does not support downloading cartridges." end rest_method( "ADD_CARTRIDGE", cart, options ) end
# File lib/rhc/rest/application.rb, line 134 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 47 def cartridges @cartridges ||= unless (carts = attributes['cartridges']).nil? carts.map{|x| Cartridge.new(x, client) } else debug "Getting all cartridges for application #{name}" rest_method "LIST_CARTRIDGES" end end
# File lib/rhc/rest/application.rb, line 104 def destroy debug "Deleting application #{name}" rest_method "DELETE" end
# File lib/rhc/rest/application.rb, line 148 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.downcase } 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 160 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 177 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 61 def gear_groups debug "Getting all gear groups for application #{name}" rest_method "GET_GEAR_GROUPS" end
# File lib/rhc/rest/application.rb, line 57 def gear_info { :gear_count => gear_count, :gear_profile => gear_profile } unless gear_count.nil? end
# File lib/rhc/rest/application.rb, line 70 def gear_ssh_url(gear_id) gear = gears.find{ |g| g['id'] == gear_id } raise ArgumentError, "Gear #{gear_id} not found" if gear.nil? gear['ssh_url'] or raise NoPerGearOperations end
# File lib/rhc/rest/application.rb, line 66 def gears gear_groups.map{ |group| group.gears }.flatten end
# File lib/rhc/rest/application.rb, line 198 def host @host ||= URI.parse(app_url).host rescue nil end
# File lib/rhc/rest/application.rb, line 110 def reload debug "Reload application #{name}" rest_method "RELOAD", :event => "reload" end
# File lib/rhc/rest/application.rb, line 125 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 99 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 202 def ssh_string RHC::Helpers.ssh_string(ssh_url) end
# File lib/rhc/rest/application.rb, line 82 def start debug "Starting application #{name}" rest_method 'START', :event => "start" end
# File lib/rhc/rest/application.rb, line 87 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 115 def threaddump debug "Running thread dump for #{name}" rest_method "THREAD_DUMP", :event => "thread-dump" end
# File lib/rhc/rest/application.rb, line 77 def tidy debug "Starting application #{name}" rest_method 'TIDY', :event => "tidy" end