foreman_scc_manager 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/scc_accounts_controller.rb +10 -4
- data/app/lib/actions/scc_manager/sync.rb +2 -5
- data/app/models/scc_account.rb +10 -11
- data/app/views/scc_accounts/index.html.erb +1 -1
- data/db/migrate/20180321000000_change_sync_status_to_sync_task.rb +7 -0
- data/lib/foreman_scc_manager/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e9a75d883e70453b301cfc95ccdcb3906204f9ae87b5c8abec1f1970bef49f
|
4
|
+
data.tar.gz: 9b5b2d8a57b2a0da65631603bb77f5b3503353aa0095267ffe7bb4724c93049d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1ba3bbdfb6215d48a99ef89a241cf1735de4c085df7e0ee16b849e1bbd786a5734e9b1bfbd79c18ea78d42e2d0440ffbf263e94401b44689a8ef7742b04428
|
7
|
+
data.tar.gz: 6ef467fe3c5deead9ccc7555a30ac4b96257a8ec269f333d3826b5e28e366def180a5940f1f932be8329719cb488e06d0184ee533c0fb862b915ad135bbf5595
|
@@ -65,6 +65,7 @@ class SccAccountsController < ApplicationController
|
|
65
65
|
# PUT /scc_accounts/1/sync
|
66
66
|
def sync
|
67
67
|
sync_task = ForemanTasks.async_task(::Actions::SccManager::Sync, @scc_account)
|
68
|
+
@scc_account.update! sync_task: sync_task
|
68
69
|
notice _('Sync task started.')
|
69
70
|
rescue ::Foreman::Exception => e
|
70
71
|
error _('Failed to add task to queue: %s') % e.to_s
|
@@ -77,10 +78,15 @@ class SccAccountsController < ApplicationController
|
|
77
78
|
def bulk_subscribe
|
78
79
|
scc_products_to_subscribe =
|
79
80
|
@scc_account.scc_products.where(id: scc_bulk_subscribe_params[:scc_subscribe_product_ids])
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
|
82
|
+
if (scc_products_to_subscribe.count > 0)
|
83
|
+
ForemanTasks.async_task(::Actions::BulkAction,
|
84
|
+
::Actions::SccManager::SubscribeProduct,
|
85
|
+
scc_products_to_subscribe)
|
86
|
+
notice _('Task to subscribe products started.')
|
87
|
+
else
|
88
|
+
notice _('No products selected.')
|
89
|
+
end
|
84
90
|
rescue ::Foreman::Exception => e
|
85
91
|
error _('Failed to add task to queue: %s') % e.to_s
|
86
92
|
rescue ForemanTasks::Lock::LockConflict => e
|
@@ -10,18 +10,15 @@ module Actions
|
|
10
10
|
sync_prod_action = plan_action(::Actions::SccManager::SyncProducts, scc_account)
|
11
11
|
plan_self(repo_status: sync_repo_action.output[:status], prod_status: sync_prod_action.output[:status])
|
12
12
|
end
|
13
|
-
scc_account.update! sync_status: 'running'
|
14
13
|
end
|
15
14
|
|
16
15
|
def finalize
|
17
16
|
scc_account = SccAccount.find(input[:scc_account][:id])
|
18
17
|
if input[:repo_status] == 'SUCCESS' && input[:prod_status] == 'SUCCESS'
|
19
|
-
scc_account.
|
20
|
-
scc_account.synced = DateTime.current
|
18
|
+
scc_account.update! synced: DateTime.current
|
21
19
|
else
|
22
|
-
|
20
|
+
raise 'Updating failed'
|
23
21
|
end
|
24
|
-
scc_account.save!
|
25
22
|
end
|
26
23
|
|
27
24
|
def rescue_strategy
|
data/app/models/scc_account.rb
CHANGED
@@ -4,11 +4,10 @@ class SccAccount < ApplicationRecord
|
|
4
4
|
include ForemanTasks::Concerns::ActionSubject
|
5
5
|
encrypts :password
|
6
6
|
|
7
|
-
SYNC_STATI = [nil, 'running', 'successful', 'failed'].freeze
|
8
|
-
|
9
7
|
self.include_root_in_json = false
|
10
8
|
|
11
9
|
belongs_to :organization
|
10
|
+
belongs_to :sync_task, class_name: ForemanTasks::Task
|
12
11
|
has_many :scc_products, dependent: :destroy
|
13
12
|
has_many :scc_repositories, dependent: :destroy
|
14
13
|
|
@@ -18,7 +17,6 @@ class SccAccount < ApplicationRecord
|
|
18
17
|
validates :login, presence: true
|
19
18
|
validates :password, presence: true
|
20
19
|
validates :base_url, presence: true
|
21
|
-
validates :sync_status, inclusion: { in: SYNC_STATI }
|
22
20
|
|
23
21
|
default_scope -> { order(:login) }
|
24
22
|
|
@@ -29,16 +27,17 @@ class SccAccount < ApplicationRecord
|
|
29
27
|
end
|
30
28
|
|
31
29
|
def get_sync_status
|
32
|
-
if
|
30
|
+
if sync_task.nil?
|
33
31
|
return _('never synced')
|
34
|
-
elsif
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
elsif sync_task.state == 'stopped'
|
33
|
+
if sync_task.result == 'success'
|
34
|
+
return synced
|
35
|
+
else
|
36
|
+
return sync_task.result
|
37
|
+
end
|
38
|
+
else
|
39
|
+
return sync_task.state
|
40
40
|
end
|
41
|
-
''
|
42
41
|
end
|
43
42
|
|
44
43
|
def test_connection
|
@@ -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><%= scc_account.get_sync_status %></td>
|
21
|
+
<td><%= link_to_if(scc_account.sync_task, scc_account.get_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)),
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class ChangeSyncStatusToSyncTask < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
remove_column :scc_accounts, :sync_status, :string
|
4
|
+
add_column :scc_accounts, :sync_task_id, :uuid, null: true
|
5
|
+
# add_foreign_key "scc_accounts", "foreman_tasks_tasks", name: "scc_accounts_foreman_tasks_tasks_id_fk", column: "sync_task_id", primary_key: "id" , on_delete: :nullify
|
6
|
+
end
|
7
|
+
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.
|
4
|
+
version: 1.3.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-05-15 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.49
|
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: 0.49
|
40
|
+
version: '0.49'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.10
|
61
|
+
version: '0.10'
|
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.10
|
68
|
+
version: '0.10'
|
69
69
|
description: Foreman plugin to sync SUSE Customer Center products and repositories
|
70
70
|
into Katello.
|
71
71
|
email:
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- db/migrate/20170307092057_add_synced_to_scc_account.rb
|
110
110
|
- db/migrate/20170418132648_add_name_to_scc_account.rb
|
111
111
|
- db/migrate/20170505063726_add_sync_status_to_scc_account.rb
|
112
|
+
- db/migrate/20180321000000_change_sync_status_to_sync_task.rb
|
112
113
|
- lib/foreman_scc_manager.rb
|
113
114
|
- lib/foreman_scc_manager/engine.rb
|
114
115
|
- lib/foreman_scc_manager/version.rb
|