Class: Actions::Katello::ContentView::Promote

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/content_view/promote.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



55
56
57
58
59
# File 'app/lib/actions/katello/content_view/promote.rb', line 55

def finalize
  history = ::Katello::ContentViewHistory.find(input[:history_id])
  history.status = ::Katello::ContentViewHistory::SUCCESSFUL
  history.save!
end

#humanized_nameObject



41
42
43
# File 'app/lib/actions/katello/content_view/promote.rb', line 41

def humanized_name
  _("Promotion")
end

#plan(version, environment, is_force = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/lib/actions/katello/content_view/promote.rb', line 7

def plan(version, environment, is_force = false)
  action_subject(version.content_view)
  version.check_ready_to_promote!(environment)

  fail ::Katello::HttpErrors::BadRequest, _("Cannot promote environment out of sequence. Use force to bypass restriction.") if !is_force && !version.promotable?(environment)

  history = ::Katello::ContentViewHistory.create!(:content_view_version => version, :user => ::User.current.,
                                                  :environment => environment, :task => self.task,
                                                  :status => ::Katello::ContentViewHistory::IN_PROGRESS)
  sequence do
    plan_action(ContentView::AddToEnvironment, version, environment)
    concurrence do
      version.archived_repos.non_puppet.each do |repository|
        sequence do
          plan_action(Repository::CloneToEnvironment, repository, environment)
        end
      end

      plan_action(ContentViewPuppetEnvironment::Clone, version, :environment => environment,
                  :puppet_modules_present => version.puppet_module_count > 0)

      repos_to_delete(version, environment).each do |repo|
        plan_action(Repository::Destroy, repo, :skip_environment_update => true, :planned_destroy => true)
      end
    end

    plan_action(ContentView::UpdateEnvironment, version.content_view, environment)
    plan_action(Katello::Foreman::ContentUpdate, environment, version.content_view)
    plan_action(ContentView::ErrataMail, version.content_view, environment)
    plan_self(history_id: history.id, environment_id: environment.id, user_id: ::User.current.id,
              environment_name: environment.name, content_view_id: version.content_view.id)
  end
end

#rescue_strategy_for_selfObject



51
52
53
# File 'app/lib/actions/katello/content_view/promote.rb', line 51

def rescue_strategy_for_self
  Dynflow::Action::Rescue::Skip
end

#runObject



45
46
47
48
49
# File 'app/lib/actions/katello/content_view/promote.rb', line 45

def run
  ForemanTasks.async_task(ContentView::CapsuleGenerateAndSync,
                          ::Katello::ContentView.find(input[:content_view_id]),
                          ::Katello::KTEnvironment.find(input[:environment_id]))
end