Class: Actions::Katello::ContentViewVersion::IncrementalUpdate
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::ContentViewVersion::IncrementalUpdate
- Defined in:
- app/lib/actions/katello/content_view_version/incremental_update.rb
Instance Attribute Summary collapse
-
#new_content_view_version ⇒ Object
Returns the value of attribute new_content_view_version.
Instance Method Summary collapse
-
#calculate_components(old_version, new_components) ⇒ Object
given a composite version, and a list of new components, calculate the list of all components for the new version.
-
#components_repo_instance(repo, component_versions) ⇒ Object
for a given repo, find its instance out of a list of content view versions.
- #copy_repo(source_repo, new_version, content, dep_solve) ⇒ Object
- #finalize ⇒ Object
- #humanized_name ⇒ Object
- #plan(old_version, environments, options = {}) ⇒ Object
- #repos_to_copy(old_version, components) ⇒ Object
- #run ⇒ Object
Instance Attribute Details
#new_content_view_version ⇒ Object
Returns the value of attribute new_content_view_version.
5 6 7 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 5 def new_content_view_version @new_content_view_version end |
Instance Method Details
#calculate_components(old_version, new_components) ⇒ Object
given a composite version, and a list of new components, calculate the list of all components for the new version
109 110 111 112 113 114 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 109 def calculate_components(old_version, new_components) old_components = old_version.components.select do |component| !new_components.map(&:content_view_id).include?(component.content_view_id) end old_components + new_components end |
#components_repo_instance(repo, component_versions) ⇒ Object
for a given repo, find its instance out of a list of content view versions. Since these versions
are all part of a composite, there should only be one
69 70 71 72 73 74 75 76 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 69 def components_repo_instance(repo, component_versions) possible_repos = component_versions.map do |cvv| cvv.repositories.select do |component_repo| component_repo.library_instance_id == repo.library_instance_id end end possible_repos.flatten.first end |
#copy_repo(source_repo, new_version, content, dep_solve) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 55 def copy_repo(source_repo, new_version, content, dep_solve) copy_output = [] sequence do new_repo = plan_action(Repository::CloneToVersion, source_repo, new_version, true).new_repository copy_output = copy_yum_content(new_repo, dep_solve, content[:package_ids], content[:errata_ids]) plan_action(Katello::Repository::MetadataGenerate, new_repo, nil) plan_action(Katello::Repository::IndexContent, id: new_repo.id) end copy_output end |
#finalize ⇒ Object
102 103 104 105 106 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 102 def finalize history = ::Katello::ContentViewHistory.find(input[:history_id]) history.status = ::Katello::ContentViewHistory::SUCCESSFUL history.save! end |
#humanized_name ⇒ Object
7 8 9 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 7 def humanized_name _("Incremental Update") end |
#plan(old_version, environments, options = {}) ⇒ 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 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 11 def plan(old_version, environments, = {}) dep_solve = .fetch(:resolve_dependencies, false) description = .fetch(:description, '') content = .fetch(:content, {}) new_components = .fetch(:new_components, []) is_composite = old_version.content_view.composite? all_components = is_composite ? calculate_components(old_version, new_components) : [] action_subject(old_version.content_view) validate_environments(environments, old_version) new_minor = old_version.content_view.versions.where(:major => old_version.major).maximum(:minor) + 1 self.new_content_view_version = old_version.content_view.create_new_version(description, old_version.major, new_minor, all_components) history = ::Katello::ContentViewHistory.create!(:content_view_version => new_content_view_version, :user => ::User.current.login, :status => ::Katello::ContentViewHistory::IN_PROGRESS, :task => self.task) copy_action_outputs = [] sequence do concurrence do repos_to_copy(old_version, new_components).each do |source_repo| copy_action_outputs += copy_repo(source_repo, new_content_view_version, content, dep_solve) end sequence do new_puppet_environment = plan_action(Katello::ContentViewPuppetEnvironment::Clone, old_version, :new_version => new_content_view_version).new_puppet_environment copy_action_outputs += copy_puppet_content(new_puppet_environment, content[:puppet_module_ids]) unless content[:puppet_module_ids].blank? end end plan_self(:content_view_id => old_version.content_view.id, :environment_ids => environments.map(&:id), :user_id => ::User.current.id, :history_id => history.id, :copy_action_outputs => copy_action_outputs) promote(new_content_view_version, environments) end end |
#repos_to_copy(old_version, components) ⇒ Object
49 50 51 52 53 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 49 def repos_to_copy(old_version, components) old_version.archived_repos.map do |source_repo| components_repo_instance(source_repo, components) || source_repo end end |
#run ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/lib/actions/katello/content_view_version/incremental_update.rb', line 78 def run content = { ::Katello::Erratum::CONTENT_TYPE => [], ::Katello::Rpm::CONTENT_TYPE => [], ::Katello::PuppetModule::CONTENT_TYPE => []} input[:copy_action_outputs].each do |copy_output| copy_output[:pulp_tasks].each do |pulp_task| pulp_task[:result][:units_successful].each do |unit| type = unit['type_id'] unit = unit['unit_key'] case type when ::Katello::Erratum::CONTENT_TYPE content[::Katello::Erratum::CONTENT_TYPE] << unit['id'] when ::Katello::Rpm::CONTENT_TYPE content[::Katello::Rpm::CONTENT_TYPE] << ::Katello::Util::Package.build_nvra(unit) when ::Katello::PuppetModule::CONTENT_TYPE content[::Katello::PuppetModule::CONTENT_TYPE] << "#{unit['author']}-#{unit['name']}-#{unit['version']}" end end end end output[:added_units] = content end |