def embed_cartridge_post
raise OpenShift::UserException.new("Invalid user", 99) if @cloud_user.nil?
app = get_app_from_request(@cloud_user)
check_cartridge_type(@req.cartridge, "embedded")
if ['deconfigure', 'start', 'stop', 'restart', 'status', 'reload'].include?(@req.action) and ( app.embedded.nil? or not app.embedded.has_key?(@req.cartridge) )
raise OpenShift::UserException.new("The application #{app.name} is not configured with the embedded cartridge #{@req.cartridge}.", 129)
end
Rails.logger.debug "DEBUG: Performing action '#{@req.action}'"
case @req.action
when 'configure'
if app.scalable && (@cloud_user.consumed_gears >= @cloud_user.max_gears) && @req.cartridge != 'jenkins-client-1.4'
raise OpenShift::UserException.new("#{@login} has already reached the gear limit of #{@cloud_user.max_gears}", 104)
end
@reply.append app.add_dependency(@req.cartridge)
when 'deconfigure'
@reply.append app.remove_dependency(@req.cartridge)
when 'start'
@reply.append app.start(@req.cartridge)
when 'stop'
@reply.append app.stop(@req.cartridge)
when 'restart'
@reply.append app.restart(@req.cartridge)
when 'status'
@reply.append app.status(@req.cartridge)
when 'reload'
@reply.append app.reload(@req.cartridge)
else
raise OpenShift::UserException.new("Invalid action #{@req.action}", 111)
end
log_action(@request_id, @cloud_user.uuid, @login, "LEGACY_EMBED_CARTRIDGE_POST", true, "Processed event #{@req.action} for cartridge #{@req.cartridge} of application #{app.name}")
@reply.resultIO << 'Success' if @reply.resultIO.length == 0
render :json => @reply
end