foreman_scc_manager 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73d2510abbdbe51fef59bba613502fb02ef1fe14eeb441f0bee716b17e2eba8d
4
- data.tar.gz: c61b9f852d58033c290204508d0d4653e5379c6c8b73e6d5b58d026ea485b0f0
3
+ metadata.gz: 6946578ff8b15ec04a5c14a78e12107481d47d9f5093a4e1d2501bc79c4c4f94
4
+ data.tar.gz: f800326b64951b7909427f7fa7d126e6300550f5bee9afacbb394f83d5fe1cf7
5
5
  SHA512:
6
- metadata.gz: d3ce92fbe191d0aaa6f10d0015ed4a3e3320892d1f45a519a965cdbd63a93e49a0fe6918fcc1b7cfb4618b8a8fc016349bfbceba5825a93ca5400dce5dd18e03
7
- data.tar.gz: a48593aa198df8fbc5b4c88a2654facb7dc1f77f80373d3cf7a03fa46e84bd5f02af338af0a0e1dd2968da7e7afa6e44548f992e51d1ece7a0a82fa05922f0d9
6
+ metadata.gz: d90c05393fe090f811d6cfbb038dd2cb5e45f73ed1359e3bd172c422131a9acb53ac17c0e85c253f9a350462fa5a7954d767af01ffdb9baf3766fcae5acee014
7
+ data.tar.gz: acbbdc19ee139f505415d328fe51f463e2d249a82635b75750b73bfbbdd4fd3a84a32f465cac22c806d36b8044f6d07f14045ecb931830af58a39dac19ce94ee
data/README.md CHANGED
@@ -11,7 +11,7 @@ Foreman plugin to sync SUSE Customer Center products and repositories into Katel
11
11
  This plugin installation is supported since Foreman 3.4 / Katello 4.6 by the foreman-installer, but only with the scenario Katello:
12
12
 
13
13
  ```sh
14
- foreman-install --scenario katello --enable-foreman-plugin-scc-manager
14
+ foreman-installer --scenario katello --enable-foreman-plugin-scc-manager
15
15
  ```
16
16
 
17
17
  You can also install it manually:
@@ -26,7 +26,7 @@ foreman-installer
26
26
 
27
27
  | Foreman Version | Katello Version | Plugin Version |
28
28
  | --------------- | --------------- | -------------- |
29
- | 3.5 | 4.5 | ~> 2.0.0 |
29
+ | 3.3 | 4.5 | ~> 2.0.0 |
30
30
  | 3.1 | 4.3 | ~> 1.8.20\* |
31
31
  | 3.0 | 4.2 | ~> 1.8.20 |
32
32
  | 2.5 | 4.1 | ~> 1.8.20 |
@@ -39,7 +39,7 @@ foreman-installer
39
39
 
40
40
  ## Documentation
41
41
 
42
- [Plugin documentation](https://docs.orcharhino.com/or/docs/sources/usage_guides/managing_sles_systems_guide.html#mssg_installing_the_scc_manager_plugin)
42
+ [Plugin documentation](https://docs.orcharhino.com/or/docs/sources/guides/suse_linux_enterprise_server/managing_content/managing_suse_content.html)
43
43
 
44
44
  ## Hammer CLI Extension
45
45
 
@@ -34,6 +34,14 @@ module Api
34
34
  param :password, String, :required => true, :desc => N_('Password of scc_account')
35
35
  param :base_url, String, :required => false, :desc => N_('URL of SUSE for scc_account')
36
36
  param :interval, ['never', 'daily', 'weekly', 'monthly'], :desc => N_('Interval for syncing scc_account')
37
+ param :download_policy,
38
+ ::Katello::RootRepository::DOWNLOAD_POLICIES,
39
+ :required => false,
40
+ :desc => N_('The default download policy for repositories which were created using this SCC Account.')
41
+ param :mirroring_policy,
42
+ SccAccount::SCC_MIRRORING_POLICIES,
43
+ :required => false,
44
+ :desc => N_('The default mirroring policy for repositories which were created using this SCC Account.')
37
45
  param :sync_date, String, :desc => N_('Date and time relative to which the sync interval is run')
38
46
  param :katello_gpg_key_id, :identifier, :required => false, :desc => N_('Associated GPG key of scc_account')
39
47
  end
@@ -170,6 +170,8 @@ class SccAccountsController < ApplicationController
170
170
  :password,
171
171
  :base_url,
172
172
  :interval,
173
+ :download_policy,
174
+ :mirroring_policy,
173
175
  :sync_date,
174
176
  :organization_id,
175
177
  :katello_gpg_key_id
@@ -53,7 +53,9 @@ module Actions
53
53
  :pretty_repo_name => repo.pretty_name,
54
54
  :url => repo.url,
55
55
  :token => repo.token,
56
- :arch => arch)
56
+ :arch => arch,
57
+ :download_policy => scc_product.scc_account.download_policy,
58
+ :mirroring_policy => scc_product.scc_account.mirroring_policy)
57
59
  katello_repos[repo.id] = repo_create_action.output[:katello_root_repository_id]
58
60
  end
59
61
 
@@ -119,13 +121,9 @@ module Actions
119
121
  :unprotected => unprotected,
120
122
  :gpg_key => gpg_key,
121
123
  :arch => input[:arch],
122
- :download_policy => Setting[:default_download_policy] }
124
+ :download_policy => input[:download_policy],
125
+ :mirroring_policy => input[:mirroring_policy] }
123
126
  repository = product.add_repo(repo_param)
124
- if repository.has_attribute?('mirror_on_sync')
125
- repository.mirror_on_sync = true
126
- else
127
- repository.mirroring_policy = ::Katello::RootRepository::MIRRORING_POLICY_CONTENT
128
- end
129
127
  if repository.has_attribute?('upstream_authentication_token')
130
128
  repository.url = input[:url]
131
129
  repository.upstream_authentication_token = input[:token]
@@ -13,6 +13,11 @@ class SccAccount < ApplicationRecord
13
13
  MONTHLY = 'monthly'.freeze
14
14
  TYPES = [NEVER, DAILY, WEEKLY, MONTHLY].freeze
15
15
 
16
+ # MIRRORING_POLICY_COMPLETE doesn't work for suse repository because deltarpm metadata is not supported by pulp3
17
+ SCC_MIRRORING_POLICIES = ::Katello::RootRepository::MIRRORING_POLICIES.dup
18
+ SCC_MIRRORING_POLICIES.delete(::Katello::RootRepository::MIRRORING_POLICY_COMPLETE)
19
+ SCC_MIRRORING_POLICIES.freeze
20
+
16
21
  self.include_root_in_json = false
17
22
 
18
23
  belongs_to :organization
@@ -29,6 +34,8 @@ class SccAccount < ApplicationRecord
29
34
  validates :password, presence: true
30
35
  validates :base_url, presence: true
31
36
  validates :interval, :inclusion => { :in => TYPES }, :allow_blank => false
37
+ validates :download_policy, :inclusion => { :in => ::Katello::RootRepository::DOWNLOAD_POLICIES }, :allow_blank => false
38
+ validates :mirroring_policy, :inclusion => { :in => SCC_MIRRORING_POLICIES }, :allow_blank => false
32
39
  validate :sync_date_is_valid_datetime
33
40
 
34
41
  after_initialize :init
@@ -278,4 +285,18 @@ class SccAccount < ApplicationRecord
278
285
  end
279
286
  items_to_invalidate
280
287
  end
288
+
289
+ def self.download_policy_selection_values
290
+ names = { 'on_demand' => _('On Demand'), 'immediate' => _('Immediate') }
291
+ ::Katello::RootRepository::DOWNLOAD_POLICIES.map do |p|
292
+ names.include?(p) ? [names[p], p] : [p, p]
293
+ end
294
+ end
295
+
296
+ def self.mirroring_policy_selection_values
297
+ names = { 'additive' => _('Additive'), 'mirror_content_only' => _('Content Only') }
298
+ SCC_MIRRORING_POLICIES.map do |p|
299
+ names.include?(p) ? [names[p], p] : [p, p]
300
+ end
301
+ end
281
302
  end
@@ -58,11 +58,8 @@ class SccProduct < ApplicationRecord
58
58
  gpg_key = new_product.gpg_key
59
59
  new_repo = new_product.add_repo(label, uniq_repo_name, repo.url, 'yum', unprotected, gpg_key)
60
60
  new_repo.arch = arch || 'noarch'
61
- if new_repo.has_attribute?('mirror_on_sync')
62
- new_repo.mirror_on_sync = true
63
- else
64
- new_repo.mirroring_policy = ::Katello::RootRepository::MIRRORING_POLICY_CONTENT
65
- end
61
+ new_repo.mirroring_policy = scc_account.mirroring_policy
62
+ new_repo.download_policy = scc_account.download_policy
66
63
  if new_repo.has_attribute?('upstream_authentication_token')
67
64
  new_repo.upstream_authentication_token = repo.token
68
65
  new_repo.url = repo.url
@@ -2,4 +2,4 @@
2
2
 
3
3
  object @scc_account
4
4
  extends 'api/v2/scc_accounts/base'
5
- attributes :organization_id, :organization_name, :login, :base_url, :interval, :sync_date
5
+ attributes :organization_id, :organization_name, :login, :base_url, :interval, :download_policy, :mirroring_policy, :sync_date
@@ -19,11 +19,15 @@
19
19
  <%= field f, :sync_date, label: _('Sync Date') do
20
20
  f.datetime_field :sync_date, placeholder: Time.now
21
21
  end %>
22
- <%= selectable_f f, :katello_gpg_key_id, @selectable_gpg_keys, {},
23
- { :include_blank => _("None"),
24
- :label => _('Use GPG key for SUSE products'),
25
- :selected => @scc_account.katello_gpg_key_id,
22
+ <%= selectable_f f, :katello_gpg_key_id, @selectable_gpg_keys, {},
23
+ { :include_blank => _("None"),
24
+ :label => _('Use GPG key for SUSE products'),
25
+ :selected => @scc_account.katello_gpg_key_id,
26
26
  :help_block => _("Use this setting if you want to automatically add a GPG key to your SUSE products upon subscription. You can change this setting in the 'Content' > 'Products' menu, later.") } %>
27
+ <%= selectable_f f, :download_policy, SccAccount::download_policy_selection_values,
28
+ { :label => _('Download Policy'), :help_block => _("The default download policy for repositories which were created using this SCC Account.") } %>
29
+ <%= selectable_f f, :mirroring_policy, SccAccount::mirroring_policy_selection_values,
30
+ { :label => _('Mirroring Policy'), :help_block => _("The default mirroring policy for repositories which were created using this SCC Account.") } %>
27
31
  <div class='clearfix'>
28
32
  <div class='form-group'>
29
33
  <div class='col-md-2'></div>
@@ -0,0 +1,11 @@
1
+ class AddSyncOptionsToSccAccount < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :scc_accounts, :download_policy, :string, default: ::Katello::RootRepository::DOWNLOAD_IMMEDIATE
4
+ add_column :scc_accounts, :mirroring_policy, :string, default: ::Katello::RootRepository::MIRRORING_POLICY_CONTENT
5
+ SccAccount.all.each do |a|
6
+ a.download_policy = ::Katello::RootRepository::DOWNLOAD_IMMEDIATE
7
+ a.mirroring_policy = ::Katello::RootRepository::MIRRORING_POLICY_CONTENT
8
+ a.save!
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module ForemanSccManager
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
@@ -19,7 +19,7 @@ class SccAccountsControllerTest < ActionController::TestCase
19
19
  'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
20
20
  'Authorization' => auth,
21
21
  'Host' => host,
22
- 'User-Agent' => "rest-client/2.1.0 (linux-gnu x86_64) ruby/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
22
+ 'User-Agent' => "rest-client/2.1.0 (linux x86_64) ruby/#{RUBY_VERSION}p#{RUBY_PATCHLEVEL}"
23
23
  }
24
24
  )
25
25
  .to_return(status: 200, body: '', headers: {})
@@ -5,11 +5,7 @@ sles12_sp4_updates:
5
5
  product_id: <%= ActiveRecord::FixtureSet.identify(:suse) %>
6
6
  url: www.not-valid.com
7
7
  download_policy: immediate
8
- <% if ActiveRecord::Base.connection.column_exists? :katello_root_repositories, :mirroring_policy %>
9
8
  mirroring_policy: "mirror_content_only"
10
- <% else %>
11
- mirror_on_sync: "true"
12
- <% end %>
13
9
  created_at: <%= Time.now %>
14
10
  updated_at: <%= Time.now %>
15
11
 
@@ -20,11 +16,7 @@ sles12_sp4_installer_updates:
20
16
  product_id: <%= ActiveRecord::FixtureSet.identify(:suse) %>
21
17
  url: www.not-valid.com
22
18
  download_policy: on_demand
23
- <% if ActiveRecord::Base.connection.column_exists? :katello_root_repositories, :mirroring_policy %>
24
19
  mirroring_policy: "mirror_content_only"
25
- <% else %>
26
- mirror_on_sync: "true"
27
- <% end %>
28
20
  created_at: <%= Time.now %>
29
21
  updated_at: <%= Time.now %>
30
22
 
@@ -35,10 +27,6 @@ sles12_sp4_installer_updates_2:
35
27
  product_id: <%= ActiveRecord::FixtureSet.identify(:suse) %>
36
28
  url: www.not-valid.com
37
29
  download_policy: on_demand
38
- <% if ActiveRecord::Base.connection.column_exists? :katello_root_repositories, :mirroring_policy %>
39
30
  mirroring_policy: "mirror_content_only"
40
- <% else %>
41
- mirror_on_sync: "true"
42
- <% end %>
43
31
  created_at: <%= Time.now %>
44
32
  updated_at: <%= Time.now %>
@@ -29,8 +29,6 @@ module FixtureTestCase
29
29
  fixtures(:all)
30
30
  FIXTURES = load_fixtures(ActiveRecord::Base)
31
31
 
32
- Setting::Content.load_defaults
33
-
34
32
  User.current = ::User.unscoped.find(FIXTURES['users']['admin']['id'])
35
33
  end
36
34
  end
@@ -41,10 +39,6 @@ class ActiveSupport::TestCase
41
39
  include FixtureTestCase
42
40
  include ForemanTasks::TestHelpers::WithInThreadExecutor
43
41
 
44
- before do
45
- Setting::Content.load_defaults
46
- end
47
-
48
42
  def get_organization(org = nil)
49
43
  saved_user = User.current
50
44
  User.current = User.unscoped.find(users(:admin).id)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_scc_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ATIX AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-31 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -171,6 +171,7 @@ files:
171
171
  - db/migrate/20220429102717_populate_scc_katello_repositories.rb
172
172
  - db/migrate/20220513132652_populate_upstream_authentication_token.rb
173
173
  - db/migrate/20220531120722_add_product_category_to_scc_products.rb
174
+ - db/migrate/20221013214310_add_sync_options_to_scc_account.rb
174
175
  - lib/foreman_scc_manager.rb
175
176
  - lib/foreman_scc_manager/engine.rb
176
177
  - lib/foreman_scc_manager/version.rb
@@ -248,27 +249,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
249
  - !ruby/object:Gem::Version
249
250
  version: '0'
250
251
  requirements: []
251
- rubygems_version: 3.2.5
252
+ rubyforge_project:
253
+ rubygems_version: 2.7.6
252
254
  signing_key:
253
255
  specification_version: 4
254
256
  summary: Suse Customer Center plugin for Foreman
255
257
  test_files:
256
- - test/models/scc_product_test.rb
257
- - test/models/scc_account_test.rb
258
- - test/controllers/scc_accounts_controller_test.rb
259
- - test/controllers/api/v2/scc_accounts_test.rb
260
- - test/controllers/api/v2/scc_products_test.rb
261
- - test/fixtures/models/katello_root_repositories.yml
262
- - test/fixtures/models/scc_accounts.yml
263
258
  - test/fixtures/models/scc_products.yml
264
259
  - test/fixtures/models/scc_repositories.yml
265
- - test/fixtures/files/data_products_page2.json
266
- - test/fixtures/files/data_products_page1.json
260
+ - test/fixtures/models/scc_accounts.yml
261
+ - test/fixtures/models/katello_root_repositories.yml
267
262
  - test/fixtures/files/data_subscriptions.json
263
+ - test/fixtures/files/data_products_page1.json
268
264
  - test/fixtures/files/data_repositories.json
269
- - test/features/sync_test.rb
270
- - test/unit/foreman_scc_manager_test.rb
265
+ - test/fixtures/files/data_products_page2.json
271
266
  - test/actions/sync_test.rb
272
- - test/support/fixtures_support.rb
267
+ - test/features/sync_test.rb
273
268
  - test/factories/foreman_scc_manager_factories.rb
269
+ - test/unit/foreman_scc_manager_test.rb
274
270
  - test/test_plugin_helper.rb
271
+ - test/support/fixtures_support.rb
272
+ - test/models/scc_account_test.rb
273
+ - test/models/scc_product_test.rb
274
+ - test/controllers/scc_accounts_controller_test.rb
275
+ - test/controllers/api/v2/scc_products_test.rb
276
+ - test/controllers/api/v2/scc_accounts_test.rb