Class: ForemanOpenstackCluster::ClustersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_openstack_cluster/clusters_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/foreman_openstack_cluster/clusters_controller.rb', line 19

def create
  if params[:foreman_openstack_cluster_cluster][:public_subnet]
    @pub_s  = Subnet.new(params[:foreman_openstack_cluster_cluster][:public_subnet])
    @pub_s.save!   # Replace these with proper error handling...
  end

  if params[:foreman_openstack_cluster_cluster][:private_subnet]
    @priv_s = Subnet.new(params[:foreman_openstack_cluster_cluster][:private_subnet])
    @priv_s.save!
  end

  @cluster = Cluster.new(params['foreman_openstack_cluster_cluster'])
  if @cluster.save
    setup_quickstack @cluster.hostgroup, @cluster.name, @cluster.environment, "quickstack::controller"
    setup_quickstack @cluster.hostgroup, @cluster.name, @cluster.environment, "quickstack::compute"
    process_success({:success_redirect => hostgroups_path})
  else
    process_error :render => 'foreman_openstack_cluster/clusters/new', :object => @cluster
  end
end

#newObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/foreman_openstack_cluster/clusters_controller.rb', line 6

def new
  not_found and return unless ( @controller_class && @compute_class )

  # Setup the override keys on the classes ahead of time
  set_keys(@controller_class)
  set_keys(@compute_class)

  @cluster = Cluster.new
  Cluster.params.each do |k,v|
    @cluster.send("#{k}=",v[:default])
  end
end