Class: Actions::Staypuft::Deployment::Populate

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/staypuft/deployment/populate.rb

Overview

TODO remove, it’s temporary

Instance Method Summary collapse

Instance Method Details

#humanized_inputObject



47
48
49
# File 'app/lib/actions/staypuft/deployment/populate.rb', line 47

def humanized_input
  "#{input[:deployment_name]} #{input[:fake] ? 'fake' : 'real'}"
end

#plan(deployment, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/lib/actions/staypuft/deployment/populate.rb', line 21

def plan(deployment, options = {})
  Type! deployment, ::Staypuft::Deployment

  fake   = options[:fake].nil? ? false : options[:fake]
  assign = options[:assign].nil? ? false : options[:assign]
  Type! fake, TrueClass, FalseClass

  compute_resource = options[:compute_resource] ||= ::Foreman::Model::Libvirt.first
  Type! compute_resource, *[ComputeResource, (NilClass if fake)].compact

  sequence do

    hostgroups = deployment.child_hostgroups
    hostgroups.each do |hostgroup|
      plan_action Actions::Staypuft::Host::Create,
                  "host-#{rand(1000).to_s}",
                  hostgroup,
                  compute_resource,
                  start:  false,
                  assign: assign,
                  fake:   fake
    end
  end
end