foreman_scc_manager 1.0.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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +619 -0
  3. data/README.md +38 -0
  4. data/Rakefile +47 -0
  5. data/app/assets/javascripts/foreman_scc_manager/scc_accounts.js.coffee +46 -0
  6. data/app/controllers/scc_accounts_controller.rb +118 -0
  7. data/app/controllers/scc_products_controller.rb +24 -0
  8. data/app/helpers/scc_accounts_helper.rb +2 -0
  9. data/app/helpers/scc_product_helper.rb +2 -0
  10. data/app/lib/actions/scc_manager/subscribe_product.rb +72 -0
  11. data/app/lib/actions/scc_manager/sync.rb +36 -0
  12. data/app/lib/actions/scc_manager/sync_products.rb +37 -0
  13. data/app/lib/actions/scc_manager/sync_repositories.rb +36 -0
  14. data/app/lib/scc_manager.rb +37 -0
  15. data/app/models/scc_account.rb +100 -0
  16. data/app/models/scc_extending.rb +4 -0
  17. data/app/models/scc_product.rb +46 -0
  18. data/app/models/scc_repository.rb +25 -0
  19. data/app/views/scc_accounts/_form.html.erb +36 -0
  20. data/app/views/scc_accounts/edit.html.erb +3 -0
  21. data/app/views/scc_accounts/index.html.erb +38 -0
  22. data/app/views/scc_accounts/new.html.erb +3 -0
  23. data/app/views/scc_accounts/show.html.erb +41 -0
  24. data/config/routes.rb +17 -0
  25. data/db/migrate/20170221100619_create_scc_accounts.rb +11 -0
  26. data/db/migrate/20170227103408_create_scc_products.rb +16 -0
  27. data/db/migrate/20170301131641_create_scc_repositories.rb +18 -0
  28. data/db/migrate/20170301141330_create_scc_products_scc_repositories_join_table.rb +8 -0
  29. data/db/migrate/20170301163451_add_product_type_to_scc_product.rb +5 -0
  30. data/db/migrate/20170302082912_remove_repositories_from_scc_products.rb +5 -0
  31. data/db/migrate/20170302121542_create_scc_extendings.rb +12 -0
  32. data/db/migrate/20170303085304_add_organization_to_scc_account.rb +22 -0
  33. data/db/migrate/20170303131704_add_product_id_to_scc_product.rb +6 -0
  34. data/db/migrate/20170307092057_add_synced_to_scc_account.rb +5 -0
  35. data/db/migrate/20170418132648_add_name_to_scc_account.rb +5 -0
  36. data/db/migrate/20170505063726_add_sync_status_to_scc_account.rb +5 -0
  37. data/lib/foreman_scc_manager.rb +4 -0
  38. data/lib/foreman_scc_manager/engine.rb +80 -0
  39. data/lib/foreman_scc_manager/version.rb +3 -0
  40. data/lib/tasks/foreman_scc_manager_tasks.rake +47 -0
  41. data/locale/Makefile +60 -0
  42. data/locale/action_names.rb +61 -0
  43. data/locale/de/LC_MESSAGES/foreman_scc_manager.mo +0 -0
  44. data/locale/de/foreman_scc_manager.po +265 -0
  45. data/locale/en/LC_MESSAGES/foreman_scc_manager.mo +0 -0
  46. data/locale/en/foreman_scc_manager.po +265 -0
  47. data/locale/foreman_scc_manager.pot +345 -0
  48. data/locale/gemspec.rb +2 -0
  49. data/test/factories/foreman_scc_manager_factories.rb +5 -0
  50. data/test/test_plugin_helper.rb +6 -0
  51. data/test/unit/foreman_scc_manager_test.rb +11 -0
  52. metadata +154 -0
@@ -0,0 +1,22 @@
1
+ class AddOrganizationToSccAccount < ActiveRecord::Migration
2
+ class SccAccount < ActiveRecord::Base
3
+ belongs_to :organization
4
+ end
5
+
6
+ class Organization < ActiveRecord::Base
7
+ end
8
+
9
+ def up
10
+ Organization.table_name = 'taxonomies'
11
+ add_column :scc_accounts, :organization_id, :integer, null: true, index: true
12
+ SccAccount.all.each do |a|
13
+ a.organization = Organization.first
14
+ a.save!
15
+ end
16
+ change_column :scc_accounts, :organization_id, :integer, null: false, index: true
17
+ end
18
+
19
+ def down
20
+ remove_column :scc_accounts, :organization_id, :integer
21
+ end
22
+ end
@@ -0,0 +1,6 @@
1
+ class AddProductIdToSccProduct < ActiveRecord::Migration
2
+ def change
3
+ add_column :scc_products, :product_id, :integer, index: true, null: true
4
+ add_foreign_key :scc_products, :katello_products, column: :product_id, on_delete: :nullify
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddSyncedToSccAccount < ActiveRecord::Migration
2
+ def change
3
+ add_column :scc_accounts, :synced, :datetime, default: nil
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddNameToSccAccount < ActiveRecord::Migration
2
+ def change
3
+ add_column :scc_accounts, :name, :string, limit: 255
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddSyncStatusToSccAccount < ActiveRecord::Migration
2
+ def change
3
+ add_column :scc_accounts, :sync_status, :string
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'foreman_scc_manager/engine'
2
+
3
+ module ForemanSccManager
4
+ end
@@ -0,0 +1,80 @@
1
+ module ForemanSccManager
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'foreman_scc_manager'
4
+
5
+ config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
6
+ config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
7
+ config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
8
+ config.autoload_paths += Dir["#{config.root}/app/overrides"]
9
+
10
+ # Add any db migrations
11
+ initializer 'foreman_scc_manager.load_app_instance_data' do |app|
12
+ ForemanSccManager::Engine.paths['db/migrate'].existent.each do |path|
13
+ app.config.paths['db/migrate'] << path
14
+ end
15
+ end
16
+
17
+ initializer 'foreman_scc_manager.register_plugin', :before => :finisher_hook do |_app|
18
+ Foreman::Plugin.register :foreman_scc_manager do
19
+ requires_foreman '>= 1.13'
20
+
21
+ # Add permissions
22
+ security_block :foreman_scc_manager do
23
+ permission :view_scc, :scc_account => [:index, :show]
24
+ permission :use_scc, :scc_account => [:bulk_subscribe]
25
+ # permission :use_scc, :scc_product => [:subscribe, :unsubscribe]
26
+ permission :new_scc, :scc_account => [:new, :create]
27
+ permission :edit_scc, :scc_account => [:edit, :update]
28
+ permission :delete_scc, :scc_account => [:destroy]
29
+ permission :sync_scc, :scc_account => [:sync]
30
+ end
31
+
32
+ # 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]
34
+
35
+ # add menu entry
36
+ menu :top_menu, :scc_manager,
37
+ url_hash: { controller: :scc_accounts, action: :index },
38
+ caption: _('SUSE Subscriptions'),
39
+ parent: :content_menu,
40
+ after: :red_hat_subscriptions
41
+ end
42
+ end
43
+
44
+ initializer 'foreman_scc_manager.register_actions', :before => :finisher_hook do |_app|
45
+ ForemanTasks.dynflow.require!
46
+ action_paths = %W(#{ForemanSccManager::Engine.root}/app/lib/actions)
47
+ ForemanTasks.dynflow.config.eager_load_paths.concat(action_paths)
48
+ end
49
+
50
+ # Precompile any JS or CSS files under app/assets/
51
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
52
+ # content twice.
53
+ assets_to_precompile =
54
+ Dir.chdir(root) do
55
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
56
+ f.split(File::SEPARATOR, 4).last.gsub(/\.coffee\Z/, '')
57
+ end
58
+ end
59
+
60
+ initializer 'foreman_scc_manager.assets.precompile' do |app|
61
+ app.config.assets.precompile += assets_to_precompile
62
+ end
63
+
64
+ initializer 'foreman_scc_manager.configure_assets', group: :assets do
65
+ SETTINGS[:foreman_scc_manager] = { assets: { precompile: assets_to_precompile } }
66
+ end
67
+
68
+ rake_tasks do
69
+ Rake::Task['db:seed'].enhance do
70
+ ForemanSccManager::Engine.load_seed
71
+ end
72
+ end
73
+
74
+ initializer 'foreman_scc_manager.register_gettext', after: :load_config_initializers do |_app|
75
+ locale_dir = File.join(File.expand_path('../../..', __FILE__), 'locale')
76
+ locale_domain = 'foreman_scc_manager'
77
+ Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanSccManager
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'rake/testtask'
2
+
3
+ # Tasks
4
+ namespace :foreman_scc_manager do
5
+ namespace :example do
6
+ desc 'Example Task'
7
+ task task: :environment do
8
+ # Task goes here
9
+ end
10
+ end
11
+ end
12
+
13
+ # Tests
14
+ namespace :test do
15
+ desc 'Test ForemanSccManager'
16
+ Rake::TestTask.new(:foreman_scc_manager) do |t|
17
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
18
+ t.libs << ['test', test_dir]
19
+ t.pattern = "#{test_dir}/**/*_test.rb"
20
+ t.verbose = true
21
+ t.warning = false
22
+ end
23
+ end
24
+
25
+ namespace :foreman_scc_manager do
26
+ task :rubocop do
27
+ begin
28
+ require 'rubocop/rake_task'
29
+ RuboCop::RakeTask.new(:rubocop_foreman_scc_manager) do |task|
30
+ task.patterns = ["#{ForemanSccManager::Engine.root}/app/**/*.rb",
31
+ "#{ForemanSccManager::Engine.root}/lib/**/*.rb",
32
+ "#{ForemanSccManager::Engine.root}/test/**/*.rb"]
33
+ end
34
+ rescue
35
+ puts 'Rubocop not loaded.'
36
+ end
37
+
38
+ Rake::Task['rubocop_foreman_scc_manager'].invoke
39
+ end
40
+ end
41
+
42
+ Rake::Task[:test].enhance ['test:foreman_scc_manager']
43
+
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
@@ -0,0 +1,60 @@
1
+ #
2
+ # Makefile for PO merging and MO generation. More info in the README.
3
+ #
4
+ # make all-mo (default) - generate MO files
5
+ # make check - check translations using translate-tool
6
+ # make tx-update - download and merge translations from Transifex
7
+ # make clean - clean everything
8
+ #
9
+ DOMAIN = foreman_scc_manager
10
+ VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
11
+ POTFILE = $(DOMAIN).pot
12
+ MOFILE = $(DOMAIN).mo
13
+ POFILES = $(shell find . -name '$(DOMAIN).po')
14
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
+ EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
17
+
18
+ %.mo: %.po
19
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
20
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
21
+
22
+ # Generate MO files from PO files
23
+ all-mo: $(MOFILES)
24
+
25
+ # Check for malformed strings
26
+ %.pox: %.po
27
+ msgfmt -c $<
28
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
29
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
30
+ cat $@
31
+ ! grep -q msgid $@
32
+
33
+ %.edit.po:
34
+ touch $@
35
+
36
+ check: $(POXFILES)
37
+
38
+ # Unify duplicate translations
39
+ uniq-po:
40
+ for f in $(shell find ./ -name "*.po") ; do \
41
+ msguniq $$f -o $$f ; \
42
+ done
43
+
44
+ tx-pull: $(EDITFILES)
45
+ tx pull -f
46
+ for f in $(EDITFILES) ; do \
47
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
48
+ done
49
+
50
+ tx-update: tx-pull
51
+ @echo
52
+ @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
53
+ @echo
54
+
55
+ mo-files: $(MOFILES)
56
+ git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
57
+ git commit -m "i18n - pulling from tx"
58
+ @echo
59
+ @echo Changes commited!
60
+ @echo
@@ -0,0 +1,61 @@
1
+ # Autogenerated!
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")
@@ -0,0 +1,265 @@
1
+ # German translations for foreman_scc_manager package.
2
+ # Copyright (C) 2017 THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the foreman_scc_manager package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: foreman_scc_manager 1.0.0\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "PO-Revision-Date: 2017-04-24 12:30+0000\n"
11
+ "Last-Translator: ATIX AG <info@atix.de>\n"
12
+ "Language-Team: German\n"
13
+ "Language: de\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=UTF-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
18
+ "\n"
19
+
20
+ msgid "Abstract async task"
21
+ msgstr ""
22
+
23
+ msgid "Action with sub plans"
24
+ msgstr ""
25
+
26
+ msgid "Actions"
27
+ msgstr ""
28
+
29
+ msgid "Add SCC account"
30
+ msgstr "SCC Zugang hinzufügen"
31
+
32
+ msgid "Add SUSE Customer Center Account"
33
+ msgstr "SUSE Customer Center hinzufügen"
34
+
35
+ msgid "Add Sync Plan Products"
36
+ msgstr ""
37
+
38
+ msgid "Attach subscriptions"
39
+ msgstr ""
40
+
41
+ msgid "Auto attach subscriptions"
42
+ msgstr ""
43
+
44
+ msgid "Auto-attach subscriptions"
45
+ msgstr ""
46
+
47
+ msgid "Base URL"
48
+ msgstr "Basis URL"
49
+
50
+ msgid "Configure capsule"
51
+ msgstr ""
52
+
53
+ msgid "Create"
54
+ msgstr ""
55
+
56
+ msgid "Create repos"
57
+ msgstr ""
58
+
59
+ msgid "Delete"
60
+ msgstr ""
61
+
62
+ msgid "Delete %s?"
63
+ msgstr ""
64
+
65
+ msgid "Delete Activation Key"
66
+ msgstr ""
67
+
68
+ msgid "Delete Lifecycle Environment"
69
+ msgstr ""
70
+
71
+ msgid "Delete Product"
72
+ msgstr ""
73
+
74
+ msgid "Destroy"
75
+ msgstr ""
76
+
77
+ msgid "Destroy Content Host"
78
+ msgstr ""
79
+
80
+ msgid "Disable"
81
+ msgstr ""
82
+
83
+ msgid "Edit"
84
+ msgstr ""
85
+
86
+ msgid "Edit %s"
87
+ msgstr ""
88
+
89
+ msgid "Enable"
90
+ msgstr ""
91
+
92
+ msgid "Errata mail"
93
+ msgstr ""
94
+
95
+ msgid "Export"
96
+ msgstr ""
97
+
98
+ msgid "Failed to add task to queue: %s"
99
+ msgstr "Task konnte nicht in die Warteschlange eingereiht werden: %s"
100
+
101
+ msgid "Filtered index content"
102
+ msgstr ""
103
+
104
+ msgid ""
105
+ "Foreman plugin to sync SUSE Customer Center products and repositories into "
106
+ "Katello."
107
+ msgstr ""
108
+ "Foreman plugin um SUSE Customer Center Producte and Repositories in Katello "
109
+ "zu synchronisieren."
110
+
111
+ msgid "Hypervisors"
112
+ msgstr ""
113
+
114
+ msgid "Hypervisors update"
115
+ msgstr ""
116
+
117
+ msgid "Import Puppet classes"
118
+ msgstr ""
119
+
120
+ msgid "Import facts"
121
+ msgstr ""
122
+
123
+ msgid "Incremental Update"
124
+ msgstr ""
125
+
126
+ msgid "Incremental Update of 0 Content View Version(s) "
127
+ msgstr ""
128
+
129
+ msgid "Index content"
130
+ msgstr ""
131
+
132
+ msgid "Index errata"
133
+ msgstr ""
134
+
135
+ msgid "Index package groups"
136
+ msgstr ""
137
+
138
+ msgid "Install Applicable Errata"
139
+ msgstr ""
140
+
141
+ msgid "Install erratum"
142
+ msgstr ""
143
+
144
+ msgid "Install package"
145
+ msgstr ""
146
+
147
+ msgid "Install package group"
148
+ msgstr ""
149
+
150
+ msgid "Last synced"
151
+ msgstr "Zuletzt synchronisiert"
152
+
153
+ msgid "Lock on SCC account already taken: %s"
154
+ msgstr "Lock für SCC Zugang bereits vergeben: %s"
155
+
156
+ msgid "Package Profile Update"
157
+ msgstr ""
158
+
159
+ msgid "Please sync your SUSE subscriptions first."
160
+ msgstr "Bitte synchronisieren Sie zuerst Ihre SUSE Abonnements."
161
+
162
+ msgid "Product Create"
163
+ msgstr ""
164
+
165
+ msgid "Product already subscribed!"
166
+ msgstr "Produkt bereits abonniert!"
167
+
168
+ msgid "Products"
169
+ msgstr ""
170
+
171
+ msgid "Promotion"
172
+ msgstr ""
173
+
174
+ msgid "Publish"
175
+ msgstr ""
176
+
177
+ msgid "Register Host"
178
+ msgstr ""
179
+
180
+ msgid "Reindex subscriptions"
181
+ msgstr ""
182
+
183
+ msgid "Remove Content"
184
+ msgstr ""
185
+
186
+ msgid "Remove Version"
187
+ msgstr ""
188
+
189
+ msgid "Remove Versions and Associations"
190
+ msgstr ""
191
+
192
+ msgid "Remove from Environment"
193
+ msgstr ""
194
+
195
+ msgid "Remove package"
196
+ msgstr ""
197
+
198
+ msgid "Remove package group"
199
+ msgstr ""
200
+
201
+ msgid "Remove subscriptions"
202
+ msgstr ""
203
+
204
+ msgid "SUSE Customer Center"
205
+ msgstr "SUSE Customer Center"
206
+
207
+ msgid "SUSE Customer Center account"
208
+ msgstr "SUSE Customer Center Zugang"
209
+
210
+ msgid "SUSE Subscriptions"
211
+ msgstr "SUSE Abonnements"
212
+
213
+ msgid "SUSE subscriptions"
214
+ msgstr "SUSE Abonnements"
215
+
216
+ msgid "Subscribe SCC Product"
217
+ msgstr "SCC Produkt abonnieren"
218
+
219
+ msgid "Sync"
220
+ msgstr "Aktualisieren"
221
+
222
+ msgid "Sync SUSE subscriptions"
223
+ msgstr "SUSE Abonnements aktualisieren"
224
+
225
+ msgid "Sync SUSE subscriptions (Products)"
226
+ msgstr "SUSE Abonnements aktualisieren (Produkte)"
227
+
228
+ msgid "Sync SUSE subscriptions (Repositories)"
229
+ msgstr "SUSE Abonnements aktualisieren (Repositories)"
230
+
231
+ msgid "Sync task started."
232
+ msgstr "Sync task gestartet."
233
+
234
+ msgid "Synchronize"
235
+ msgstr "Synchronisieren"
236
+
237
+ msgid "Synchronize capsule content"
238
+ msgstr ""
239
+
240
+ msgid "Test Connection"
241
+ msgstr "Verbindung testen"
242
+
243
+ msgid "Unregister Host"
244
+ msgstr ""
245
+
246
+ msgid "Update"
247
+ msgstr ""
248
+
249
+ msgid "Update Sync Plan"
250
+ msgstr ""
251
+
252
+ msgid "Update Sync Plan Products"
253
+ msgstr ""
254
+
255
+ msgid "Update for host"
256
+ msgstr ""
257
+
258
+ msgid "Update package"
259
+ msgstr ""
260
+
261
+ msgid "Upload errata into"
262
+ msgstr ""
263
+
264
+ msgid "Upload into"
265
+ msgstr ""