Class: Actions::ForemanPatch::Cycle::PrepareContent

Inherits:
EntryAction
  • Object
show all
Includes:
Katello::ContentViewHelper
Defined in:
app/lib/actions/foreman_patch/cycle/prepare_content.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



59
60
61
62
63
64
# File 'app/lib/actions/foreman_patch/cycle/prepare_content.rb', line 59

def finalize
  new_version.update_content_counts!

  history.status = ::Katello::ContentViewHistory::SUCCESSFUL
  history.save!
end

#humanized_nameObject



7
8
9
# File 'app/lib/actions/foreman_patch/cycle/prepare_content.rb', line 7

def humanized_name
  _('Minor Version Update')
end

#new_versionObject



66
67
68
# File 'app/lib/actions/foreman_patch/cycle/prepare_content.rb', line 66

def new_version
  @new_version ||= ::Katello::ContentViewVersion.find(input[:new_version_id])
end

#plan(old_version, description) ⇒ Object



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
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/lib/actions/foreman_patch/cycle/prepare_content.rb', line 11

def plan(old_version, description)
  action_subject(old_version.content_view)

  new_minor = old_version.content_view.versions.where(major: old_version.major).maximum(:minor) + 1

  components = []

  sequence do
    if old_version.content_view.composite?
      components = update_components(old_version.components, description)
    end

    new_version = old_version.content_view.create_new_version(old_version.major, new_minor, components)

    history = ::Katello::ContentViewHistory.create!(content_view_version: new_version,
                                                    user: ::User.current.,
                                                    action: ::Katello::ContentViewHistory.actions[:publish],
                                                    status: ::Katello::ContentViewHistory::IN_PROGRESS,
                                                    task: self.task,
                                                    notes: description)

    repositories = collect_repositories(old_version, components)

    repository_mapping = plan_action(Actions::Katello::ContentViewVersion::CreateRepos,
                                     new_version, repositories).repository_mapping

    separated_repo_map = separated_repo_mapping(repository_mapping, true)

    if separated_repo_map[:pulp3_yum_multicopy].keys.flatten.present? &&
        SmartProxy.pulp_primary.pulp3_support?(separated_repo_map[:pulp3_yum_multicopy].keys.flatten.first)
      
      plan_action(Actions::Katello::Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum_multicopy], new_version)
    end

    concurrence do
      repositories.each do |repository|
        plan_action(Actions::Katello::Repository::CloneToVersion,
                    repository, new_version, repository_mapping[repository])
      end
    end

    plan_self(new_version_id: new_version.id,
              history_id: history.id,
              old_version_id: old_version.id)
    plan_action(Actions::Katello::ContentView::Promote, new_version, old_version.environments, true)
  end
end