foreman_scc_manager 1.3.1 → 1.4.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 +4 -4
- data/README.md +6 -6
- data/Rakefile +2 -2
- data/app/controllers/scc_accounts_controller.rb +4 -9
- data/app/controllers/scc_products_controller.rb +0 -1
- data/app/lib/actions/scc_manager/subscribe_product.rb +8 -9
- data/app/lib/actions/scc_manager/sync.rb +2 -5
- data/app/lib/actions/scc_manager/sync_products.rb +1 -1
- data/app/lib/actions/scc_manager/sync_repositories.rb +1 -1
- data/app/models/scc_account.rb +18 -10
- data/app/models/scc_repository.rb +1 -1
- data/app/views/scc_accounts/index.html.erb +1 -1
- data/lib/foreman_scc_manager/engine.rb +3 -3
- data/lib/foreman_scc_manager/version.rb +1 -1
- data/lib/tasks/foreman_scc_manager_tasks.rake +2 -4
- data/locale/action_names.rb +60 -60
- data/test/controllers/foreman_scc_manager/scc_accounts_controller_test.rb +10 -0
- data/test/factories/foreman_scc_manager_factories.rb +1 -1
- data/test/test_plugin_helper.rb +0 -4
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67a2884348925699e2aadc5796abe4ec48adee8458c577c035c564c1fbd9f950
|
4
|
+
data.tar.gz: 2ea193e0dbc07d41706f908870c610e1411ec200df1c6f10435f8ddc2dde0a4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbac716765fccb60766e4e3a6a205d596bbfd08b1349efe1e9ed56a70bb84696835895520d2b93c6bf079f8ae9d0aebab169d541b5d6291f9519f24347b407c9
|
7
|
+
data.tar.gz: 6419f3962cc8355300132eb6ea01719e5a912a66f18051922e2edc8db482a0d46d224f88bd6c5dbef501c06b877dbe6dc44cfc4e48d4438e62251c46cf6599c3
|
data/README.md
CHANGED
@@ -7,13 +7,13 @@ Foreman plugin to sync SUSE Customer Center products and repositories into Katel
|
|
7
7
|
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
8
8
|
for how to install Foreman plugins
|
9
9
|
|
10
|
-
##
|
10
|
+
## Compatibility
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
| Foreman Version | Katello Version | Plugin Version |
|
13
|
+
| --------------- | --------------- | -------------- |
|
14
|
+
| 1.17 | 3.6 | >= 1.3.1 |
|
15
|
+
| 1.16 | 3.5 | <= 1.3.0 |
|
16
|
+
| 1.15 | 3.4 | ~> 1.1.0 |
|
17
17
|
|
18
18
|
## Contributing
|
19
19
|
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
21
|
end
|
22
22
|
|
23
|
-
APP_RAKEFILE = File.expand_path('
|
23
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
24
|
|
25
25
|
Bundler::GemHelper.install_tasks
|
26
26
|
|
@@ -38,7 +38,7 @@ task default: :test
|
|
38
38
|
begin
|
39
39
|
require 'rubocop/rake_task'
|
40
40
|
RuboCop::RakeTask.new
|
41
|
-
rescue => _
|
41
|
+
rescue StandardError => _
|
42
42
|
puts 'Rubocop not loaded.'
|
43
43
|
end
|
44
44
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class SccAccountsController < ApplicationController
|
2
2
|
before_action :find_organization
|
3
3
|
before_action :find_resource, only: %i[show edit update destroy sync bulk_subscribe]
|
4
|
-
include Api::TaxonomyScope
|
5
4
|
include Foreman::Controller::AutoCompleteSearch
|
6
5
|
|
7
6
|
# GET /scc_accounts
|
@@ -32,14 +31,12 @@ class SccAccountsController < ApplicationController
|
|
32
31
|
# POST /scc_accounts/test_connection
|
33
32
|
def test_connection
|
34
33
|
@scc_account = SccAccount.new(scc_account_params)
|
35
|
-
if params[:scc_account_id].present? && scc_account_params[:password].empty?
|
36
|
-
@scc_account.password = SccAccount.find_by!(id: params[:scc_account_id]).password
|
37
|
-
end
|
34
|
+
@scc_account.password = SccAccount.find_by!(id: params[:scc_account_id]).password if params[:scc_account_id].present? && scc_account_params[:password].empty?
|
38
35
|
respond_to do |format|
|
39
36
|
if @scc_account.test_connection
|
40
37
|
format.json { render json: nil, status: :ok }
|
41
38
|
else
|
42
|
-
format.json { render json: nil, status:
|
39
|
+
format.json { render json: nil, status: :not_found }
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
@@ -79,7 +76,7 @@ class SccAccountsController < ApplicationController
|
|
79
76
|
scc_products_to_subscribe =
|
80
77
|
@scc_account.scc_products.where(id: scc_bulk_subscribe_params[:scc_subscribe_product_ids])
|
81
78
|
|
82
|
-
if
|
79
|
+
if scc_products_to_subscribe.count > 0
|
83
80
|
ForemanTasks.async_task(::Actions::BulkAction,
|
84
81
|
::Actions::SccManager::SubscribeProduct,
|
85
82
|
scc_products_to_subscribe)
|
@@ -99,9 +96,7 @@ class SccAccountsController < ApplicationController
|
|
99
96
|
|
100
97
|
def find_organization
|
101
98
|
@organization = Organization.current
|
102
|
-
unless @organization
|
103
|
-
redirect_to '/select_organization?toState=' + request.path
|
104
|
-
end
|
99
|
+
redirect_to '/select_organization?toState=' + request.path unless @organization
|
105
100
|
end
|
106
101
|
|
107
102
|
# Use callbacks to share common setup or constraints between actions.
|
@@ -61,15 +61,14 @@ module Actions
|
|
61
61
|
label = ::Katello::Util::Model.labelize(uniq_name)
|
62
62
|
unprotected = true
|
63
63
|
gpg_key = product.gpg_key
|
64
|
-
repo_param = {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
}
|
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 }
|
73
72
|
repository = product.add_repo(repo_param)
|
74
73
|
repository.mirror_on_sync = true
|
75
74
|
repository.verify_ssl_on_sync = true
|
@@ -14,11 +14,8 @@ module Actions
|
|
14
14
|
|
15
15
|
def finalize
|
16
16
|
scc_account = SccAccount.find(input[:scc_account][:id])
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
raise 'Updating failed'
|
21
|
-
end
|
17
|
+
raise 'Updating failed' unless input[:repo_status] == 'SUCCESS' && input[:prod_status] == 'SUCCESS'
|
18
|
+
scc_account.update! synced: Time.current
|
22
19
|
end
|
23
20
|
|
24
21
|
def rescue_strategy
|
data/app/models/scc_account.rb
CHANGED
@@ -26,24 +26,24 @@ class SccAccount < ApplicationRecord
|
|
26
26
|
name
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def sync_status
|
30
30
|
if sync_task.nil?
|
31
|
-
|
31
|
+
_('never synced')
|
32
32
|
elsif sync_task.state == 'stopped'
|
33
33
|
if sync_task.result == 'success'
|
34
|
-
|
34
|
+
synced
|
35
35
|
else
|
36
|
-
|
36
|
+
sync_task.result
|
37
37
|
end
|
38
38
|
else
|
39
|
-
|
39
|
+
sync_task.state
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_connection
|
44
44
|
SccManager.get_scc_data(base_url, '/connect/organizations/subscriptions', login, password)
|
45
45
|
true
|
46
|
-
rescue
|
46
|
+
rescue StandardError
|
47
47
|
false
|
48
48
|
end
|
49
49
|
|
@@ -67,10 +67,14 @@ class SccAccount < ApplicationRecord
|
|
67
67
|
if upstream_repo_ids.empty?
|
68
68
|
urid_query_fragment = ''
|
69
69
|
else
|
70
|
-
upstream_repo_ids_str = upstream_repo_ids.map
|
70
|
+
upstream_repo_ids_str = upstream_repo_ids.map do |id|
|
71
|
+
ActiveRecord::Base.connection.quote(id)
|
72
|
+
end.join(',')
|
71
73
|
urid_query_fragment = " and scc_repositories.scc_id not in (#{upstream_repo_ids_str})"
|
72
74
|
end
|
73
|
-
ActiveRecord::Base.connection.execute(
|
75
|
+
ActiveRecord::Base.connection.execute(
|
76
|
+
"delete from scc_repositories where scc_repositories.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{urid_query_fragment};"
|
77
|
+
)
|
74
78
|
end
|
75
79
|
|
76
80
|
def update_scc_products(upstream_products)
|
@@ -94,10 +98,14 @@ class SccAccount < ApplicationRecord
|
|
94
98
|
if upstream_product_ids.empty?
|
95
99
|
upid_query_fragment = ''
|
96
100
|
else
|
97
|
-
upstream_product_ids_str = upstream_product_ids.map
|
101
|
+
upstream_product_ids_str = upstream_product_ids.map do |id|
|
102
|
+
ActiveRecord::Base.connection.quote(id)
|
103
|
+
end.join(',')
|
98
104
|
upid_query_fragment = " and scc_products.scc_id not in (#{upstream_product_ids_str})"
|
99
105
|
end
|
100
|
-
ActiveRecord::Base.connection.execute(
|
106
|
+
ActiveRecord::Base.connection.execute(
|
107
|
+
"delete from scc_products where scc_products.scc_account_id = #{ActiveRecord::Base.connection.quote(id)}#{upid_query_fragment};"
|
108
|
+
)
|
101
109
|
# rewire product to product relationships
|
102
110
|
upstream_products.each do |up|
|
103
111
|
extensions = scc_products.where(scc_id: up['extensions'].map { |ext| ext['id'] })
|
@@ -12,7 +12,7 @@ class SccRepository < ApplicationRecord
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def token_changed_callback
|
15
|
-
User.current
|
15
|
+
User.current ||= User.anonymous_admin
|
16
16
|
scc_products.where.not(product: nil).find_each do |sp|
|
17
17
|
reponame = sp.friendly_name + ' ' + description
|
18
18
|
repository = sp.product.repositories.find_by(name: reponame)
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<%= link_to_if_authorized(scc_account.name, hash_for_edit_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)) %>
|
19
19
|
</td>
|
20
20
|
<td><%= scc_account.scc_products.count.to_s %></td>
|
21
|
-
<td><%= link_to_if(scc_account.sync_task, scc_account.
|
21
|
+
<td><%= link_to_if(scc_account.sync_task, scc_account.sync_status, scc_account.sync_task) %></td>
|
22
22
|
<td>
|
23
23
|
<%= action_buttons(
|
24
24
|
display_link_if_authorized(_("Select products"), hash_for_scc_account_path(:id => scc_account).merge(:auth_object => scc_account, :authorizer => authorizer)),
|
@@ -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.18'
|
22
|
+
requires_foreman_plugin 'katello', '>= 3.7.0'
|
23
23
|
|
24
24
|
# Add permissions
|
25
25
|
security_block :foreman_scc_manager do
|
@@ -75,7 +75,7 @@ module ForemanSccManager
|
|
75
75
|
end
|
76
76
|
|
77
77
|
initializer 'foreman_scc_manager.register_gettext', after: :load_config_initializers do |_app|
|
78
|
-
locale_dir = File.join(File.expand_path('
|
78
|
+
locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
|
79
79
|
locale_domain = 'foreman_scc_manager'
|
80
80
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
81
81
|
end
|
@@ -31,7 +31,7 @@ namespace :foreman_scc_manager do
|
|
31
31
|
"#{ForemanSccManager::Engine.root}/lib/**/*.rb",
|
32
32
|
"#{ForemanSccManager::Engine.root}/test/**/*.rb"]
|
33
33
|
end
|
34
|
-
rescue
|
34
|
+
rescue StandardError
|
35
35
|
puts 'Rubocop not loaded.'
|
36
36
|
end
|
37
37
|
|
@@ -42,6 +42,4 @@ end
|
|
42
42
|
Rake::Task[:test].enhance ['test:foreman_scc_manager']
|
43
43
|
|
44
44
|
load 'tasks/jenkins.rake'
|
45
|
-
if Rake::Task.task_defined?(:'jenkins:unit')
|
46
|
-
Rake::Task['jenkins:unit'].enhance ['test:foreman_scc_manager', 'foreman_scc_manager:rubocop']
|
47
|
-
end
|
45
|
+
Rake::Task['jenkins:unit'].enhance ['test:foreman_scc_manager', 'foreman_scc_manager:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
|
data/locale/action_names.rb
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
# Autogenerated!
|
2
|
-
_(
|
3
|
-
_(
|
4
|
-
_(
|
5
|
-
_(
|
6
|
-
_(
|
7
|
-
_(
|
8
|
-
_(
|
9
|
-
_(
|
10
|
-
_(
|
11
|
-
_(
|
12
|
-
_(
|
13
|
-
_(
|
14
|
-
_(
|
15
|
-
_(
|
16
|
-
_(
|
17
|
-
_(
|
18
|
-
_(
|
19
|
-
_(
|
20
|
-
_(
|
21
|
-
_(
|
22
|
-
_(
|
23
|
-
_(
|
24
|
-
_(
|
25
|
-
_(
|
26
|
-
_(
|
27
|
-
_(
|
28
|
-
_(
|
29
|
-
_(
|
30
|
-
_(
|
31
|
-
_(
|
32
|
-
_(
|
33
|
-
_(
|
34
|
-
_(
|
35
|
-
_(
|
36
|
-
_(
|
37
|
-
_(
|
38
|
-
_(
|
39
|
-
_(
|
40
|
-
_(
|
41
|
-
_(
|
42
|
-
_(
|
43
|
-
_(
|
44
|
-
_(
|
45
|
-
_(
|
46
|
-
_(
|
47
|
-
_(
|
48
|
-
_(
|
49
|
-
_(
|
50
|
-
_(
|
51
|
-
_(
|
52
|
-
_(
|
53
|
-
_(
|
54
|
-
_(
|
55
|
-
_(
|
56
|
-
_(
|
57
|
-
_(
|
58
|
-
_(
|
59
|
-
_(
|
60
|
-
_(
|
61
|
-
_(
|
2
|
+
_('Delete Lifecycle Environment')
|
3
|
+
_('Destroy Content Host')
|
4
|
+
_('Hypervisors')
|
5
|
+
_('Hypervisors update')
|
6
|
+
_('Install package')
|
7
|
+
_('Remove package')
|
8
|
+
_('Update for host')
|
9
|
+
_('Install Applicable Errata')
|
10
|
+
_('Update package')
|
11
|
+
_('Update')
|
12
|
+
_('Install package group')
|
13
|
+
_('Package Profile Update')
|
14
|
+
_('Configure capsule')
|
15
|
+
_('Auto-attach subscriptions')
|
16
|
+
_('Create repos')
|
17
|
+
_('Create')
|
18
|
+
_('Remove package group')
|
19
|
+
_('Install erratum')
|
20
|
+
_('Register Host')
|
21
|
+
_('Remove subscriptions')
|
22
|
+
_('Unregister Host')
|
23
|
+
_('Delete Activation Key')
|
24
|
+
_('Abstract async task')
|
25
|
+
_('Incremental Update')
|
26
|
+
_('Destroy')
|
27
|
+
_('Synchronize capsule content')
|
28
|
+
_('Product Create')
|
29
|
+
_('Export')
|
30
|
+
_('Delete Product')
|
31
|
+
_('Delete')
|
32
|
+
_('Auto attach subscriptions')
|
33
|
+
_('Reindex subscriptions')
|
34
|
+
_('Errata mail')
|
35
|
+
_('Attach subscriptions')
|
36
|
+
_('Incremental Update of 0 Content View Version(s) ')
|
37
|
+
_('Import Puppet classes')
|
38
|
+
_('Import facts')
|
39
|
+
_('Filtered index content')
|
40
|
+
_('Upload into')
|
41
|
+
_('Action with sub plans')
|
42
|
+
_('Upload errata into')
|
43
|
+
_('Remove from Environment')
|
44
|
+
_('Sync SUSE subscriptions')
|
45
|
+
_('Enable')
|
46
|
+
_('Index errata')
|
47
|
+
_('Remove Version')
|
48
|
+
_('Index package groups')
|
49
|
+
_('Add Sync Plan Products')
|
50
|
+
_('Sync SUSE subscriptions (Products)')
|
51
|
+
_('Remove Content')
|
52
|
+
_('Index content')
|
53
|
+
_('Disable')
|
54
|
+
_('Sync SUSE subscriptions (Repositories)')
|
55
|
+
_('Subscribe SCC Product')
|
56
|
+
_('Remove Versions and Associations')
|
57
|
+
_('Synchronize')
|
58
|
+
_('Publish')
|
59
|
+
_('Update Sync Plan Products')
|
60
|
+
_('Promotion')
|
61
|
+
_('Update Sync Plan')
|
data/test/test_plugin_helper.rb
CHANGED
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
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.4.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: 2018-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rdoc
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.49'
|
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'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: foreman-tasks
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0.10'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.1'
|
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: '5.1'
|
69
69
|
description: Foreman plugin to sync SUSE Customer Center products and repositories
|
70
70
|
into Katello.
|
71
71
|
email:
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- locale/en/foreman_scc_manager.po
|
123
123
|
- locale/foreman_scc_manager.pot
|
124
124
|
- locale/gemspec.rb
|
125
|
+
- test/controllers/foreman_scc_manager/scc_accounts_controller_test.rb
|
125
126
|
- test/factories/foreman_scc_manager_factories.rb
|
126
127
|
- test/test_plugin_helper.rb
|
127
128
|
- test/unit/foreman_scc_manager_test.rb
|
@@ -150,6 +151,7 @@ signing_key:
|
|
150
151
|
specification_version: 4
|
151
152
|
summary: Suse Customer Center plugin for Foreman
|
152
153
|
test_files:
|
154
|
+
- test/controllers/foreman_scc_manager/scc_accounts_controller_test.rb
|
153
155
|
- test/test_plugin_helper.rb
|
154
156
|
- test/unit/foreman_scc_manager_test.rb
|
155
157
|
- test/factories/foreman_scc_manager_factories.rb
|