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 +5 -5
- data/app/lib/actions/scc_manager/subscribe_product.rb +10 -3
- data/app/models/scc_account.rb +42 -42
- data/app/models/scc_extending.rb +1 -1
- data/app/models/scc_product.rb +1 -1
- data/app/models/scc_repository.rb +1 -1
- data/app/views/scc_accounts/index.html.erb +4 -6
- data/app/views/scc_accounts/show.html.erb +1 -1
- data/db/migrate/20170303085304_add_organization_to_scc_account.rb +2 -2
- data/lib/foreman_scc_manager/engine.rb +2 -2
- data/lib/foreman_scc_manager/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c9b8504241cd3feed62bc340cf0db3c37bfc10943bf7db7ac9d119d154a1abc
|
4
|
+
data.tar.gz: 33c6c4286f16de71f6d3af9ad4d35bbaa741ddc5e66cbc164c95730256945778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
65
|
-
|
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
|
data/app/models/scc_account.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class SccAccount <
|
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
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
data/app/models/scc_extending.rb
CHANGED
data/app/models/scc_product.rb
CHANGED
@@ -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,
|
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
|
-
|
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
|
-
|
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
|
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 <
|
2
|
+
class SccAccount < ApplicationRecord
|
3
3
|
belongs_to :organization
|
4
4
|
end
|
5
5
|
|
6
|
-
class Organization <
|
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.
|
22
|
-
requires_foreman_plugin 'katello', '>= 3.
|
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
|
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.
|
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:
|
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:
|
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:
|
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:
|
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:
|
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.
|
147
|
+
rubygems_version: 2.7.6
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Suse Customer Center plugin for Foreman
|