Class: Actions::Katello::ContentView::Publish
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::ContentView::Publish
- Extended by:
- ApipieDSL::Class
- Includes:
- JailConcern::ContentView, JailConcern::Organization, ObservableAction, Katello::ContentViewHelper
- Defined in:
- app/lib/actions/katello/content_view/publish.rb
Defined Under Namespace
Classes: Jail
Instance Attribute Summary collapse
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #content_view_version_id ⇒ Object
- #content_view_version_name ⇒ Object
- #finalize ⇒ Object
- #history_id ⇒ Object
- #humanized_name ⇒ Object
-
#plan(content_view, description = "", options = {importing: false, syncable: false}) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity.
- #rescue_strategy_for_self ⇒ Object
- #run ⇒ Object
- #trigger_capsule_sync(_execution_plan) ⇒ Object
Methods included from JailConcern::ContentView
#content_view_id, #content_view_label, #content_view_name, included
Methods included from JailConcern::Organization
included, #organization_id, #organization_label, #organization_name
Methods included from Katello::ContentViewHelper
Instance Attribute Details
#version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 8 def version @version end |
Instance Method Details
#content_view_version_id ⇒ Object
134 135 136 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 134 def content_view_version_id input['content_view_version_id'] end |
#content_view_version_name ⇒ Object
138 139 140 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 138 def content_view_version_name input['content_view_version_name'] end |
#finalize ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 110 def finalize version = ::Katello::ContentViewVersion.find(input[:content_view_version_id]) version.update_content_counts! # update errata applicability counts for all hosts in the CV & Library unless input[:skip_promotion] environment = ::Katello::KTEnvironment.find(input[:environment_id]) ::Katello::ContentView.find(input[:content_view_id]).update_host_statuses(environment) end history = ::Katello::ContentViewHistory.find(input[:history_id]) history.status = ::Katello::ContentViewHistory::SUCCESSFUL history.save! end |
#history_id ⇒ Object
142 143 144 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 142 def history_id input['history_id'] end |
#humanized_name ⇒ Object
92 93 94 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 92 def humanized_name _("Publish") end |
#plan(content_view, description = "", options = {importing: false, syncable: false}) ⇒ Object
rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 12 def plan(content_view, description = "", = {importing: false, syncable: false}) # rubocop:disable Metrics/PerceivedComplexity action_subject(content_view) content_view.check_ready_to_publish!(.slice(:importing, :syncable)) unless [:importing] || [:syncable] ::Katello::Util::CandlepinRepositoryChecker.check_repositories_for_publish!(content_view) end if [:repos_units].present? valid_labels_from_cv = content_view.repositories.map(&:label) labels_from_repos_units = [:repos_units].map { |repo| repo[:label] } labels_from_repos_units.each do |label| fail _("Repository label '%s' is not associated with content view.") % label unless valid_labels_from_cv.include? label end valid_labels_from_cv.each do |label| fail _("Content view has repository label '%s' which is not specified in repos_units parameter.") % label unless labels_from_repos_units.include? label end end # Add non-override components back in [:override_components] = include_other_components([:override_components], content_view) version = version_for_publish(content_view, ) self.version = version library = content_view.organization.library history = ::Katello::ContentViewHistory.create!(:content_view_version => version, :user => ::User.current.login, :status => ::Katello::ContentViewHistory::IN_PROGRESS, :action => ::Katello::ContentViewHistory.actions[:publish], :task => self.task, :notes => description, :triggered_by => [:triggered_by] ) source_repositories = [] content_view.publish_repositories([:override_components]) do |repositories| source_repositories += [repositories] end sequence do plan_action(ContentView::AddToEnvironment, version, library) unless [:skip_promotion] repository_mapping = plan_action(ContentViewVersion::CreateRepos, version, source_repositories).repository_mapping # Split Pulp 3 Yum repos out of the repository_mapping. Only Pulp 3 RPM plugin has multi repo copy support. separated_repo_map = separated_repo_mapping(repository_mapping, content_view.solve_dependencies) if [:importing] handle_import(version, .slice(:path, :metadata)) elsif separated_repo_map[:pulp3_yum_multicopy].keys.flatten.present? plan_action(Repository::MultiCloneToVersion, separated_repo_map[:pulp3_yum_multicopy], version) end concurrence do source_repositories.each do |repositories| sequence do if ![:importing] && repositories.present? && separated_repo_map[:other].keys.include?(repositories) plan_action(Repository::CloneToVersion, repositories, version, repository_mapping[repositories], :repos_units => [:repos_units]) end plan_action(Repository::CloneToEnvironment, repository_mapping[repositories], library) unless [:skip_promotion] end end repos_to_delete(content_view).each do |repo| plan_action(Repository::Destroy, repo, :skip_environment_update => true) end end plan_action(Candlepin::Environment::SetContent, content_view, library, content_view.content_view_environment(library)) unless [:skip_promotion] plan_action(Katello::Foreman::ContentUpdate, library, content_view) unless [:skip_promotion] plan_action(ContentView::ErrataMail, content_view, library) unless [:skip_promotion] plan_action(ContentView::Promote, version, find_environments([:environment_ids]), [:is_force_promote]) if [:environment_ids]&.any? plan_self(history_id: history.id, content_view_id: content_view.id, auto_publish_composite_ids: auto_publish_composite_ids(content_view), content_view_version_name: version.name, content_view_version_id: version.id, environment_id: library.id, user_id: ::User.current.id, skip_promotion: [:skip_promotion]) end end |
#rescue_strategy_for_self ⇒ Object
106 107 108 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 106 def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end |
#run ⇒ Object
96 97 98 99 100 101 102 103 104 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 96 def run version = ::Katello::ContentViewVersion.find(input[:content_view_version_id]) version.auto_publish_composites! output[:content_view_id] = input[:content_view_id] output[:content_view_version_id] = input[:content_view_version_id] output[:skip_promotion] = input[:skip_promotion] output[:history_id] = input[:history_id] end |
#trigger_capsule_sync(_execution_plan) ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'app/lib/actions/katello/content_view/publish.rb', line 124 def trigger_capsule_sync(_execution_plan) environment = ::Katello::KTEnvironment.find(input[:environment_id]) view = ::Katello::ContentView.find(input[:content_view_id]) if SmartProxy.sync_needed?(environment) && !input[:skip_promotion] ForemanTasks.async_task(ContentView::CapsuleSync, view, environment) end end |