Class: Actions::Katello::ContentView::Publish

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

Instance Method Summary collapse

Instance Method Details

#finalizeObject



61
62
63
64
65
# File 'app/lib/actions/katello/content_view/publish.rb', line 61

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

#humanized_nameObject



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

def humanized_name
  _("Publish")
end

#plan(content_view, description = "") ⇒ Object

rubocop:disable MethodLength



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
40
41
42
43
44
45
# File 'app/lib/actions/katello/content_view/publish.rb', line 8

def plan(content_view, description = "")
  action_subject(content_view)
  content_view.check_ready_to_publish!
  version = content_view.create_new_version(description)
  library = content_view.organization.library

  history = ::Katello::ContentViewHistory.create!(:content_view_version => version, :user => ::User.current.,
                                                  :status => ::Katello::ContentViewHistory::IN_PROGRESS, :task => self.task)

  sequence do
    plan_action(ContentView::AddToEnvironment, version, library)
    concurrence do
      content_view.repositories_to_publish.each do |repository|
        sequence do
          clone_to_version = plan_action(Repository::CloneToVersion, repository, version)
          plan_action(Repository::CloneToEnvironment, clone_to_version.new_repository, library)
        end
      end

      sequence do
        has_modules = content_view.puppet_modules.any? || content_view.components.any? { |component| component.puppet_modules.any? }
        plan_action(ContentViewPuppetEnvironment::CreateForVersion, version)
        plan_action(ContentViewPuppetEnvironment::Clone, version, :environment => library,
                    :puppet_modules_present => has_modules)
      end

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

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

#rescue_strategy_for_selfObject



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

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

#runObject



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

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