Class: Actions::Staypuft::Host::Deploy
- Inherits:
-
Dynflow::Action
- Object
- Dynflow::Action
- Actions::Staypuft::Host::Deploy
- Defined in:
- app/lib/actions/staypuft/host/deploy.rb
Instance Method Summary collapse
Instance Method Details
#plan(host, check_success = true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/lib/actions/staypuft/host/deploy.rb', line 18 def plan(host, check_success = true) Type! host, ::Host::Base input.update host: { id: host.id, name: host.name } sequence do puppet_run = plan_action Host::PuppetRun, host plan_action Host::ReportWait, host.id, puppet_run.output[:executed_at] if check_success plan_action Host::AssertReportSuccess, host.id end end end |
#task_output ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/lib/actions/staypuft/host/deploy.rb', line 32 def task_output steps = planned_actions(Host::ReportWait).inject([]) { |s, a| s + a.steps[1..2] }.compact progress = if steps.empty? 1 else total = steps.map { |s| s.progress_done * s.progress_weight }.reduce(&:+) weighted_count = steps.map(&:progress_weight).reduce(&:+) total / weighted_count end input[:host].merge progress: progress end |