Project

General

Profile

Download (1.28 KB) Statistics
| Branch: | Tag: | Revision:

foreman-docker / app / controllers / containers / steps_controller.rb @ 3bc253a2

1
module Containers
2
  class StepsController < ::ApplicationController
3
    include Wicked::Wizard
4

    
5
    steps :preliminary, :image, :configuration, :environment
6
    before_filter :find_container
7

    
8
    def show
9
      case step
10
      when :preliminary
11
        @container_resources = ComputeResource.select { |cr| cr.provider == 'Docker' }
12
      when :image
13
      when :configuration
14
      when :environment
15
      end
16
      render_wizard
17
    end
18

    
19
    def update
20
      case step
21
      when :preliminary
22
        @container.update_attribute(:compute_resource_id, params[:container][:compute_resource_id])
23
      when :image
24
        @container.image = params[:image]
25
        @container.update_attributes(params[:container])
26
      when :configuration
27
        @container.update_attributes(params[:container])
28
      when :environment
29
        @container.update_attributes(params[:container])
30
        start_container
31
      end
32
      render_wizard @container
33
    end
34

    
35
    private
36

    
37
    def allowed_resources
38
      ComputeResource.authorized(:view_compute_resources)
39
    end
40

    
41
    def find_container
42
      @container = Container.find(params[:container_id])
43
    rescue ActiveRecord::RecordNotFound
44
      not_found
45
    end
46

    
47
    def start_container
48
      @container.compute_resource.create_vm(@container.parametrize)
49
    end
50
  end
51
end