Project

General

Profile

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

foreman_pipeline / app / lib / actions / foreman_pipeline / job / deploy_new_host.rb @ 91959835

1
module Actions
2
  module ForemanPipeline
3
    module Job
4
      class DeployNewHost < Actions::EntryAction
5
        include Mixins::UriExtension
6
        middleware.use ::Actions::Middleware::KeepCurrentUser
7

    
8
        def plan(job)          
9
          sequence do
10
            redeploy = plan_action(Redeploy, job)    
11
                
12
            plan_action(Jenkins::WaitHostReady, :host_ip => redeploy.output[:host][:ip],
13
                                                :jenkins_instance_hostname => jenkins_hostname(job),
14
                                                :jenkins_home => job.jenkins_instance.jenkins_home,
15
                                                :cert_path => job.jenkins_instance.cert_path)
16
            
17
            # h = { :host => {
18
            #         :id => "random_number",
19
            #         :name => "dummy host",
20
            #         :ip => "192.168.100.103",
21
            #         :mac => " 01:23:45:67:89:ab",
22
            #         :params => ["host_params_empty"]
23
            #       },
24
            #       :activation_key => {
25
            #           :cp_id => 544553785444,
26
            #       },                  
27
            # }
28

    
29
            packages = plan_action(FindPackagesToInstall, :job_id => job.id)
30

    
31

    
32
            bulk_build = plan_action(Jenkins::BulkBuild, 
33
                                      job.jenkins_projects,
34
                                      :job_id => job.id,
35
                                      :data => redeploy.output,
36
                                      :packages => packages.output[:package_names])
37
            plan_action(Promote, :job_id => job.id, :build_fails => bulk_build.output[:failed_count])            
38
          end
39
        end
40
      end
41
    end
42
  end
43
end