# File lib/rhc/rest/cartridge.rb, line 145 def self.for_url(url) new 'url' => url end
# File lib/rhc/rest/cartridge.rb, line 129 def <=>(other) return -1 if other.type == 'standalone' && type != 'standalone' return 1 if type == 'standalone' && other.type != 'standalone' name <=> other.name end
# File lib/rhc/rest/cartridge.rb, line 37 def additional_gear_storage attribute(:additional_gear_storage).to_i rescue 0 end
# File lib/rhc/rest/cartridge.rb, line 29 def collocated_with Array(attribute(:collocated_with)) end
# File lib/rhc/rest/cartridge.rb, line 124 def connection_info info = property(:cart_data, :connection_url) || property(:cart_data, :job_url) || property(:cart_data, :monitoring_url) info ? (info["value"] || '').rstrip : nil end
# File lib/rhc/rest/cartridge.rb, line 14 def custom? url.present? end
# File lib/rhc/rest/cartridge.rb, line 107 def destroy debug "Deleting cartridge #{name}" rest_method "DELETE" end
# File lib/rhc/rest/cartridge.rb, line 41 def display_name attribute(:display_name) || name || url_basename end
# File lib/rhc/rest/cartridge.rb, line 22 def only_in_existing? type == 'embedded' end
# File lib/rhc/rest/cartridge.rb, line 18 def only_in_new? type == 'standalone' end
# File lib/rhc/rest/cartridge.rb, line 76 def property(type, key) key, type = key.to_s, type.to_s properties.select{ |p| p['type'] == type }.find{ |p| p['name'] == key } end
# File lib/rhc/rest/cartridge.rb, line 102 def reload debug "Reloading cartridge #{name}" rest_method "RESTART", :event => "reload" end
# File lib/rhc/rest/cartridge.rb, line 97 def restart debug "Restarting cartridge #{name}" rest_method "RESTART", :event => "restart" end
# File lib/rhc/rest/cartridge.rb, line 10 def scalable? supported_scales_to != supported_scales_from end
# File lib/rhc/rest/cartridge.rb, line 67 def scaling { :current_scale => current_scale, :scales_from => scales_from, :scales_to => scales_to, :gear_profile => gear_profile, } if scalable? end
# File lib/rhc/rest/cartridge.rb, line 113 def set_scales(values) values.delete_if{|k,v| v.nil? } debug "Setting scales = %s" % values.map{|k,v| "#{k}: #{v}"}.join(" ") rest_method "UPDATE", values end
# File lib/rhc/rest/cartridge.rb, line 119 def set_storage(values) debug "Setting additional storage: #{values[:additional_gear_storage]}GB" rest_method "UPDATE", values end
Use this value when the user should interact with this cart via CLI arguments
# File lib/rhc/rest/cartridge.rb, line 48 def short_name name || url end
# File lib/rhc/rest/cartridge.rb, line 87 def start debug "Starting cartridge #{name}" rest_method "START", :event => "start" end
# File lib/rhc/rest/cartridge.rb, line 81 def status debug "Getting cartridge #{name}'s status" result = rest_method "GET", :include => "status_messages" result.status_messages end
# File lib/rhc/rest/cartridge.rb, line 92 def stop debug "Stopping cartridge #{name}" rest_method "STOP", :event => "stop" end
# File lib/rhc/rest/cartridge.rb, line 135 def url_basename uri = URI.parse(url) name = uri.fragment name = Rack::Utils.parse_nested_query(uri.query)['name'] if name.blank? && uri.query name = File.basename(uri.path) if name.blank? && uri.path.present? && uri.path != '/' name.presence || url rescue url end
# File lib/rhc/rest/cartridge.rb, line 57 def usage_rate rate = attribute(:usage_rate_usd) if attribute(:usage_rates) rate ||= attribute(:usage_rates).inject(0) { |total, rate| total + rate['usd'].to_f } end rate.to_f rescue 0.0 end
# File lib/rhc/rest/cartridge.rb, line 52 def usage_rate? rate = usage_rate rate && rate > 0.0 end