foreman_scc_manager 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d296a7acbef13daa1e12d2f5fd87cde248487a46
4
- data.tar.gz: 8d3377991fc0dded2f0b4e72498bbc90081d6ea8
2
+ SHA256:
3
+ metadata.gz: 8c9b8504241cd3feed62bc340cf0db3c37bfc10943bf7db7ac9d119d154a1abc
4
+ data.tar.gz: 33c6c4286f16de71f6d3af9ad4d35bbaa741ddc5e66cbc164c95730256945778
5
5
  SHA512:
6
- metadata.gz: 5c94a4f70faeab6138a5d3a41e65d5ea59e17cdea4c5df585ff402bc8118ba01ee9a51783d2213bc287534700ef9a430955b3a18016ebd53f61ffcdd23d24603
7
- data.tar.gz: 91b77311d51017259a86f688b9de1491f00603d6cb8e932c2fc1b642be6c698c147a1cfb90611b3d80fc8fcd928eb4002fb7c017b13f1ffb6f5d03ccaa2172e1
6
+ metadata.gz: 729e90d1a64ee314ac3772346b19f3869a142431cbc2d932359c19ea8d9615bc10465b747efe8a7003bc8ae532d310e4a13dd077262fea05266f84059554a7f8
7
+ data.tar.gz: e0a3d085ea59df19371f774b48f83d229a970bde2fcf5b394b0c65ac0f9b27489b00530d3582fb4248488442894b3ceb72898fa592573ef2f87cd31170725a37
@@ -61,11 +61,18 @@ module Actions
61
61
  label = ::Katello::Util::Model.labelize(uniq_name)
62
62
  unprotected = true
63
63
  gpg_key = product.gpg_key
64
- repository = product.add_repo(label, uniq_name, input[:url], 'yum', unprotected, gpg_key)
65
- repository.arch = input[:arch]
64
+ repo_param = { :label => label,
65
+ :name => uniq_name,
66
+ :url => input[:url],
67
+ :content_type => 'yum',
68
+ :unprotected => unprotected,
69
+ :gpg_key => gpg_key,
70
+ :arch => input[:arch],
71
+ :download_policy => ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
72
+ }
73
+ repository = product.add_repo(repo_param)
66
74
  repository.mirror_on_sync = true
67
75
  repository.verify_ssl_on_sync = true
68
- repository.download_policy = ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
69
76
  trigger(::Actions::Katello::Repository::Create, repository, false, false)
70
77
  end
71
78
  end
@@ -1,4 +1,4 @@
1
- class SccAccount < ActiveRecord::Base
1
+ class SccAccount < ApplicationRecord
2
2
  include Authorizable
3
3
  include Encryptable
4
4
  include ForemanTasks::Concerns::ActionSubject
@@ -50,52 +50,52 @@ class SccAccount < ActiveRecord::Base
50
50
 
51
51
  def update_scc_repositories(upstream_repositories)
52
52
  upstream_repo_ids = []
53
- SccProduct.transaction do
54
- # import repositories
55
- upstream_repositories.each do |ur|
56
- cached_repository = scc_repositories.find_or_initialize_by(scc_id: ur['id'])
57
- cached_repository.name = ur['name']
58
- cached_repository.distro_target = ur['distro_target']
59
- cached_repository.description = ur['description']
60
- cached_repository.url, cached_repository.token = ur['url'].split('?')
61
- cached_repository.enabled = ur['enabled']
62
- cached_repository.autorefresh = ur['autorefresh']
63
- cached_repository.installer_updates = ur['installer_updates']
64
- cached_repository.save!
65
- upstream_repo_ids << cached_repository.id
66
- end
67
- # delete repositories beeing removed upstream
68
- scc_repositories.where(id: scc_repository_ids - upstream_repo_ids).destroy_all.count
53
+ # import repositories
54
+ upstream_repositories.each do |ur|
55
+ cached_repository = scc_repositories.find_or_initialize_by(scc_id: ur['id'])
56
+ cached_repository.name = ur['name']
57
+ cached_repository.distro_target = ur['distro_target']
58
+ cached_repository.description = ur['description']
59
+ cached_repository.url, cached_repository.token = ur['url'].split('?')
60
+ cached_repository.enabled = ur['enabled']
61
+ cached_repository.autorefresh = ur['autorefresh']
62
+ cached_repository.installer_updates = ur['installer_updates']
63
+ cached_repository.save!
64
+ upstream_repo_ids << ur['id']
69
65
  end
66
+ # delete repositories beeing removed upstream (Active record seems to be wrong here...)
67
+ # scc_repositories.where.not(scc_id: upstream_repo_ids).delete_all
68
+ upstream_repo_ids_str = upstream_repo_ids.map{ |id| ActiveRecord::Base.sanitize(id) }.join(',')
69
+ ActiveRecord::Base.connection.execute("delete from scc_repositories where scc_repositories.scc_account_id = #{ActiveRecord::Base.sanitize(id)} and scc_repositories.scc_id not in (#{upstream_repo_ids_str});")
70
70
  end
71
71
 
72
72
  def update_scc_products(upstream_products)
73
73
  upstream_product_ids = []
74
- SccProduct.transaction do
75
- # import products
76
- upstream_products.each do |up|
77
- cached_product = scc_products.find_or_initialize_by(scc_id: up['id'])
78
- cached_product.name = up['name']
79
- cached_product.version = up['version']
80
- cached_product.arch = up['arch']
81
- cached_product.description = up['description']
82
- cached_product.friendly_name = up['friendly_name']
83
- cached_product.product_type = up['product_type']
84
- cached_product.scc_repositories =
85
- scc_repositories.where(scc_id: up['repositories'].map { |repo| repo['id'] })
86
- cached_product.save!
87
- upstream_product_ids << cached_product.id
88
- end
89
- # delete products beeing removed upstream
90
- scc_products.where(id: scc_product_ids - upstream_product_ids).destroy_all.count
91
- # rewire product to product relationships
92
- upstream_products.each do |up|
93
- extensions = scc_products.where(scc_id: up['extensions'].map { |ext| ext['id'] })
94
- begin
95
- scc_products.find_by!(scc_id: up['id']).update!(scc_extensions: extensions)
96
- rescue ActiveRecord::RecordNotFound
97
- logger.info "Failed to find parent scc_product '#{up['name']}'."
98
- end
74
+ # import products
75
+ upstream_products.each do |up|
76
+ cached_product = scc_products.find_or_initialize_by(scc_id: up['id'])
77
+ cached_product.name = up['name']
78
+ cached_product.version = up['version']
79
+ cached_product.arch = up['arch']
80
+ cached_product.description = up['description']
81
+ cached_product.friendly_name = up['friendly_name']
82
+ cached_product.product_type = up['product_type']
83
+ cached_product.scc_repositories =
84
+ scc_repositories.where(scc_id: up['repositories'].map { |repo| repo['id'] })
85
+ cached_product.save!
86
+ upstream_product_ids << up['id']
87
+ end
88
+ # delete products beeing removed upstream (Active record seems to be wrong here...)
89
+ # scc_products.where.not(scc_id: upstream_product_ids).delete_all
90
+ upstream_product_ids_str = upstream_product_ids.map{ |id| ActiveRecord::Base.sanitize(id) }.join(',')
91
+ ActiveRecord::Base.connection.execute("delete from scc_products where scc_products.scc_account_id = #{ActiveRecord::Base.sanitize(id)} and scc_products.scc_id not in (#{upstream_product_ids_str});")
92
+ # rewire product to product relationships
93
+ upstream_products.each do |up|
94
+ extensions = scc_products.where(scc_id: up['extensions'].map { |ext| ext['id'] })
95
+ begin
96
+ scc_products.find_by!(scc_id: up['id']).update!(scc_extensions: extensions)
97
+ rescue ActiveRecord::RecordNotFound
98
+ logger.info "Failed to find parent scc_product '#{up['name']}'."
99
99
  end
100
100
  end
101
101
  end
@@ -1,4 +1,4 @@
1
- class SccExtending < ActiveRecord::Base
1
+ class SccExtending < ApplicationRecord
2
2
  belongs_to :scc_product, inverse_of: :scc_extendings
3
3
  belongs_to :scc_extension, class_name: :SccProduct, inverse_of: :inverse_scc_extendings
4
4
  end
@@ -1,4 +1,4 @@
1
- class SccProduct < ActiveRecord::Base
1
+ class SccProduct < ApplicationRecord
2
2
  include Authorizable
3
3
  include ForemanTasks::Concerns::ActionSubject
4
4
 
@@ -1,4 +1,4 @@
1
- class SccRepository < ActiveRecord::Base
1
+ class SccRepository < ApplicationRecord
2
2
  after_commit :token_changed_callback
3
3
 
4
4
  self.include_root_in_json = false
@@ -15,19 +15,17 @@
15
15
  <% @scc_accounts.each do |scc_account| %>
16
16
  <tr>
17
17
  <td class="display-two-pane ellipsis">
18
- <%= link_to_if_authorized(scc_account.name, hash_for_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)) %>
19
- <%= link_to_if_authorized('', hash_for_edit_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer), {visible: false, class: 'edit_deferree'}) %>
18
+ <%= link_to_if_authorized(scc_account.name, hash_for_edit_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)) %>
20
19
  </td>
21
20
  <td><%= scc_account.scc_products.count.to_s %></td>
22
21
  <td><%= scc_account.get_sync_status %></td>
23
22
  <td>
24
23
  <%= action_buttons(
24
+ display_link_if_authorized(_("Select products"), hash_for_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)),
25
25
  display_link_if_authorized(_("Sync"), hash_for_sync_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer),
26
- :method => :put),
27
- display_link_if_authorized(_("Edit"), hash_for_edit_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer),
28
- class: 'edit_deferrer'),
26
+ :method => :put),
29
27
  display_delete_if_authorized(hash_for_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer),
30
- :data => { :confirm => _("Delete %s?") % scc_account.to_s })
28
+ :data => { :confirm => _("Delete %s?") % scc_account.to_s })
31
29
  ) %>
32
30
  </td>
33
31
  </tr>
@@ -26,7 +26,7 @@
26
26
  </ul>
27
27
 
28
28
  <div class="tab-content">
29
- <div class="tab-pane active pre-scrollable" id="primary">
29
+ <div class="tab-pane active" id="primary">
30
30
  <ul>
31
31
  <% if @scc_account.synced %>
32
32
  <% @scc_account.scc_products.where(product_type: 'base').order(:friendly_name).each do |scc_product| %>
@@ -1,9 +1,9 @@
1
1
  class AddOrganizationToSccAccount < ActiveRecord::Migration
2
- class SccAccount < ActiveRecord::Base
2
+ class SccAccount < ApplicationRecord
3
3
  belongs_to :organization
4
4
  end
5
5
 
6
- class Organization < ActiveRecord::Base
6
+ class Organization < ApplicationRecord
7
7
  end
8
8
 
9
9
  def up
@@ -18,8 +18,8 @@ module ForemanSccManager
18
18
 
19
19
  initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
20
20
  Foreman::Plugin.register :foreman_scc_manager do
21
- requires_foreman '>= 1.13'
22
- requires_foreman_plugin 'katello', '>= 3.2.0'
21
+ requires_foreman '>= 1.16'
22
+ requires_foreman_plugin 'katello', '>= 3.5.0'
23
23
 
24
24
  # Add permissions
25
25
  security_block :foreman_scc_manager do
@@ -1,3 +1,3 @@
1
1
  module ForemanSccManager
2
- VERSION = '1.1.3'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
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: 1.1.3
4
+ version: 1.2.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: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.49.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.49.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: foreman-tasks
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.10.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.10.0
69
69
  description: Foreman plugin to sync SUSE Customer Center products and repositories
70
70
  into Katello.
71
71
  email:
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.5.2.1
147
+ rubygems_version: 2.7.6
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Suse Customer Center plugin for Foreman