foreman_scc_manager 1.0.1 → 1.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 +4 -4
- data/README.md +1 -1
- data/app/controllers/scc_accounts_controller.rb +30 -26
- data/app/controllers/scc_products_controller.rb +1 -1
- data/app/lib/actions/scc_manager/subscribe_product.rb +1 -0
- data/app/lib/actions/scc_manager/sync.rb +1 -1
- data/app/models/scc_account.rb +8 -10
- data/app/models/scc_extending.rb +1 -1
- data/app/models/scc_product.rb +2 -2
- data/app/models/scc_repository.rb +1 -1
- data/app/views/scc_accounts/_form.html.erb +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20170303085304_add_organization_to_scc_account.rb +2 -2
- data/lib/foreman_scc_manager/engine.rb +8 -5
- data/lib/foreman_scc_manager/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa248fe4014c5156df6c1ab4be7dce1af64659f
|
4
|
+
data.tar.gz: 6cf03c575cbc81688eb43965025c4ecfbb33f9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a67ebb39edf2962ed0aa880a7b0da53dcbf01d945f938463c78234a037f3e811967f5b9e7e0a3790c55df2cbe00fc982fdd0e418302b8b23f380f949608c93c
|
7
|
+
data.tar.gz: 2b00b136da8f133584b0082b45e951d0c2219455cf3a949c5352c5871a13270a3ca3a5a50d6b612914cb84293a828554f9d46d1aa65baf18905b7ae6adf6b6bf
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Fork and send a Pull Request. Thanks!
|
|
21
21
|
|
22
22
|
## Copyright
|
23
23
|
|
24
|
-
Copyright (c) 2017 ATIX AG
|
24
|
+
Copyright (c) 2017 ATIX AG - http://www.atix.de
|
25
25
|
|
26
26
|
This program is free software: you can redistribute it and/or modify
|
27
27
|
it under the terms of the GNU General Public License as published by
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class SccAccountsController < ApplicationController
|
2
|
-
before_filter :
|
2
|
+
before_filter :find_organization
|
3
|
+
before_filter :find_resource, only: %i[show edit update destroy sync bulk_subscribe]
|
3
4
|
include Api::TaxonomyScope
|
4
5
|
include Foreman::Controller::AutoCompleteSearch
|
5
6
|
|
@@ -12,7 +13,7 @@ class SccAccountsController < ApplicationController
|
|
12
13
|
# GET /scc_accounts/new
|
13
14
|
def new
|
14
15
|
@scc_account = SccAccount.new
|
15
|
-
@scc_account.organization =
|
16
|
+
@scc_account.organization = @organization
|
16
17
|
end
|
17
18
|
|
18
19
|
# POST /scc_accounts
|
@@ -63,37 +64,40 @@ class SccAccountsController < ApplicationController
|
|
63
64
|
|
64
65
|
# PUT /scc_accounts/1/sync
|
65
66
|
def sync
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
redirect_to scc_accounts_path
|
75
|
-
end
|
67
|
+
sync_task = ForemanTasks.async_task(::Actions::SccManager::Sync, @scc_account)
|
68
|
+
notice _('Sync task started.')
|
69
|
+
rescue ::Foreman::Exception => e
|
70
|
+
error _('Failed to add task to queue: %s') % e.to_s
|
71
|
+
rescue ForemanTasks::Lock::LockConflict => e
|
72
|
+
error _('Lock on SCC account already taken: %s') % e.to_s
|
73
|
+
ensure
|
74
|
+
redirect_to scc_accounts_path
|
76
75
|
end
|
77
76
|
|
78
77
|
def bulk_subscribe
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
redirect_to scc_accounts_path
|
92
|
-
end
|
78
|
+
scc_products_to_subscribe =
|
79
|
+
@scc_account.scc_products.where(id: scc_bulk_subscribe_params[:scc_subscribe_product_ids])
|
80
|
+
ForemanTasks.async_task(::Actions::BulkAction,
|
81
|
+
::Actions::SccManager::SubscribeProduct,
|
82
|
+
scc_products_to_subscribe)
|
83
|
+
notice _('Task to subscribe products started.')
|
84
|
+
rescue ::Foreman::Exception => e
|
85
|
+
error _('Failed to add task to queue: %s') % e.to_s
|
86
|
+
rescue ForemanTasks::Lock::LockConflict => e
|
87
|
+
error _('Lock on SCC account already taken: %s') % e.to_s
|
88
|
+
ensure
|
89
|
+
redirect_to scc_accounts_path
|
93
90
|
end
|
94
91
|
|
95
92
|
private
|
96
93
|
|
94
|
+
def find_organization
|
95
|
+
@organization = Organization.current
|
96
|
+
unless @organization
|
97
|
+
redirect_to '/select_organization?toState=' + request.path
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
97
101
|
# Use callbacks to share common setup or constraints between actions.
|
98
102
|
# Only allow a trusted parameter "white list" through.
|
99
103
|
def scc_account_params
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class SccProductsController < ApplicationController
|
2
|
-
before_filter :find_resource, only: [
|
2
|
+
before_filter :find_resource, only: %i[show subscribe unsubscribe]
|
3
3
|
include Api::TaxonomyScope
|
4
4
|
include Foreman::Controller::AutoCompleteSearch
|
5
5
|
|
@@ -65,6 +65,7 @@ module Actions
|
|
65
65
|
repository.arch = input[:arch]
|
66
66
|
repository.mirror_on_sync = true
|
67
67
|
repository.verify_ssl_on_sync = true
|
68
|
+
repository.download_policy = ::Runcible::Models::YumImporter::DOWNLOAD_IMMEDIATE
|
68
69
|
trigger(::Actions::Katello::Repository::Create, repository, false, false)
|
69
70
|
end
|
70
71
|
end
|
@@ -15,7 +15,7 @@ module Actions
|
|
15
15
|
|
16
16
|
def finalize
|
17
17
|
scc_account = SccAccount.find(input[:scc_account][:id])
|
18
|
-
if input[:repo_status] == 'SUCCESS'
|
18
|
+
if input[:repo_status] == 'SUCCESS' && input[:prod_status] == 'SUCCESS'
|
19
19
|
scc_account.sync_status = 'successful'
|
20
20
|
scc_account.synced = DateTime.current
|
21
21
|
else
|
data/app/models/scc_account.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
class SccAccount <
|
1
|
+
class SccAccount < ApplicationRecord
|
2
2
|
include Authorizable
|
3
3
|
include Encryptable
|
4
4
|
include ForemanTasks::Concerns::ActionSubject
|
5
5
|
encrypts :password
|
6
6
|
|
7
|
-
SYNC_STATI = [
|
7
|
+
SYNC_STATI = [nil, 'running', 'successful', 'failed'].freeze
|
8
8
|
|
9
9
|
self.include_root_in_json = false
|
10
10
|
|
@@ -18,7 +18,7 @@ class SccAccount < ActiveRecord::Base
|
|
18
18
|
validates :login, presence: true
|
19
19
|
validates :password, presence: true
|
20
20
|
validates :base_url, presence: true
|
21
|
-
|
21
|
+
validates :sync_status, inclusion: { in: SYNC_STATI }
|
22
22
|
|
23
23
|
default_scope -> { order(:login) }
|
24
24
|
|
@@ -29,7 +29,7 @@ class SccAccount < ActiveRecord::Base
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def get_sync_status
|
32
|
-
if sync_status
|
32
|
+
if sync_status.nil?
|
33
33
|
return _('never synced')
|
34
34
|
elsif sync_status == 'running'
|
35
35
|
return _('sync in progress')
|
@@ -42,12 +42,10 @@ class SccAccount < ActiveRecord::Base
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_connection
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
false
|
50
|
-
end
|
45
|
+
SccManager.get_scc_data(base_url, '/connect/organizations/subscriptions', login, password)
|
46
|
+
true
|
47
|
+
rescue
|
48
|
+
false
|
51
49
|
end
|
52
50
|
|
53
51
|
def update_scc_repositories(upstream_repositories)
|
data/app/models/scc_extending.rb
CHANGED
data/app/models/scc_product.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class SccProduct <
|
1
|
+
class SccProduct < ApplicationRecord
|
2
2
|
include Authorizable
|
3
3
|
include ForemanTasks::Concerns::ActionSubject
|
4
4
|
|
@@ -20,7 +20,7 @@ class SccProduct < ActiveRecord::Base
|
|
20
20
|
scoped_search on: :name, complete_value: true
|
21
21
|
|
22
22
|
def uniq_name
|
23
|
-
|
23
|
+
"#{scc_id} " + friendly_name
|
24
24
|
end
|
25
25
|
|
26
26
|
def subscribe
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<div class="tab-pane active" id="primary">
|
11
11
|
<div>
|
12
12
|
<%= text_f f, :name %>
|
13
|
-
<%= text_f f, :login %>
|
13
|
+
<%= text_f f, :login, :help_block => _("Use your 'Organization credentials' obtained from the SUSE Customer Center.") %>
|
14
14
|
<%= password_f f, :password %>
|
15
15
|
<%= text_f f, :base_url, label: _('Base URL') %>
|
16
16
|
<div class='clearfix'>
|
data/config/routes.rb
CHANGED
@@ -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
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'katello'
|
2
|
+
|
1
3
|
module ForemanSccManager
|
2
4
|
class Engine < ::Rails::Engine
|
3
5
|
engine_name 'foreman_scc_manager'
|
@@ -17,20 +19,21 @@ module ForemanSccManager
|
|
17
19
|
initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
|
18
20
|
Foreman::Plugin.register :foreman_scc_manager do
|
19
21
|
requires_foreman '>= 1.13'
|
22
|
+
requires_foreman_plugin 'katello', '>= 3.2.0'
|
20
23
|
|
21
24
|
# Add permissions
|
22
25
|
security_block :foreman_scc_manager do
|
23
|
-
permission :view_scc, :scc_account => [
|
26
|
+
permission :view_scc, :scc_account => %i[index show]
|
24
27
|
permission :use_scc, :scc_account => [:bulk_subscribe]
|
25
28
|
# permission :use_scc, :scc_product => [:subscribe, :unsubscribe]
|
26
|
-
permission :new_scc, :scc_account => [
|
27
|
-
permission :edit_scc, :scc_account => [
|
29
|
+
permission :new_scc, :scc_account => %i[new create]
|
30
|
+
permission :edit_scc, :scc_account => %i[edit update]
|
28
31
|
permission :delete_scc, :scc_account => [:destroy]
|
29
32
|
permission :sync_scc, :scc_account => [:sync]
|
30
33
|
end
|
31
34
|
|
32
35
|
# Add a new role called 'SccManager' if it doesn't exist
|
33
|
-
role 'SccManager', [
|
36
|
+
role 'SccManager', %i[view_scc use_scc new_scc edit_scc delete_scc sync_scc]
|
34
37
|
|
35
38
|
# add menu entry
|
36
39
|
menu :top_menu, :scc_manager,
|
@@ -43,7 +46,7 @@ module ForemanSccManager
|
|
43
46
|
|
44
47
|
initializer 'foreman_scc_manager.register_actions', :before => :finisher_hook do |_app|
|
45
48
|
ForemanTasks.dynflow.require!
|
46
|
-
action_paths = %W
|
49
|
+
action_paths = %W[#{ForemanSccManager::Engine.root}/app/lib/actions]
|
47
50
|
ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
|
48
51
|
end
|
49
52
|
|
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.0
|
4
|
+
version: 1.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: 2017-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -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
|
147
|
+
rubygems_version: 2.5.2.1
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Suse Customer Center plugin for Foreman
|