foreman_scc_manager 1.8.7 → 1.8.12
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 +14 -8
- data/app/controllers/scc_accounts_controller.rb +1 -1
- data/app/lib/scc_manager.rb +3 -8
- data/app/models/scc_account.rb +2 -7
- data/config/routes.rb +1 -1
- data/db/migrate/20210224095050_connect_katello_root_repository_to_scc_repository.rb +11 -0
- data/db/migrate/20210713092440_add_permissions.rb +19 -0
- data/lib/foreman_scc_manager/engine.rb +26 -6
- data/lib/foreman_scc_manager/version.rb +1 -1
- data/locale/de/foreman_scc_manager.edit.po +125 -128
- data/locale/en/foreman_scc_manager.edit.po +99 -103
- data/test/controllers/api/v2/scc_accounts_test.rb +46 -1
- data/test/controllers/scc_accounts_controller_test.rb +51 -1
- data/test/fixtures/models/scc_accounts.yml +2 -0
- data/test/unit/access_permissions_test.rb +16 -0
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f09d1fba685e2d82d20dcc19d519dfce35a1b6bd04b6c64353e2e40519b30fc9
|
4
|
+
data.tar.gz: afdb4e0f4c17546b8984c7b29d3bebfce35fa9043fb308a60423c8f113df2b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93779edde27305d62942cdcce50ba8dd548af379f0ff9b88fd7fe800b79bb3de41c58f6e873b116451ba20fbd65c89f6ab0428fbe7f8c7f25f07bc26982054f1
|
7
|
+
data.tar.gz: 0c58463cfd08bf269ae9c3a6ba2b0c833f1327d5985038cf32b38ff60a3a307377498759ca6cb11734de7a31122b2743bd9a8cb84a454cc8b6167682925c14a4
|
data/README.md
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
|
1
|
+

|
2
|
+

|
3
|
+
[](https://badge.fury.io/rb/foreman_scc_manager)
|
2
4
|
|
3
|
-
#
|
5
|
+
# Foreman SCC Manager
|
4
6
|
|
5
|
-
Foreman plugin to sync SUSE Customer Center products and repositories into Katello
|
7
|
+
Foreman plugin to sync SUSE Customer Center products and repositories into Katello.
|
6
8
|
|
7
9
|
## Installation
|
8
10
|
|
9
|
-
See [
|
10
|
-
for how to install Foreman plugins
|
11
|
+
See [Foreman Manual](https://theforeman.org/plugins/#2.Installation) on how to install Foreman plugins.
|
11
12
|
|
12
13
|
## Compatibility
|
13
14
|
|
14
15
|
| Foreman Version | Katello Version | Plugin Version |
|
15
16
|
| --------------- | --------------- | -------------- |
|
17
|
+
| 2.3 | 3.18 | ~> 1.8.9 |
|
16
18
|
| 2.1 | 3.16 | ~> 1.8.5 |
|
17
19
|
| 2.0 | 3.16 | ~> 1.8.4 |
|
18
20
|
| 1.24 | 3.14 | ~> 1.8.0 |
|
@@ -26,7 +28,12 @@ for how to install Foreman plugins
|
|
26
28
|
| 1.15 | 3.4 | ~> 1.1.0 |
|
27
29
|
|
28
30
|
## Documentation
|
29
|
-
|
31
|
+
|
32
|
+
[Plugin documentation](https://docs.orcharhino.com/sources/management_ui/the_content_menu/suse_subscriptions.html)
|
33
|
+
|
34
|
+
## Hammer CLI Extension
|
35
|
+
|
36
|
+
[Hammer CLI for Foreman SCC Manager](https://github.com/ATIX-AG/hammer-cli-foreman-scc-manager)
|
30
37
|
|
31
38
|
## Contributing
|
32
39
|
|
@@ -34,7 +41,7 @@ Fork and send a Pull Request. Thanks!
|
|
34
41
|
|
35
42
|
## Copyright
|
36
43
|
|
37
|
-
Copyright (c)
|
44
|
+
Copyright (c) 2021 ATIX AG - https://atix.de
|
38
45
|
|
39
46
|
This program is free software: you can redistribute it and/or modify
|
40
47
|
it under the terms of the GNU General Public License as published by
|
@@ -48,4 +55,3 @@ GNU General Public License for more details.
|
|
48
55
|
|
49
56
|
You should have received a copy of the GNU General Public License
|
50
57
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
51
|
-
|
@@ -2,7 +2,7 @@ class SccAccountsController < ApplicationController
|
|
2
2
|
helper_method :scc_filtered_products
|
3
3
|
before_action :find_organization
|
4
4
|
before_action :find_resource, only: %i[show edit update destroy sync bulk_subscribe]
|
5
|
-
before_action :find_available_gpg_keys, only: %i[new edit]
|
5
|
+
before_action :find_available_gpg_keys, only: %i[new edit update create]
|
6
6
|
include Foreman::Controller::AutoCompleteSearch
|
7
7
|
|
8
8
|
# GET /scc_accounts
|
data/app/lib/scc_manager.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
module SccManager
|
2
2
|
# adapted from https://github.com/SUSE/connect
|
3
3
|
def self.get_scc_data(base_url, rest_url, login, password)
|
4
|
-
if
|
5
|
-
|
6
|
-
uri =
|
7
|
-
|
8
|
-
uri.scheme = URI.parse(proxy_config[:host]).scheme
|
9
|
-
uri.host = URI.parse(proxy_config[:host]).host
|
10
|
-
uri.port = proxy_config[:port].try(:to_s)
|
11
|
-
uri.user = proxy_config[:user]
|
4
|
+
if (proxy_config = ::HttpProxy.default_global_content_proxy)
|
5
|
+
uri = URI(proxy_config[:url])
|
6
|
+
uri.user = proxy_config[:username]
|
12
7
|
uri.password = proxy_config[:password] if uri.user.present?
|
13
8
|
|
14
9
|
RestClient.proxy = uri.to_s
|
data/app/models/scc_account.rb
CHANGED
@@ -45,12 +45,7 @@ class SccAccount < ApplicationRecord
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def sync_date_is_valid_datetime
|
48
|
-
errors.add(:sync_date, 'must be a valid datetime') if interval != NEVER &&
|
49
|
-
sync_date.present? &&
|
50
|
-
!sync_date.respond_to?(:min) &&
|
51
|
-
!sync_date.respond_to?(:hour) &&
|
52
|
-
!sync_date.respond_to?(:wday) &&
|
53
|
-
!sync_date.respond_to?(:day)
|
48
|
+
errors.add(:sync_date, 'must be a valid datetime') if interval != NEVER && sync_date.blank?
|
54
49
|
end
|
55
50
|
|
56
51
|
def to_s
|
@@ -104,7 +99,7 @@ class SccAccount < ApplicationRecord
|
|
104
99
|
end
|
105
100
|
|
106
101
|
def add_recurring_logic(sync_date, interval)
|
107
|
-
sd = sync_date
|
102
|
+
sd = sync_date.presence || Time.now
|
108
103
|
|
109
104
|
raise _('Interval cannot be nil') if interval.nil?
|
110
105
|
|
data/config/routes.rb
CHANGED
@@ -23,7 +23,7 @@ Rails.application.routes.draw do
|
|
23
23
|
:defaults => { :apiv => 'v2' },
|
24
24
|
:apiv => /v1|v2/,
|
25
25
|
:constraints => ApiConstraints.new(:version => 2, :default => true) do
|
26
|
-
resources :scc_accounts do
|
26
|
+
resources :scc_accounts, except: %i[new edit] do
|
27
27
|
collection do
|
28
28
|
post 'test_connection'
|
29
29
|
get 'auto_complete_search'
|
@@ -1,4 +1,15 @@
|
|
1
1
|
class ConnectKatelloRootRepositoryToSccRepository < ActiveRecord::Migration[5.2]
|
2
|
+
# add SccRepository class, because original one triggers the token_changed_callback
|
3
|
+
# which tried to update Katello root repositories
|
4
|
+
class SccRepository < ApplicationRecord
|
5
|
+
belongs_to :katello_root_repository, class_name: 'Katello::RootRepository'
|
6
|
+
end
|
7
|
+
|
8
|
+
class SccProduct < ApplicationRecord
|
9
|
+
belongs_to :product, class_name: 'Katello::Product'
|
10
|
+
has_and_belongs_to_many :scc_repositories
|
11
|
+
end
|
12
|
+
|
2
13
|
def up
|
3
14
|
SccProduct.where.not(product_id: nil).each do |scc_p|
|
4
15
|
# extract all katello root repository ids from subscribed products
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AddPermissions < ActiveRecord::Migration[6.0]
|
2
|
+
PRODUCT_PERMISSION_NAMES = [
|
3
|
+
'view_scc_products',
|
4
|
+
'subscribe_scc_products'
|
5
|
+
].freeze
|
6
|
+
|
7
|
+
def up
|
8
|
+
Permission.create!(:name => 'test_connection_scc_accounts', :resource_type => 'SccAccount')
|
9
|
+
PRODUCT_PERMISSION_NAMES.each do |p|
|
10
|
+
Permission.create!(:name => p, :resource_type => SccProduct)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def down
|
15
|
+
(PRODUCT_PERMISSION_NAMES + ['test_connection_scc_accounts']).each do |p|
|
16
|
+
Permission.where(:name => p).destroy_all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -22,16 +22,18 @@ module ForemanSccManager
|
|
22
22
|
|
23
23
|
initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
|
24
24
|
Foreman::Plugin.register :foreman_scc_manager do
|
25
|
-
requires_foreman '>= 1
|
26
|
-
requires_foreman_plugin 'katello', '>= 3.
|
25
|
+
requires_foreman '>= 2.1'
|
26
|
+
requires_foreman_plugin 'katello', '>= 3.16.0'
|
27
|
+
|
28
|
+
precompile_assets 'foreman_scc_manager/scc_accounts.js'
|
27
29
|
|
28
30
|
apipie_documented_controllers ["#{ForemanSccManager::Engine.root}/app/controllers/api/v2/*.rb"]
|
29
31
|
|
30
32
|
# Add permissions
|
31
33
|
security_block :foreman_scc_manager do
|
32
34
|
permission :view_scc_accounts,
|
33
|
-
{ :scc_accounts => [:show, :index],
|
34
|
-
:'api/v2/scc_accounts' => [:show, :index] },
|
35
|
+
{ :scc_accounts => [:show, :index, :auto_complete_search],
|
36
|
+
:'api/v2/scc_accounts' => [:show, :index, :auto_complete_search] },
|
35
37
|
:resource_type => 'SccAccount'
|
36
38
|
|
37
39
|
permission :use_scc_accounts,
|
@@ -58,15 +60,33 @@ module ForemanSccManager
|
|
58
60
|
{ :scc_accounts => [:sync],
|
59
61
|
:'api/v2/scc_accounts' => [:sync] },
|
60
62
|
:resource_type => 'SccAccount'
|
63
|
+
|
64
|
+
permission :test_connection_scc_accounts,
|
65
|
+
{ :scc_accounts => [:test_connection],
|
66
|
+
:'api/v2/scc_accounts' => [:test_connection] },
|
67
|
+
:resource_type => 'SccAccount'
|
68
|
+
|
69
|
+
permission :view_scc_products,
|
70
|
+
{ :scc_products => [:index, :show],
|
71
|
+
:'api/v2/scc_products' => [:index, :show] },
|
72
|
+
:resource_type => 'SccProduct'
|
73
|
+
|
74
|
+
permission :subscribe_scc_products,
|
75
|
+
{ :scc_products => [:subscribe, :unsubscribe],
|
76
|
+
:'api/v2/scc_products' => [:subscribe, :unsibscribe] },
|
77
|
+
:resource_type => 'SccProduct'
|
61
78
|
end
|
62
79
|
|
63
80
|
# Add a new role called 'SccManager' if it doesn't exist
|
64
81
|
role 'SccManager',
|
65
|
-
%i[view_scc_accounts use_scc_accounts new_scc_accounts edit_scc_accounts
|
82
|
+
%i[view_scc_accounts use_scc_accounts new_scc_accounts edit_scc_accounts
|
83
|
+
delete_scc_accounts sync_scc_accounts test_connection_scc_accounts
|
84
|
+
view_scc_products subscribe_scc_products],
|
66
85
|
'Role granting permissons to manage SUSE Subscriptions'
|
67
86
|
|
68
87
|
role 'SccViewer',
|
69
|
-
%i[view_scc_accounts use_scc_accounts sync_scc_accounts
|
88
|
+
%i[view_scc_accounts use_scc_accounts sync_scc_accounts
|
89
|
+
create_products view_products subscribe_scc_products view_scc_products],
|
70
90
|
'Role granting permissons to view and use SUSE Subscriptions'
|
71
91
|
|
72
92
|
add_all_permissions_to_default_roles
|