-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #38048 - Add rolling content views
Co-authored-by: Markus Bucher <bucher@atix.de> Co-authored-by: Nadja Heitmann <nadjah@atix.de> Co-authored-by: Quirin Pamp <pamp@atix.de> Co-authored-by: Bernhard Suttner <suttner@atix.de>
- Loading branch information
1 parent
f3402e0
commit 89239be
Showing
62 changed files
with
1,067 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Actions | ||
module Helpers | ||
module RollingCVRepos | ||
def update_rolling_content_views(repo) | ||
concurrence do | ||
repos = repo.root.repositories.in_environment(repo.environment).where( | ||
content_view_version: ::Katello::ContentViewVersion.where(content_view: ::Katello::ContentView.rolling) | ||
) | ||
|
||
repos.each do |rolling_repo| | ||
plan_action(::Actions::Katello::ContentView::RefreshRollingRepo, rolling_repo) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
app/lib/actions/katello/content_view/add_rolling_repo_clone.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Actions | ||
module Katello | ||
module ContentView | ||
class AddRollingRepoClone < Actions::EntryAction | ||
def plan(content_view, repository_ids) | ||
library = content_view.organization.library | ||
|
||
concurrence do | ||
::Katello::Repository.where(id: repository_ids).each do |repository| | ||
sequence do | ||
clone = content_view.get_repo_clone(library, repository).first | ||
if clone.nil? | ||
clone = repository.build_clone(content_view: content_view, environment: library) | ||
clone.save! | ||
end | ||
plan_action(RefreshRollingRepo, clone) | ||
|
||
view_env_cp_id = content_view.content_view_environment(library).cp_id | ||
content_id = repository.content_id | ||
plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env_cp_id, :content_id => content_id) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
30 changes: 30 additions & 0 deletions
30
app/lib/actions/katello/content_view/refresh_rolling_repo.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module Actions | ||
module Katello | ||
module ContentView | ||
class RefreshRollingRepo < Actions::EntryAction | ||
def plan(repository) | ||
action_subject repository | ||
sequence do | ||
plan_self(repository_id: repository.id) | ||
plan_action(Pulp3::Repository::RefreshDistribution, repository, SmartProxy.pulp_primary) | ||
plan_action(Repository::IndexContent, id: repository.id, source_repository_id: repository.library_instance.id) | ||
end | ||
end | ||
|
||
def run | ||
repository = ::Katello::Repository.find(input[:repository_id]) | ||
library_instance = repository.library_instance | ||
# ensure IndexContent is not skipped! | ||
repository.last_contents_changed = DateTime.now if repository.version_href != library_instance.version_href | ||
|
||
repository.version_href = library_instance.version_href | ||
repository.publication_href = library_instance.publication_href | ||
if repository.deb_using_structured_apt? | ||
repository.content_id = library_instance.content_id | ||
end | ||
repository.save! | ||
end | ||
end | ||
end | ||
end | ||
end |
28 changes: 28 additions & 0 deletions
28
app/lib/actions/katello/content_view/remove_rolling_repo_clone.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module Actions | ||
module Katello | ||
module ContentView | ||
class RemoveRollingRepoClone < Actions::EntryAction | ||
def plan(content_view, repository_ids) | ||
library = content_view.organization.library | ||
|
||
clone_repo_ids = [] | ||
concurrence do | ||
::Katello::Repository.where(id: repository_ids).each do |repository| | ||
clone_repo = content_view.get_repo_clone(library, repository).first | ||
next if clone_repo.nil? | ||
|
||
clone_repo_ids << clone_repo.id | ||
plan_action(Actions::Pulp3::Repository::DeleteDistributions, clone_repo.id, SmartProxy.pulp_primary) | ||
end | ||
plan_action(Candlepin::Environment::SetContent, content_view, library, content_view.content_view_environment(library)) | ||
end | ||
plan_self(repository_ids: clone_repo_ids) | ||
end | ||
|
||
def run | ||
::Katello::Repository.where(id: input[:repository_ids]).destroy_all | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.