class RHC::Rest::Cartridge

Attributes

current_scale[R]
name[R]
properties[R]
scales_from[R]
scales_to[R]
scales_with[R]
status_messages[R]
type[R]

Public Class Methods

new(args, use_debug=false) click to toggle source
# File lib/rhc/rest/cartridge.rb, line 7
def initialize(args, use_debug=false)
  @properties = {}
  props = args[:properties] || args["properties"] || []
  props.each do |p|
    category = @properties[:"#{p['type']}"] || {}
    category[:"#{p['name']}"] = p
    @properties[:"#{p['type']}"] = category
  end

  super
end

Public Instance Methods

connection_info() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 66
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
delete() click to toggle source
Alias for: destroy
destroy() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 54
def destroy
  debug "Deleting cartridge #{name}"
  rest_method "DELETE"
end
Also aliased as: delete
property(category, key) click to toggle source
# File lib/rhc/rest/cartridge.rb, line 23
def property(category, key)
  category = properties[category]
  category ? category[key] : nil
end
reload() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 49
def reload
  debug "Reloading cartridge #{name}"
  rest_method "RESTART", :event => "reload"
end
restart() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 44
def restart
  debug "Restarting cartridge #{name}"
  rest_method "RESTART", :event => "restart"
end
scalable?() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 19
def scalable?
  [scales_to,scales_from].map{|x| x > 1 || x == -1}.inject(:|)
end
set_scales(values) click to toggle source
# File lib/rhc/rest/cartridge.rb, line 60
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
start() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 34
def start
  debug "Starting cartridge #{name}"
  rest_method "START", :event => "start"
end
status() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 28
def status
  debug "Getting cartridge #{name}'s status"
  result = rest_method "GET", :include => "status_messages"
  result.status_messages
end
stop() click to toggle source
# File lib/rhc/rest/cartridge.rb, line 39
def stop()
  debug "Stopping cartridge #{name}"
  rest_method "STOP", :event => "stop"
end