Class: Staypuft::StepsController

Inherits:
ApplicationController show all
Includes:
Wicked::Wizard
Defined in:
app/controllers/staypuft/steps_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/staypuft/steps_controller.rb', line 8

def show
  case step
  when :deployment_settings
    @layouts = ordered_layouts
  when :services_overview
    if @deployment.cinder.lvm_ptable.nil?
      flash[:warning] = "Missing Partition Table 'LVM with cinder-volumes', LVM cinder backend won't work." 
    end
  when :network_configuration
    @subnets = Subnet.search_for(params[:search], :order => params[:order]).includes(:domains, :dhcp).paginate :page => params[:page]
  when :services_configuration
    @services_map = [:nova, :neutron, :glance, :cinder]
  end

  render_wizard
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/staypuft/steps_controller.rb', line 25

def update
  case step

  when :deployment_settings
    @layouts               = ordered_layouts
    # FIXME: validate that deployment is valid when leaving wizard with cancel button
    @deployment.form_step  = Deployment::STEP_SETTINGS
    @deployment.passwords.attributes = params[:staypuft_deployment].delete(:passwords)
    @deployment.attributes = params[:staypuft_deployment]

    # we don't care too much whether pxe network was detected or all typings were saved since it's
    # just a helper for user to have all types preassigned to pxe network
    pxe_network = Subnet.where('dhcp_id IS NOT NULL').first
    if pxe_network
      @deployment.unassigned_pxe_default_subnet_types.each do |type|
        @deployment.subnet_typings.new(:subnet_id => pxe_network.id, :subnet_type_id => type.id).save
      end
    end

  when :services_overview
    @deployment.form_step = Deployment::STEP_OVERVIEW

  when :services_configuration
    @services_map = [:nova, :neutron, :glance, :cinder]
    if params[:staypuft_deployment]
      @deployment.form_step = Deployment::STEP_CONFIGURATION
      @services_map.each do |service|
        @deployment.send(service).attributes = params[:staypuft_deployment].delete(service)
      end
    end
  when :network_configuration
    @deployment.form_step = Deployment::STEP_NETWORKING
    @subnets = Subnet.search_for(params[:search], :order => params[:order]).includes(:domains, :dhcp).paginate :page => params[:page]
    @deployment.build_vips(NetworkQuery::VIP_NAMES) if @deployment.valid?
  else
    raise 'unknown step'
  end

  render_wizard @deployment
end