foreman_content 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -1
  3. data/app/controllers/content/api/repositories_controller.rb +3 -5
  4. data/app/controllers/content/content_views_controller.rb +48 -0
  5. data/app/controllers/content/products_controller.rb +1 -1
  6. data/app/controllers/content/repositories_controller.rb +9 -6
  7. data/app/helpers/content/content_views_helper.rb +21 -0
  8. data/app/helpers/content/products_helper.rb +9 -0
  9. data/app/helpers/content/repositories_helper.rb +3 -49
  10. data/app/models/concerns/content/environment_extensions.rb +2 -2
  11. data/app/models/concerns/content/home_helper.rb +1 -0
  12. data/app/models/concerns/content/host_extensions.rb +17 -1
  13. data/app/models/concerns/content/hostgroup_extensions.rb +14 -0
  14. data/app/models/concerns/content/operatingsystem_extensions.rb +6 -5
  15. data/app/models/concerns/content/orchestration/pulp/clone.rb +77 -0
  16. data/app/models/concerns/content/orchestration/pulp/sync.rb +70 -0
  17. data/app/models/concerns/content/orchestration/pulp.rb +25 -0
  18. data/app/models/content/available_content_view.rb +12 -0
  19. data/app/models/content/content_view.rb +66 -0
  20. data/app/models/content/content_view_host.rb +9 -0
  21. data/app/models/content/content_view_repository_clone.rb +5 -0
  22. data/app/models/content/host_product.rb +0 -11
  23. data/app/models/content/hostgroup_product.rb +0 -11
  24. data/app/models/content/operatingsystem_repository.rb +0 -11
  25. data/app/models/content/product.rb +6 -5
  26. data/app/models/content/repository/operating_system.rb +14 -0
  27. data/app/models/content/repository/product.rb +21 -0
  28. data/app/models/content/repository.rb +28 -39
  29. data/app/models/content/repository_clone.rb +29 -0
  30. data/app/models/content/validators/content_validator.rb +0 -12
  31. data/app/models/content/validators/description_format.rb +0 -12
  32. data/app/models/content/validators/no_trailing_space.rb +0 -12
  33. data/app/models/setting/content.rb +0 -18
  34. data/app/overrides/{add_host_conent_tab.rb → add_host_content_tab.rb} +2 -2
  35. data/app/overrides/{add_hostgroup_conent_tab.rb → add_hostgroup_content_tab.rb} +1 -1
  36. data/app/services/content/content_view_factory.rb +41 -0
  37. data/app/services/content/{pulp_configuration.rb → pulp/configuration.rb} +1 -1
  38. data/app/services/content/pulp/event_handler.rb +61 -0
  39. data/app/services/content/pulp/repository.rb +200 -0
  40. data/app/services/content/pulp/repository_clone.rb +24 -0
  41. data/app/services/content/pulp/repository_sync_history.rb +35 -0
  42. data/app/services/content/pulp/repository_sync_status.rb +30 -0
  43. data/app/views/content/content_views/_form.html.erb +49 -0
  44. data/app/views/content/content_views/_form_tab.html.erb +3 -0
  45. data/app/views/content/content_views/_host_tab_pane.html.erb +5 -0
  46. data/app/views/content/content_views/_step1.html.erb +18 -0
  47. data/app/views/content/content_views/_step2.html.erb +16 -0
  48. data/app/views/content/content_views/edit.html.erb +5 -0
  49. data/app/views/content/content_views/index.html.erb +27 -0
  50. data/app/views/content/content_views/new.html.erb +11 -0
  51. data/app/views/content/products/_form.html.erb +2 -13
  52. data/app/views/content/products/_form_tab.html.erb +3 -3
  53. data/app/views/content/products/_hostgroup_tab_pane.html.erb +2 -2
  54. data/app/views/content/products/index.html.erb +6 -1
  55. data/app/views/content/repositories/_os_form.html.erb +22 -0
  56. data/app/views/content/repositories/{_form.html.erb → _product_form.html.erb} +4 -6
  57. data/app/views/content/repositories/edit.html.erb +5 -2
  58. data/app/views/content/repositories/index.html.erb +12 -9
  59. data/app/views/content/repositories/new.html.erb +5 -2
  60. data/app/views/content/repositories/show.html.erb +9 -16
  61. data/config/environment.rb +0 -0
  62. data/config/routes.rb +6 -0
  63. data/db/migrate/20130702140034_create_content_repositories.rb +6 -2
  64. data/db/migrate/20130722084911_create_content_operatingsystem_repositories.rb +1 -1
  65. data/db/migrate/20130807121629_create_content_content_views.rb +15 -0
  66. data/db/migrate/20130807123220_create_content_available_content_views.rb +11 -0
  67. data/db/migrate/20130812154754_create_content_content_view_hosts.rb +9 -0
  68. data/db/migrate/20130813110455_create_content_repository_clones.rb +17 -0
  69. data/db/migrate/20130825145431_create_content_content_view_repository_clones.rb +12 -0
  70. data/lib/content/engine.rb +2 -0
  71. data/lib/content/version.rb +1 -1
  72. data/test/fixtures/content/repository_clones.yml +21 -0
  73. data/test/unit/content/repository_clone_test.rb +7 -0
  74. metadata +44 -17
  75. data/app/models/concerns/content/custom_repository_paths.rb +0 -29
  76. data/app/models/content/environment_product.rb +0 -19
  77. data/app/models/content/orchestration/pulp.rb +0 -93
  78. data/app/models/content/product_operatingsystem.rb +0 -19
  79. data/app/models/content/remote/pulp/repository.rb +0 -48
  80. data/app/overrides/add_os_conent_tab.rb +0 -9
  81. data/app/services/content/pulp_event_handler.rb +0 -25
  82. data/app/views/content/products/_host_tab_pane.html.erb +0 -5
  83. data/app/views/content/products/_operatingsystem_tab_pane.html.erb +0 -5
  84. data/db/migrate/20130717032320_create_content_environments_products.rb +0 -9
  85. data/db/migrate/20130729032320_create_content_product_operatingsystems.rb +0 -9
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_content
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitri Dolguikh
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-05 00:00:00.000000000 Z
13
+ date: 2013-08-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -80,11 +80,13 @@ extra_rdoc_files:
80
80
  - README.md
81
81
  files:
82
82
  - app/models/setting/content.rb
83
- - app/models/content/remote/pulp/repository.rb
83
+ - app/models/content/content_view_repository_clone.rb
84
+ - app/models/content/repository_clone.rb
84
85
  - app/models/content/host_product.rb
85
- - app/models/content/product_operatingsystem.rb
86
+ - app/models/content/repository/operating_system.rb
87
+ - app/models/content/repository/product.rb
88
+ - app/models/content/content_view_host.rb
86
89
  - app/models/content/gpg_key.rb
87
- - app/models/content/orchestration/pulp.rb
88
90
  - app/models/content/hostgroup_product.rb
89
91
  - app/models/content/operatingsystem_repository.rb
90
92
  - app/models/content/validators/no_trailing_space.rb
@@ -92,21 +94,29 @@ files:
92
94
  - app/models/content/validators/content_validator.rb
93
95
  - app/models/content/validators/description_format.rb
94
96
  - app/models/content/repository.rb
97
+ - app/models/content/content_view.rb
98
+ - app/models/content/available_content_view.rb
95
99
  - app/models/content/product.rb
96
- - app/models/content/environment_product.rb
97
100
  - app/models/concerns/content/taxonomy_extensions.rb
98
101
  - app/models/concerns/content/hostgroup_extensions.rb
99
102
  - app/models/concerns/content/environment_extensions.rb
100
103
  - app/models/concerns/content/operatingsystem_extensions.rb
101
- - app/models/concerns/content/custom_repository_paths.rb
104
+ - app/models/concerns/content/orchestration/pulp/clone.rb
105
+ - app/models/concerns/content/orchestration/pulp/sync.rb
106
+ - app/models/concerns/content/orchestration/pulp.rb
102
107
  - app/models/concerns/content/home_helper.rb
103
108
  - app/models/concerns/content/host_extensions.rb
104
109
  - app/models/concerns/content/redhat_extensions.rb
105
- - app/services/content/pulp_event_handler.rb
106
- - app/services/content/pulp_configuration.rb
107
- - app/overrides/add_os_conent_tab.rb
108
- - app/overrides/add_host_conent_tab.rb
109
- - app/overrides/add_hostgroup_conent_tab.rb
110
+ - app/services/content/content_view_factory.rb
111
+ - app/services/content/pulp/repository_sync_history.rb
112
+ - app/services/content/pulp/repository_clone.rb
113
+ - app/services/content/pulp/configuration.rb
114
+ - app/services/content/pulp/event_handler.rb
115
+ - app/services/content/pulp/repository_sync_status.rb
116
+ - app/services/content/pulp/repository.rb
117
+ - app/overrides/add_host_content_tab.rb
118
+ - app/overrides/add_hostgroup_content_tab.rb
119
+ - app/controllers/content/content_views_controller.rb
110
120
  - app/controllers/content/api/repositories_controller.rb
111
121
  - app/controllers/content/repositories_controller.rb
112
122
  - app/controllers/content/products_controller.rb
@@ -115,34 +125,47 @@ files:
115
125
  - app/views/content/gpg_keys/new.html.erb
116
126
  - app/views/content/gpg_keys/index.html.erb
117
127
  - app/views/content/gpg_keys/edit.html.erb
118
- - app/views/content/repositories/_form.html.erb
119
128
  - app/views/content/repositories/new.html.erb
120
129
  - app/views/content/repositories/show.html.erb
130
+ - app/views/content/repositories/_product_form.html.erb
131
+ - app/views/content/repositories/_os_form.html.erb
121
132
  - app/views/content/repositories/index.html.erb
122
133
  - app/views/content/repositories/welcome.html.erb
123
134
  - app/views/content/repositories/edit.html.erb
135
+ - app/views/content/content_views/_form.html.erb
136
+ - app/views/content/content_views/new.html.erb
137
+ - app/views/content/content_views/_step1.html.erb
138
+ - app/views/content/content_views/_form_tab.html.erb
139
+ - app/views/content/content_views/_step2.html.erb
140
+ - app/views/content/content_views/index.html.erb
141
+ - app/views/content/content_views/_host_tab_pane.html.erb
142
+ - app/views/content/content_views/edit.html.erb
124
143
  - app/views/content/products/_form.html.erb
125
144
  - app/views/content/products/new.html.erb
126
- - app/views/content/products/_operatingsystem_tab_pane.html.erb
127
145
  - app/views/content/products/_form_tab.html.erb
128
146
  - app/views/content/products/_hostgroup_tab_pane.html.erb
129
147
  - app/views/content/products/index.html.erb
130
- - app/views/content/products/_host_tab_pane.html.erb
131
148
  - app/views/content/products/welcome.html.erb
132
149
  - app/views/content/products/edit.html.erb
150
+ - app/helpers/content/products_helper.rb
151
+ - app/helpers/content/content_views_helper.rb
133
152
  - app/helpers/content/repositories_helper.rb
134
153
  - app/helpers/content/application_helper.rb
135
154
  - app/assets/javascripts/content/content.js
136
155
  - app/assets/stylesheets/content/application.css
156
+ - config/environment.rb
137
157
  - config/routes.rb
158
+ - db/migrate/20130807121629_create_content_content_views.rb
138
159
  - db/migrate/20130702162629_create_content_products.rb
139
160
  - db/migrate/20130709001120_create_content_gpg_keys.rb
140
161
  - db/migrate/20130722084911_create_content_operatingsystem_repositories.rb
141
- - db/migrate/20130717032320_create_content_environments_products.rb
142
162
  - db/migrate/20130723124911_create_content_host_products.rb
143
- - db/migrate/20130729032320_create_content_product_operatingsystems.rb
144
163
  - db/migrate/20130702140034_create_content_repositories.rb
164
+ - db/migrate/20130807123220_create_content_available_content_views.rb
165
+ - db/migrate/20130813110455_create_content_repository_clones.rb
145
166
  - db/migrate/20130723084911_create_content_hostgroup_products.rb
167
+ - db/migrate/20130812154754_create_content_content_view_hosts.rb
168
+ - db/migrate/20130825145431_create_content_content_view_repository_clones.rb
146
169
  - lib/content/engine.rb
147
170
  - lib/content/version.rb
148
171
  - lib/foreman_content.rb
@@ -151,10 +174,12 @@ files:
151
174
  - README.md
152
175
  - test/unit/content/description_format_validator_test.rb
153
176
  - test/unit/content/repositories_test.rb
177
+ - test/unit/content/repository_clone_test.rb
154
178
  - test/unit/content/product_validation_test.rb
155
179
  - test/unit/content/name_format_validator_test.rb
156
180
  - test/test_helper.rb
157
181
  - test/fixtures/content/products.yml
182
+ - test/fixtures/content/repository_clones.yml
158
183
  - test/fixtures/content/repositories.yml
159
184
  - test/content_test.rb
160
185
  - test/integration/navigation_test.rb
@@ -185,10 +210,12 @@ summary: Add Foreman support for content management.
185
210
  test_files:
186
211
  - test/unit/content/description_format_validator_test.rb
187
212
  - test/unit/content/repositories_test.rb
213
+ - test/unit/content/repository_clone_test.rb
188
214
  - test/unit/content/product_validation_test.rb
189
215
  - test/unit/content/name_format_validator_test.rb
190
216
  - test/test_helper.rb
191
217
  - test/fixtures/content/products.yml
218
+ - test/fixtures/content/repository_clones.yml
192
219
  - test/fixtures/content/repositories.yml
193
220
  - test/content_test.rb
194
221
  - test/integration/navigation_test.rb
@@ -1,29 +0,0 @@
1
- module Content
2
- module CustomRepositoryPaths
3
- extend ActiveSupport::Concern
4
-
5
- def repo_path_from_content_path(environment, content_path)
6
- content_path = content_path.sub(/^\//, "")
7
- path_prefix = [environment.organization.label, environment.label].join("/")
8
- "#{path_prefix}/#{content_path}"
9
- end
10
-
11
- # repo path for custom product repos (RH repo paths are derived from
12
- # content url)
13
- def custom_repo_path(org_label, environment_label, product_label, repo_label)
14
- prefix = [org_label, environment_label].map { |x| x.gsub(/[^-\w]/, "_") }.join("/")
15
- prefix + custom_content_path(product_label, repo_label)
16
- end
17
-
18
- def custom_content_path(product_label, repo_label)
19
- parts = []
20
- # We generate repo path only for custom product content. We add this
21
- # constant string to avoid collisions with RH content. RH content url
22
- # begins usually with something like "/content/dist/rhel/...".
23
- # There we prefix custom content/repo url with "/custom/..."
24
- parts << "custom"
25
- parts += [product_label, repo_label]
26
- "/" + parts.map { |x| x.gsub(/[^-\w]/, "_") }.join("/")
27
- end
28
- end
29
- end
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2013 Red Hat, Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public
5
- # License as published by the Free Software Foundation; either version
6
- # 2 of the License (GPLv2) or (at your option) any later version.
7
- # There is NO WARRANTY for this software, express or implied,
8
- # including the implied warranties of MERCHANTABILITY,
9
- # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
10
- # have received a copy of GPLv2 along with this software; if not, see
11
- # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12
- module Content
13
- class EnvironmentProduct < ActiveRecord::Base
14
- belongs_to :product
15
- belongs_to :environment
16
- validates_presence_of :product_id, :environment_id
17
- validates_uniqueness_of :product_id, :scope => :environment_id
18
- end
19
- end
@@ -1,93 +0,0 @@
1
- module Content::Orchestration::Pulp
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- after_validation :queue_pulp
6
- before_destroy :queue_pulp_destroy unless Rails.env == "test"
7
- end
8
-
9
- def orchestration_errors?
10
- errors.empty?
11
- end
12
-
13
- protected
14
-
15
- def queue_pulp
16
- return unless pulp? and errors.empty?
17
- new_record? ? queue_pulp_create : queue_pulp_update
18
- end
19
-
20
- private
21
-
22
- def queue_pulp_create
23
- logger.debug "Scheduling new Pulp Repository"
24
- queue.create(:name => _("Create Pulp Repository for %s") % self, :priority => 10,
25
- :action => [self, :set_pulp_repo])
26
- queue.create(:name => _("Sync Pulp Repository %s") % self, :priority => 20,
27
- :action => [self, :set_sync_pulp_repo])
28
- end
29
-
30
- def queue_pulp_update
31
- end
32
-
33
- def set_pulp_repo
34
- Runcible::Extensions::Repository.create_with_importer_and_distributors(pulp_id,
35
- pulp_importer,
36
- [pulp_distributor],
37
- { :display_name => relative_path,
38
- :description => description })
39
- rescue RestClient::BadRequest => e
40
- raise (JSON.parse e.response)['error_message']
41
- end
42
-
43
- def del_pulp_repo
44
- delete
45
- end
46
-
47
- def set_sync_pulp_repo
48
- sync
49
- end
50
-
51
- def del_sync_pulp_repo
52
- status = sync_status
53
- return if status.blank? || status == ::PulpSyncStatus::Status::NOT_SYNCED
54
- Runcible::Resources::Task.cancel(status.uuid)
55
- end
56
-
57
- def pulp_importer
58
- options = {
59
- :feed_url => feed
60
- }
61
-
62
- case content_type
63
- when Content::Repository::YUM_TYPE, Content::Repository::KICKSTART_TYPE
64
- Runcible::Extensions::YumImporter.new(options)
65
- when Content::Repository::FILE_TYPE
66
- Runcible::Extensions::IsoImporter.new(options)
67
- else
68
- raise "Unexpected repo type %s" % content_type
69
- end
70
- end
71
-
72
- def pulp_distributor
73
- case content_type
74
- when Content::Repository::YUM_TYPE, Content::Repository::KICKSTART_TYPE
75
- Runcible::Extensions::YumDistributor.new(relative_path, unprotected, true,
76
- { :protected => true, :id => pulp_id,
77
- :auto_publish => true })
78
- when Content::Repository::FILE_TYPE
79
- dist = Runcible::Extensions::IsoDistributor.new(true, true)
80
- dist.auto_publish = true
81
- dist
82
- else
83
- raise "Unexpected repo type %s" % content_type
84
- end
85
- end
86
-
87
- def queue_pulp_destroy
88
- return unless pulp? and errors.empty?
89
- logger.debug _("Scheduling removal of Pulp Repository %s") % name
90
- queue.create(:name => _("Delete Pulp repository for %s") % name, :priority => 50,
91
- :action => [self, :del_pulp_repo])
92
- end
93
- end
@@ -1,19 +0,0 @@
1
- #
2
- # Copyright 2013 Red Hat, Inc.
3
- #
4
- # This software is licensed to you under the GNU General Public
5
- # License as published by the Free Software Foundation; either version
6
- # 2 of the License (GPLv2) or (at your option) any later version.
7
- # There is NO WARRANTY for this software, express or implied,
8
- # including the implied warranties of MERCHANTABILITY,
9
- # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
10
- # have received a copy of GPLv2 along with this software; if not, see
11
- # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12
- module Content
13
- class ProductOperatingsystem < ActiveRecord::Base
14
- belongs_to :product
15
- belongs_to :operatingsystem
16
- validates_presence_of :product_id, :operatingsystem_id
17
- validates_uniqueness_of :product_id, :scope => :operatingsystem_id
18
- end
19
- end
@@ -1,48 +0,0 @@
1
- module Content
2
- module Remote
3
- module Pulp
4
- module Repository
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- after_initialize :initialize_pulp
9
- end
10
-
11
- def pulp?
12
- @use_pulp ||= Setting.use_pulp and enabled?
13
- end
14
-
15
- def sync
16
- Runcible::Resources::Repository.sync(pulp_id)
17
- end
18
-
19
- def retrieve_with_details
20
- return unless pulp? && pulp_id
21
- Runcible::Resources::Repository.retrieve(pulp_id, {:details => true})
22
- end
23
-
24
- def sync_status
25
- return unless pulp? && pulp_id
26
- Runcible::Extensions::Repository.sync_status(pulp_id)
27
- end
28
-
29
- def sync_history
30
- return unless pulp? && pulp_id
31
- Runcible::Extensions::Repository.sync_history(pulp_id)
32
- end
33
-
34
- def delete
35
- Runcible::Resources::Repository.delete(pulp_id)
36
- end
37
-
38
- protected
39
- def initialize_pulp
40
- # initiate pulp connection
41
- Content::PulpConfiguration.new
42
- self.pulp_id ||= Foreman.uuid.gsub("-", '')
43
- self.relative_path ||= custom_repo_path("acme_org", "library", product.name, name) if name
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,9 +0,0 @@
1
- Deface::Override.new(:virtual_path => "operatingsystems/_form",
2
- :name => "add_content_tab",
3
- :insert_after => 'ul.nav > li a#params-tab',
4
- :partial => 'content/products/form_tab')
5
-
6
- Deface::Override.new(:virtual_path => "operatingsystems/_form",
7
- :name => "add_content_tab_pane",
8
- :insert_after => 'div.tab-pane#params',
9
- :partial => 'content/products/operatingsystem_tab_pane')
@@ -1,25 +0,0 @@
1
- class Content::PulpEventHandler
2
- attr_reader :type, :status
3
- delegate :name, :to => :repo
4
- delegate :logger, :to => :Rails
5
-
6
- def initialize(pulp_id, params)
7
- @repo = Content::Repository.where(:pulp_id => pulp_id).first
8
- @params = params
9
- @type, @status = parse_type
10
- log
11
- end
12
-
13
- private
14
- attr_reader :repo, :params
15
-
16
- def log
17
- logger.info "Repository #{name} #{type} #{status}"
18
- end
19
-
20
- def parse_type
21
- # converts repo.sync.start to ['sync','start']
22
- params['event_type'].gsub(/^repo\./, '').split('.')
23
- end
24
-
25
- end
@@ -1,5 +0,0 @@
1
- <div class="tab-pane" id="products">
2
- <%= fields_for @host do |f| %>
3
- <%= multiple_selects f, :products, Content::Product, @host.all_product_ids , {:disabled => @host.inherited_product_ids}, {} %>
4
- <% end -%>
5
- </div>
@@ -1,5 +0,0 @@
1
- <div class="tab-pane" id="products">
2
- <%= fields_for @operatingsystem do |f| %>
3
- <%= multiple_selects f, :products, Content::Product, @operatingsystem.product_ids , {}, {} %>
4
- <% end -%>
5
- </div>
@@ -1,9 +0,0 @@
1
- class CreateContentEnvironmentsProducts < ActiveRecord::Migration
2
- def change
3
- create_table :content_environment_products do |t|
4
- t.references :environment, :null =>false
5
- t.references :product, :null =>false
6
- end
7
- add_index(:content_environment_products, [:environment_id, :product_id],:name=>'environment_products_index', :unique=>true)
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateContentProductOperatingsystems < ActiveRecord::Migration
2
- def change
3
- create_table :content_product_operatingsystems do |t|
4
- t.references :operatingsystem, :null =>false
5
- t.references :product, :null =>false
6
- end
7
- add_index(:content_product_operatingsystems, [:operatingsystem_id, :product_id],:name=>'product_operatingsystems_index', :unique=>true)
8
- end
9
- end