foreman_scc_manager 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13d2baaf07d83319e14477fbb5ca896df93f2154
4
- data.tar.gz: 6ad133edc24b85d703fd6a1360152de37032fced
3
+ metadata.gz: daa248fe4014c5156df6c1ab4be7dce1af64659f
4
+ data.tar.gz: 6cf03c575cbc81688eb43965025c4ecfbb33f9b8
5
5
  SHA512:
6
- metadata.gz: 0bc7aac431276b7b866aa82529f783bf98ce46ce63c6c48bbc34eaf188dffea1cd8f40efc114c87d71ddb25c76a11279ee3d223c2baf2df39a058daf58cb22fa
7
- data.tar.gz: d0830f921dfc1dfd93799d4aaeeec5d6c0c1dcaf52dd97036526ea6afcf88219367c6c6fb5744d5fcee88eebc5e382904212e5a6c554622fa581c6b72a8f7fc9
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 :find_resource, only: [:show, :edit, :update, :destroy, :sync, :bulk_subscribe]
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 = Organization.current
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
- begin
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
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
- begin
80
- scc_products_to_subscribe =
81
- @scc_account.scc_products.where(id: scc_bulk_subscribe_params[:scc_subscribe_product_ids])
82
- ForemanTasks.async_task(::Actions::BulkAction,
83
- ::Actions::SccManager::SubscribeProduct,
84
- scc_products_to_subscribe)
85
- notice _("Task to subscribe products started.")
86
- rescue ::Foreman::Exception => e
87
- error _("Failed to add task to queue: %s") % e.to_s
88
- rescue ForemanTasks::Lock::LockConflict => e
89
- error _("Lock on SCC account already taken: %s") % e.to_s
90
- ensure
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: [:show, :subscribe, :unsubscribe]
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' and input[:prod_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
@@ -1,10 +1,10 @@
1
- class SccAccount < ActiveRecord::Base
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 = [ nil, 'running', 'successful', 'failed' ]
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
- validates_inclusion_of :sync_status, in: SYNC_STATI
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 == nil
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
- begin
46
- SccManager::get_scc_data(base_url, '/connect/organizations/subscriptions', login, password)
47
- true
48
- rescue
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)
@@ -1,4 +1,4 @@
1
- class SccExtending < ActiveRecord::Base
1
+ class SccExtending < ApplicationRecord
2
2
  belongs_to :scc_product
3
3
  belongs_to :scc_extension, class_name: :SccProduct
4
4
  end
@@ -1,4 +1,4 @@
1
- class SccProduct < ActiveRecord::Base
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
- return "#{scc_id} " + friendly_name;
23
+ "#{scc_id} " + friendly_name
24
24
  end
25
25
 
26
26
  def subscribe
@@ -1,4 +1,4 @@
1
- class SccRepository < ActiveRecord::Base
1
+ class SccRepository < ApplicationRecord
2
2
  after_commit :token_changed_callback
3
3
 
4
4
  self.include_root_in_json = false
@@ -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
@@ -8,7 +8,7 @@ Rails.application.routes.draw do
8
8
  put 'bulk_subscribe'
9
9
  end
10
10
  end
11
- resources :scc_products, only: [:index, :show] do
11
+ resources :scc_products, only: %i[index show] do
12
12
  member do
13
13
  put 'subscribe'
14
14
  put 'unsubscribe'
@@ -1,9 +1,9 @@
1
1
  class AddOrganizationToSccAccount < ActiveRecord::Migration
2
- class SccAccount < ActiveRecord::Base
2
+ class SccAccount < ApplicationRecord
3
3
  belongs_to :organization
4
4
  end
5
5
 
6
- class Organization < ActiveRecord::Base
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 => [:index, :show]
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 => [:new, :create]
27
- permission :edit_scc, :scc_account => [:edit, :update]
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', [:view_scc, :use_scc, :new_scc, :edit_scc, :delete_scc, :sync_scc]
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(#{ForemanSccManager::Engine.root}/app/lib/actions)
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
 
@@ -1,3 +1,3 @@
1
1
  module ForemanSccManager
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'.freeze
3
3
  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.0.1
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-08-16 00:00:00.000000000 Z
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