# File lib/rhc/commands/cartridge.rb, line 25 def add(cart_type) cart = find_cartridge rest_client, cart_type say "Adding '#{cart.name}' to application '#{options.app}'" rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(options.app) rest_cartridge = rest_app.add_cartridge(cart.name) say "Success" display_cart(rest_cartridge,rest_cartridge.properties[:cart_data]) 0 end
# File lib/rhc/commands/cartridge.rb, line 13 def list carts = rest_client.find_cartridges(:type => 'embedded').collect { |c| c.name } results { say "#{carts.join(', ')}" } 0 end
# File lib/rhc/commands/cartridge.rb, line 141 def reload(cartridge) cartridge_action cartridge, :reload results { say "#{cartridge} config reloaded!" } 0 end
# File lib/rhc/commands/cartridge.rb, line 62 def remove(cartridge) unless options.confirm results { say "Removing a cartridge is a destructive operation that may result in loss of data associated with the cartridge. You must pass the --confirm switch to this command in order to to remove the cartridge." } return 1 end rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(options.app) rest_cartridge = rest_app.find_cartridge cartridge, :type => "embedded" rest_cartridge.destroy results { say "Success: Cartridge '#{rest_cartridge.name}' removed from application '#{rest_app.name}'." } 0 end
# File lib/rhc/commands/cartridge.rb, line 109 def restart(cartridge) cartridge_action cartridge, :restart results { say "#{cartridge} restarted!" } 0 end
# File lib/rhc/commands/cartridge.rb, line 156 def scale(cartridge) raise RHC::MissingScalingValueException unless options.min || options.max rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(options.app) rest_cartridge = find_cartridge rest_app, cartridge, nil raise RHC::CartridgeNotScalableException unless rest_cartridge.scalable? cart = rest_cartridge.set_scales({ :scales_from => options.min, :scales_to => options.max }) results do say "Success: Scaling values updated" display_cart(cart) end 0 end
# File lib/rhc/commands/cartridge.rb, line 45 def show(cartridge) rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(options.app) rest_cartridge = find_cartridge rest_app, cartridge, nil display_cart(rest_cartridge,rest_cartridge.properties[:cart_data]) 0 end
# File lib/rhc/commands/cartridge.rb, line 83 def start(cartridge) cartridge_action cartridge, :start results { say "#{cartridge} started!" } 0 end
# File lib/rhc/commands/cartridge.rb, line 122 def status(cartridge) rest_domain = rest_client.find_domain(options.namespace) rest_app = rest_domain.find_application(options.app) rest_cartridge = find_cartridge(rest_app, cartridge) msgs = rest_cartridge.status results { msgs.each do |msg| say msg['message'] end } 0 end
# File lib/rhc/commands/cartridge.rb, line 96 def stop(cartridge) cartridge_action cartridge, :stop results { say "#{cartridge} stopped!" } 0 end