Class: ScalingController

Inherits:
ConsoleController show all
Defined in:
app/controllers/scaling_controller.rb

Instance Method Summary collapse

Methods inherited from ConsoleController

#active_tab

Methods included from SshkeyAware

#sshkey_uploaded?

Methods included from DomainAware

#domain_is_missing, #user_default_domain

Methods included from CapabilityAware

#user_capabilities

Instance Method Details

#deleteObject



18
19
20
21
22
# File 'app/controllers/scaling_controller.rb', line 18

def delete
  user_default_domain
  @application = @domain.find_application params[:application_id]
  redirect_to new_application_scaling_path(@application) unless @application.scales?
end

#newObject



11
12
13
14
15
16
# File 'app/controllers/scaling_controller.rb', line 11

def new
  user_default_domain
  @application = @domain.find_application params[:application_id]
  @cartridge_type = CartridgeType.cached.find 'haproxy-1.4'
  @cartridge = Cartridge.new :name => @cartridge_type.name
end

#showObject



3
4
5
6
7
8
9
# File 'app/controllers/scaling_controller.rb', line 3

def show
  user_default_domain
  @application = @domain.find_application params[:application_id]
  @cartridges = @application.cartridges
  @user = User.find :one, :as => current_user
  redirect_to new_application_scaling_path(@application) unless @application.scales?
end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/scaling_controller.rb', line 24

def update
  user_default_domain
  @user = User.find :one, :as => current_user
  @application = @domain.find_application params[:application_id]
  @cartridges = @application.cartridges
  @cartridge = @cartridges.find{ |c| c.name == params[:id] } or raise RestApi::ResourceNotFound.new(Cartridge.model_name, params[:id])

  range = [params[:cartridge][:scales_from].to_i, params[:cartridge][:scales_to].to_i]
  range.reverse! if range.first > range.last && range.last != -1
  @cartridge.scales_from, @cartridge.scales_to = range

  if @cartridge.save
    redirect_to application_scaling_path, :flash => {:success => "Updated scale settings for cartridge '#{@cartridge.display_name}'"}
  else
    render :show
  end
end