-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix_ca_install_for_rh8
- Loading branch information
Showing
15 changed files
with
474 additions
and
182 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
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,103 @@ | ||
class RMT::CLI::Mirror < RMT::CLI::Base | ||
desc 'all', _('Mirror all enabled repositories') | ||
def all | ||
RMT::Lockfile.lock do | ||
logger = RMT::Logger.new(STDOUT) | ||
mirror = RMT::Mirror.new(logger: logger, mirror_src: RMT::Config.mirror_src_files?) | ||
|
||
begin | ||
mirror.mirror_suma_product_tree(repository_url: 'https://scc.suse.com/suma/') | ||
rescue RMT::Mirror::Exception => e | ||
logger.warn(e.message) | ||
end | ||
|
||
raise RMT::CLI::Error.new(_('There are no repositories marked for mirroring.')) if Repository.where(mirroring_enabled: true).empty? | ||
|
||
mirrored_repo_ids = [] | ||
until Repository.where(mirroring_enabled: true).where.not(id: mirrored_repo_ids).blank? | ||
repo = Repository.where(mirroring_enabled: true).where.not(id: mirrored_repo_ids).first | ||
|
||
begin | ||
mirror_repo!(mirror, repo) | ||
rescue RMT::Mirror::Exception => e | ||
logger.warn e.to_s | ||
ensure | ||
mirrored_repo_ids << repo.id | ||
end | ||
end | ||
end | ||
end | ||
|
||
default_task :all | ||
|
||
desc 'repository IDS', _('Mirror enabled repositories with given repository IDs') | ||
def repository(*ids) | ||
RMT::Lockfile.lock do | ||
logger = RMT::Logger.new(STDOUT) | ||
mirror = RMT::Mirror.new(logger: logger, mirror_src: RMT::Config.mirror_src_files?) | ||
|
||
ids = clean_target_input(ids) | ||
raise RMT::CLI::Error.new(_('No repository IDs supplied')) if ids.empty? | ||
|
||
repos = [] | ||
ids.each do |id| | ||
repo = Repository.find_by!(scc_id: id) | ||
raise RMT::CLI::Error.new(_('Mirroring of repository with ID %{repo_id} is not enabled') % { repo_id: id }) unless repo.mirroring_enabled | ||
repos << repo | ||
rescue ActiveRecord::RecordNotFound | ||
raise RMT::CLI::Error.new(_('Repository with ID %{repo_id} not found') % { repo_id: id }) | ||
end | ||
|
||
repos.each do |repo| | ||
mirror_repo!(mirror, repo) | ||
rescue RMT::Mirror::Exception => e | ||
logger.warn e.to_s | ||
end | ||
end | ||
end | ||
|
||
desc 'product IDS', _('Mirror enabled repositories for a product with given product IDs') | ||
def product(*targets) | ||
RMT::Lockfile.lock do | ||
logger = RMT::Logger.new(STDOUT) | ||
mirror = RMT::Mirror.new(logger: logger, mirror_src: RMT::Config.mirror_src_files?) | ||
|
||
targets = clean_target_input(targets) | ||
raise RMT::CLI::Error.new(_('No product IDs supplied')) if targets.empty? | ||
|
||
repos = [] | ||
targets.each do |target| | ||
products = Product.get_by_target!(target) | ||
raise RMT::CLI::Error.new(_('Product for target %{target} not found') % { target: target }) if products.empty? | ||
products.each do |product| | ||
product_repos = product.repositories.where(mirroring_enabled: true) | ||
raise RMT::CLI::Error.new(_('Product %{target} has no repositories enabled') % { target: target }) if product_repos.empty? | ||
repos += product_repos.to_a | ||
end | ||
rescue ActiveRecord::RecordNotFound | ||
raise RMT::CLI::Error.new(_('Product with ID %{target} not found') % { target: target }) | ||
end | ||
|
||
repos.each do |repo| | ||
mirror_repo!(mirror, repo) | ||
rescue RMT::Mirror::Exception => e | ||
logger.warn e.to_s | ||
end | ||
end | ||
end | ||
|
||
protected | ||
|
||
def mirror_repo!(mirror, repo) | ||
mirror.mirror( | ||
repository_url: repo.external_url, | ||
local_path: Repository.make_local_path(repo.external_url), | ||
auth_token: repo.auth_token, | ||
repo_name: repo.name | ||
) | ||
|
||
repo.refresh_timestamp! | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
------------------------------------------------------------------- | ||
Tue Aug 20 11:12:58 UTC 2019 - Ivan Kapelyukhin <[email protected]> | ||
|
||
- Version 2.4.0 | ||
- Allow to mirror individual products/repositories (bsc#1138863) | ||
|
||
------------------------------------------------------------------- | ||
Fri Aug 16 11:07:26 UTC 2019 - [email protected] | ||
|
||
- Version 2.3.7 | ||
- RMT now uses mirror_src to determine whether or not to download | ||
source packages. (bsc#1145688) | ||
|
||
------------------------------------------------------------------- | ||
Thu Aug 8 10:50:26 UTC 2019 - Ivan Kapelyukhin <[email protected]> | ||
|
||
- Version 2.3.6 | ||
- Make Rails log level configurable; set default log level to INFO | ||
|
||
------------------------------------------------------------------- | ||
Wed Aug 7 12:43:02 UTC 2019 - Thomas Schmidt <[email protected]> | ||
|
||
|
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 |
---|---|---|
|
@@ -23,3 +23,6 @@ http_client: | |
proxy_auth: | ||
proxy_user: | ||
proxy_password: | ||
|
||
log_level: | ||
rails: info |
Oops, something went wrong.