katello 3.4.5 → 3.5.0.rc1

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 (206) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/app/assets/stylesheets/katello/katello.scss +7 -5
  4. data/app/controllers/katello/api/v2/activation_keys_controller.rb +3 -3
  5. data/app/controllers/katello/api/v2/api_controller.rb +8 -0
  6. data/app/controllers/katello/api/v2/capsule_content_controller.rb +6 -1
  7. data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +2 -1
  8. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +1 -1
  9. data/app/controllers/katello/api/v2/content_views_controller.rb +1 -1
  10. data/app/controllers/katello/api/v2/host_collections_controller.rb +1 -1
  11. data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +2 -2
  12. data/app/controllers/katello/api/v2/host_tracer_controller.rb +1 -1
  13. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +6 -6
  14. data/app/controllers/katello/api/v2/repositories_controller.rb +6 -7
  15. data/app/controllers/katello/api/v2/repository_sets_controller.rb +25 -4
  16. data/app/controllers/katello/concerns/api/v2/content_overrides_controller.rb +2 -4
  17. data/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb +10 -27
  18. data/app/controllers/katello/concerns/api/v2/smart_proxies_controller_extensions.rb +10 -14
  19. data/app/controllers/katello/concerns/hosts_controller_extensions.rb +33 -0
  20. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +2 -1
  21. data/app/helpers/katello/organizations_helper.rb +1 -1
  22. data/app/helpers/katello/providers_helper.rb +1 -1
  23. data/app/lib/actions/candlepin/abstract_async_task.rb +1 -1
  24. data/app/lib/actions/candlepin/candlepin_listening_service.rb +17 -6
  25. data/app/lib/actions/candlepin/import_pool_handler.rb +21 -56
  26. data/app/lib/actions/candlepin/listen_on_candlepin_events.rb +1 -0
  27. data/app/lib/actions/candlepin/owner/import_products.rb +1 -3
  28. data/app/lib/actions/candlepin/product/content_create.rb +2 -0
  29. data/app/lib/actions/candlepin/product/content_update.rb +2 -0
  30. data/app/lib/actions/candlepin/product/create.rb +2 -10
  31. data/app/lib/actions/candlepin/product/create_unlimited_subscription.rb +8 -1
  32. data/app/lib/actions/katello/capsule_content/sync.rb +12 -3
  33. data/app/lib/actions/katello/host/attach_subscriptions.rb +1 -1
  34. data/app/lib/actions/katello/host/hypervisors_update.rb +2 -4
  35. data/app/lib/actions/katello/host/remove_subscriptions.rb +1 -1
  36. data/app/lib/actions/katello/organization/create.rb +2 -2
  37. data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -2
  38. data/app/lib/actions/katello/product/content_create.rb +4 -4
  39. data/app/lib/actions/katello/product/create.rb +13 -11
  40. data/app/lib/actions/katello/repository/sync.rb +0 -1
  41. data/app/lib/actions/katello/repository/update.rb +2 -1
  42. data/app/lib/actions/pulp/consumer/generate_applicability.rb +5 -1
  43. data/app/lib/actions/pulp/repository/create.rb +1 -0
  44. data/app/lib/actions/pulp/repository/create_in_plan.rb +4 -4
  45. data/app/lib/actions/pulp/repository/sync.rb +1 -1
  46. data/app/lib/katello/http_resource.rb +1 -1
  47. data/app/lib/katello/lazy_accessor.rb +1 -1
  48. data/app/lib/katello/resources/candlepin.rb +2 -2
  49. data/app/lib/katello/util/data.rb +6 -0
  50. data/app/lib/katello/util/support.rb +1 -1
  51. data/app/models/katello/activation_key.rb +25 -7
  52. data/app/models/katello/concerns/host_managed_extensions.rb +60 -17
  53. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +31 -10
  54. data/app/models/katello/content_facet_applicable_rpm.rb +0 -2
  55. data/app/models/katello/content_facet_erratum.rb +0 -2
  56. data/app/models/katello/content_facet_repository.rb +0 -2
  57. data/app/models/katello/content_view.rb +3 -4
  58. data/app/models/katello/content_view_component.rb +1 -3
  59. data/app/models/katello/content_view_docker_filter_rule.rb +0 -2
  60. data/app/models/katello/content_view_environment.rb +2 -4
  61. data/app/models/katello/content_view_erratum_filter_rule.rb +0 -2
  62. data/app/models/katello/content_view_filter.rb +0 -2
  63. data/app/models/katello/content_view_package_filter_rule.rb +0 -2
  64. data/app/models/katello/content_view_package_group_filter_rule.rb +0 -2
  65. data/app/models/katello/content_view_puppet_environment.rb +0 -2
  66. data/app/models/katello/content_view_puppet_environment_puppet_module.rb +0 -2
  67. data/app/models/katello/content_view_puppet_module.rb +0 -2
  68. data/app/models/katello/content_view_repository.rb +0 -2
  69. data/app/models/katello/content_view_version.rb +0 -2
  70. data/app/models/katello/erratum_bugzilla.rb +0 -2
  71. data/app/models/katello/erratum_cve.rb +0 -2
  72. data/app/models/katello/erratum_package.rb +0 -2
  73. data/app/models/katello/ext/label_from_name.rb +1 -1
  74. data/app/models/katello/glue/candlepin/pool.rb +18 -11
  75. data/app/models/katello/glue/candlepin/product.rb +1 -2
  76. data/app/models/katello/glue/pulp/repo.rb +13 -6
  77. data/app/models/katello/glue/pulp/repos.rb +16 -16
  78. data/app/models/katello/gpg_key.rb +0 -2
  79. data/app/models/katello/host/content_facet.rb +21 -0
  80. data/app/models/katello/host/info_provider.rb +56 -0
  81. data/app/models/katello/host/subscription_facet.rb +5 -3
  82. data/app/models/katello/host_collection.rb +0 -2
  83. data/app/models/katello/host_collection_hosts.rb +0 -2
  84. data/app/models/katello/host_installed_package.rb +0 -2
  85. data/app/models/katello/host_tracer.rb +0 -2
  86. data/app/models/katello/key_host_collection.rb +0 -2
  87. data/app/models/katello/kt_environment.rb +0 -2
  88. data/app/models/katello/model.rb +1 -1
  89. data/app/models/katello/pool.rb +3 -3
  90. data/app/models/katello/product.rb +10 -3
  91. data/app/models/katello/provider.rb +0 -2
  92. data/app/models/katello/repository.rb +0 -2
  93. data/app/models/katello/repository_docker_manifest.rb +0 -2
  94. data/app/models/katello/repository_erratum.rb +0 -2
  95. data/app/models/katello/repository_file.rb +0 -2
  96. data/app/models/katello/repository_ostree_branch.rb +0 -2
  97. data/app/models/katello/repository_package_group.rb +0 -1
  98. data/app/models/katello/repository_puppet_module.rb +0 -2
  99. data/app/models/katello/repository_rpm.rb +0 -2
  100. data/app/models/katello/rpm.rb +2 -2
  101. data/app/models/katello/subscription_facet_activation_key.rb +0 -2
  102. data/app/models/katello/subscription_facet_pool.rb +6 -0
  103. data/app/models/katello/subscription_product.rb +0 -1
  104. data/app/models/katello/sync_plan.rb +0 -2
  105. data/app/models/katello/task_status.rb +2 -4
  106. data/app/models/setting/content.rb +2 -0
  107. data/app/services/katello/candlepin/consumer.rb +1 -2
  108. data/app/services/katello/candlepin/message_handler.rb +88 -0
  109. data/app/services/katello/repository_type_manager.rb +1 -1
  110. data/app/views/dashboard/_content_views_widget.html.erb +2 -2
  111. data/app/views/dashboard/_errata_widget.html.erb +3 -3
  112. data/app/views/foreman/smart_proxies/_content_sync.html.erb +25 -8
  113. data/app/views/foreman/unattended/kickstart-katello-atomic.erb +1 -1
  114. data/app/views/foreman/unattended/kickstart-katello.erb +1 -1
  115. data/app/views/katello/api/v2/common/_org_reference.json.rabl +1 -0
  116. data/app/views/katello/api/v2/content_facet/base.json.rabl +3 -14
  117. data/app/views/katello/api/v2/products/base.json.rabl +1 -1
  118. data/app/views/katello/api/v2/repositories/base.json.rabl +1 -1
  119. data/app/views/katello/api/v2/repository_sets/show.json.rabl +8 -1
  120. data/app/views/katello/api/v2/subscriptions/base.json.rabl +0 -7
  121. data/app/views/katello/api/v2/subscriptions/show.json.rabl +4 -37
  122. data/config/routes/overrides.rb +1 -0
  123. data/db/migrate/20140422000001_update_products_add_organization.rb +1 -1
  124. data/db/migrate/20140610154745_content_view_puppet_environment_id.rb +1 -1
  125. data/db/migrate/20140626204657_add_unlimited_to_activation_keys.rb +1 -1
  126. data/db/migrate/20140626204902_add_unlimited_to_host_collection.rb +1 -1
  127. data/db/migrate/20141209103005_disown_foreman_templates.rb +1 -1
  128. data/db/migrate/20150901213759_remove_distributors.rb +1 -1
  129. data/db/migrate/20150908222711_drop_marketing_engineering_products.rb +1 -1
  130. data/db/migrate/20150930183738_migrate_content_hosts.rb +20 -20
  131. data/db/migrate/20151014144004_host_collection_to_hosts.rb +5 -5
  132. data/db/migrate/20160114200145_add_mirror_on_sync_to_repositories.rb +1 -1
  133. data/db/migrate/20160131182301_add_download_policy_to_katello_repositories.rb +1 -1
  134. data/db/migrate/20160222143432_move_system_description_to_host.rb +2 -2
  135. data/db/migrate/20160404132250_remove_katello_from_notification_name.rb +1 -1
  136. data/db/migrate/20160426145517_move_host_description_to_host_comment.rb +1 -1
  137. data/db/migrate/20160617124149_remove_duplicate_view_filters.rb +4 -4
  138. data/db/migrate/20160619223332_fix_viewer_role.rb +4 -4
  139. data/db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb +1 -1
  140. data/db/migrate/20160924213020_change_katello_widget_names.rb +1 -1
  141. data/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb +2 -2
  142. data/db/migrate/20161026191118_fix_invalid_interfaces.rb +1 -1
  143. data/db/migrate/20170321012632_fill_in_content_view_components.rb +3 -3
  144. data/db/migrate/20170718142148_create_katello_subscription_facet_pools.rb +15 -0
  145. data/db/migrate/20170821170915_add_index_to_installed_packages.rb +5 -0
  146. data/db/migrate/20170821170916_add_nvra_index_to_installed_packages.rb +5 -0
  147. data/db/migrate/20170913183848_add_errata_counts.rb +23 -0
  148. data/db/seeds.d/101-locations.rb +2 -2
  149. data/db/seeds.d/102-organizations.rb +3 -3
  150. data/db/seeds.d/103-provisioning_templates.rb +29 -31
  151. data/db/seeds.d/104-proxy.rb +10 -12
  152. data/db/seeds.d/106-mail_notifications.rb +30 -32
  153. data/db/seeds.d/107-enable_dynflow.rb +3 -4
  154. data/db/seeds.d/108-subcription-bookmarks.rb +12 -10
  155. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/activation-keys.routes.js +1 -1
  156. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/new/views/activation-key-new.html +1 -1
  157. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/architectures/architecture.factory.js +15 -0
  158. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/architectures/architectures.module.js +14 -0
  159. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js +1 -0
  160. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +3 -0
  161. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +2 -2
  162. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-repository-sets-modal.controller.js +107 -0
  163. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-repository-sets-modal.html +113 -0
  164. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js +13 -0
  165. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +25 -4
  166. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details-info.controller.js +4 -4
  167. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +15 -12
  168. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-repository-sets.html +1 -1
  169. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +11 -5
  170. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/views/version-deletion-activation-keys.html +15 -12
  171. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/views/version-deletion-content-hosts.html +16 -12
  172. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +9 -6
  173. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/errata-counts.html +6 -12
  174. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/errata.html +4 -1
  175. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-bulk-action.factory.js +1 -0
  176. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/packages/views/packages.html +5 -2
  177. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +20 -2
  178. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +9 -1
  179. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +22 -3
  180. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +17 -1
  181. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +1 -1
  182. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js +1 -0
  183. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repository-sets/repository-set.factory.js +16 -0
  184. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-details.controller.js +4 -0
  185. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-details.html +0 -19
  186. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-info.html +31 -0
  187. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/subscriptions.routes.js +1 -1
  188. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/views/tasks-table.html +6 -3
  189. data/lib/katello/permissions/host_permissions.rb +1 -0
  190. data/lib/katello/plugin.rb +7 -5
  191. data/lib/katello/tasks/clean_installed_packages.rake +54 -0
  192. data/lib/katello/tasks/import_subscriptions.rake +8 -0
  193. data/lib/katello/tasks/{setup.rake → reset.rake} +10 -0
  194. data/lib/katello/tasks/test.rake +18 -0
  195. data/lib/katello/version.rb +1 -1
  196. data/vendor/assets/stylesheets/katello/{jquery-ui-1.8.11.custom.css → jquery-ui-1.8.11.custom.css.scss} +0 -0
  197. data/vendor/assets/stylesheets/katello/{jquery.loadmask.css → jquery.loadmask.css.scss} +0 -0
  198. data/vendor/assets/stylesheets/katello/{jquery.treeTable.scss → jquery.treeTable.css.scss} +0 -0
  199. data/vendor/assets/stylesheets/katello/{ui.spinner.css → ui.spinner.css.scss} +0 -0
  200. metadata +43 -21
  201. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-activation-keys.controller.js +0 -30
  202. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-content-hosts.controller.js +0 -45
  203. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-activation-keys.html +0 -48
  204. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-content-hosts.html +0 -62
  205. data/lib/katello/tasks/upgrades/2.4/import_subscriptions.rake +0 -12
  206. data/lib/katello/tasks/upgrades/3.3/import_subscriptions.rake +0 -12
@@ -3,7 +3,10 @@ module Katello
3
3
  module HostsControllerExtensions
4
4
  extend ActiveSupport::Concern
5
5
  include ForemanTasks::Triggers
6
+
6
7
  included do
8
+ alias_method_chain :action_permission, :katello
9
+
7
10
  def destroy
8
11
  sync_task(::Actions::Katello::Host::Destroy, @host)
9
12
  process_success(:success_redirect => hosts_path)
@@ -23,6 +26,36 @@ module Katello
23
26
  cvpe = Katello::ContentViewPuppetEnvironment.where(:environment_id => environment, :content_view_version_id => version).first
24
27
  render :json => cvpe.nil? ? nil : {:name => cvpe.puppet_environment.name, :id => cvpe.puppet_environment.id}
25
28
  end
29
+
30
+ def content_hosts
31
+ respond_to do |format|
32
+ format.csv do
33
+ @hosts = resource_base_with_search.where(organization_id: params[:organization_id])
34
+ .preload(:subscription_facet, :host_statuses, :operatingsystem,
35
+ :applicable_rpms, :lifecycle_environment, :content_view)
36
+ csv_response(@hosts,
37
+ [:name, :subscription_status_label, 'applicable_errata.security.size',
38
+ 'applicable_errata.bugfix.size', 'applicable_errata.enhancement.size',
39
+ 'applicable_rpms.size', :operatingsystem, :lifecycle_environment, :content_view,
40
+ 'subscription_facet.registered_at', 'subscription_facet.last_checkin'],
41
+ ['Name', 'Subscription Status', 'Installable Updates - Security',
42
+ 'Installable Updates - Bug Fixes', 'Installable Updates - Enhancements',
43
+ 'Installable Updates - Package Count', 'OS', 'Environment', 'Content View',
44
+ 'Registered', 'Last Checkin'])
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ def action_permission_with_katello
53
+ case params[:action]
54
+ when 'content_hosts'
55
+ 'view'
56
+ else
57
+ action_permission_without_katello
58
+ end
26
59
  end
27
60
  end
28
61
  end
@@ -191,12 +191,13 @@ module Katello
191
191
  # case 1
192
192
  selected_host_group = options.fetch(:selected_host_group, nil)
193
193
  host = selected_host_group.present? ? selected_host_group : param_host
194
- return [] unless host.operatingsystem.is_a?(Redhat)
195
194
 
196
195
  new_host = ::Host.new
197
196
  new_host.operatingsystem = param_host.operatingsystem.present? ? param_host.operatingsystem : host.operatingsystem
198
197
  new_host.architecture = param_host.architecture.present? ? param_host.architecture : host.architecture
199
198
 
199
+ return [] unless new_host.operatingsystem.is_a?(Redhat)
200
+
200
201
  if (host.is_a? Hostgroup)
201
202
  new_host.content_facet = ::Katello::Host::ContentFacet.new(:lifecycle_environment_id => host.inherited_lifecycle_environment_id,
202
203
  :content_view_id => host.inherited_content_view_id,
@@ -2,7 +2,7 @@ module Katello
2
2
  module OrganizationsHelper
3
3
  def organization_servicelevel(org)
4
4
  _("%{sla}") %
5
- { :sla => ((org.service_level.nil? || org.service_level.empty?) ? _("No Service Level Preference") : (_("Service Level %s") % org.service_level))}
5
+ { :sla => (org.service_level.blank? ? _("No Service Level Preference") : (_("Service Level %s") % org.service_level))}
6
6
  end
7
7
 
8
8
  def organization_servicelevel_edit(org)
@@ -56,7 +56,7 @@ module Katello
56
56
 
57
57
  # make the structure plain setting it's attributes according to the tree (namely id and class)
58
58
  def normalize(children, parent_set = [], data = [], item_type = nil)
59
- children.sort { |a, b| a[:name] <=> b[:name] }.each do |child|
59
+ children.sort_by { |a| a[:name] }.each do |child|
60
60
  new_set = parent_set + [child[:id]]
61
61
 
62
62
  item = { :id => id(new_set),
@@ -26,7 +26,7 @@ module Actions
26
26
  end
27
27
 
28
28
  def done?
29
- ! ::Katello::Resources::Candlepin::Job.not_finished?(external_task)
29
+ !::Katello::Resources::Candlepin::Job.not_finished?(external_task)
30
30
  end
31
31
 
32
32
  private
@@ -40,13 +40,23 @@ module Actions
40
40
  end
41
41
 
42
42
  def retrieve
43
- return @receiver.fetch(TIMEOUT)
43
+ result = @receiver.fetch(TIMEOUT)
44
+ result
44
45
  rescue => e
45
46
  if e.class.name.include? "TransportFailure"
46
47
  raise ::Actions::Candlepin::ConnectionError, "failed to connect to #{@url}"
47
48
  else
48
49
  raise e unless e.class.name.include? NO_MESSAGE_AVAILABLE_ERROR_TYPE
49
50
  end
51
+ ensure
52
+ safe_release(result) if result
53
+ end
54
+
55
+ def safe_release(message)
56
+ @session.acknowledge(:message => message, :sync => true)
57
+ rescue => e
58
+ @session.release(message)
59
+ raise e
50
60
  end
51
61
 
52
62
  def start(suspended_action)
@@ -78,17 +88,18 @@ module Actions
78
88
  loop do
79
89
  begin
80
90
  message = fetch_message
81
- if (message[:result].nil? && message[:error].nil?) || count >= LOOP_RECEIVE_COUNT
82
- sleep 1
83
- count = 0
84
- elsif message[:result]
91
+ if message[:result]
85
92
  result = message[:result]
86
- @session.acknowledge(:message => result, :sync => true)
87
93
  suspended_action.notify_message_received(result.message_id, result.subject, result.content)
88
94
  elsif message[:error]
89
95
  suspended_action.notify_not_connected(message[:error])
90
96
  break
91
97
  end
98
+
99
+ if count >= LOOP_RECEIVE_COUNT || (message[:result].nil? && message[:error].nil?)
100
+ sleep 1
101
+ count = 0
102
+ end
92
103
  rescue => e
93
104
  suspended_action.notify_fatal(e)
94
105
  raise e
@@ -1,21 +1,5 @@
1
1
  module Actions
2
2
  module Candlepin
3
- class MessageWrapper
4
- attr_accessor :message
5
-
6
- def initialize(message)
7
- @message = message
8
- end
9
-
10
- def subject
11
- @message.subject
12
- end
13
-
14
- def content
15
- JSON.parse(@message.content)
16
- end
17
- end
18
-
19
3
  class ImportPoolHandler
20
4
  def initialize(logger)
21
5
  @logger = logger
@@ -27,56 +11,37 @@ module Actions
27
11
 
28
12
  ::User.current = ::User.anonymous_admin
29
13
 
30
- wrapped_message = MessageWrapper.new(message)
31
- case message.subject
14
+ message_handler = ::Katello::Candlepin::MessageHandler.new(message)
15
+
16
+ case message_handler.subject
32
17
  when /entitlement\.created/
33
- import_pool(wrapped_message.content['referenceId'])
18
+ message_handler.import_pool_by_reference_id
19
+ message_handler.create_pool_on_host
34
20
  when /entitlement\.deleted/
35
- import_pool(wrapped_message.content['referenceId'])
21
+ message_handler.import_pool_by_reference_id
22
+ message_handler.remove_pool_from_host
36
23
  when /pool\.created/
37
- import_pool(wrapped_message.content['entityId'])
24
+ message_handler.import_pool_by_entity_id
38
25
  when /pool\.deleted/
39
- remove_pool(wrapped_message.content['entityId'])
26
+ message_handler.import_pool_by_entity_id
40
27
  when /compliance\.created/
41
- reindex_consumer(wrapped_message)
28
+ reindex_consumer(message_handler)
42
29
  end
43
30
  end
44
31
 
45
32
  private
46
33
 
47
- def import_pool(pool_id)
48
- pool = ::Katello::Pool.find_by(:cp_id => pool_id)
49
- if pool
50
- ::Katello::EventQueue.push_event(::Katello::Events::ImportPool::EVENT_TYPE, pool.id)
51
- else
52
- ::Katello::Pool.import_pool(pool_id)
53
- end
54
- end
55
-
56
- def remove_pool(pool_id)
57
- pool = ::Katello::Pool.find_by(:cp_id => pool_id)
58
- if pool
59
- pool.destroy!
60
- else
61
- @logger.debug "Couldn't find pool with candlepin id #{pool_id} in the database"
62
- end
63
- end
64
-
65
- def reindex_consumer(message)
66
- if message.content['newEntity']
67
- parsed = JSON.parse(message.content['newEntity'])
68
- uuid = parsed['consumer']['uuid']
69
- sub_status = parsed['status']['status']
70
- subscription_facet = ::Katello::Host::SubscriptionFacet.find_by_uuid(uuid)
71
-
72
- if subscription_facet && sub_status
73
- @logger.debug "re-indexing content host #{subscription_facet.host.name}"
74
- subscription_facet.update_subscription_status(sub_status)
75
- elsif subscription_facet.nil?
76
- @logger.debug "skip re-indexing of non-existent content host #{uuid}"
77
- elsif sub_status.nil?
78
- @logger.debug "skip re-indexing of empty subscription status #{uuid}"
79
- end
34
+ def reindex_consumer(message_handler)
35
+ subscription_facet = message_handler.subscription_facet
36
+ sub_status = message_handler.sub_status
37
+ uuid = message_handler.consumer_uuid
38
+ if subscription_facet && sub_status
39
+ @logger.debug "re-indexing content host #{subscription_facet.host.name}"
40
+ subscription_facet.update_subscription_status(sub_status)
41
+ elsif subscription_facet.nil?
42
+ @logger.debug "skip re-indexing of non-existent content host #{uuid}"
43
+ elsif sub_status.nil?
44
+ @logger.debug "skip re-indexing of empty subscription status #{uuid}"
80
45
  end
81
46
  end
82
47
  end
@@ -182,6 +182,7 @@ module Actions
182
182
  output[:connection] = "Connected"
183
183
  Actions::Candlepin::ImportPoolHandler.new(Rails.logger).handle(event)
184
184
  output[:last_message] = "#{event.message_id} - #{event.subject}"
185
+ output[:last_message_time] = DateTime.now.to_s
185
186
  output[:messages] = event.message_id
186
187
  rescue => e
187
188
  output[:last_event_error] = e.message
@@ -8,9 +8,7 @@ module Actions
8
8
 
9
9
  def run
10
10
  organization = ::Organization.find(input[:organization_id])
11
- User.as_anonymous_admin do
12
- organization.redhat_provider.import_products_from_cp
13
- end
11
+ organization.redhat_provider.import_products_from_cp
14
12
  end
15
13
  end
16
14
  end
@@ -5,6 +5,7 @@ module Actions
5
5
  input_format do
6
6
  param :name
7
7
  param :type
8
+ param :arches
8
9
  param :label
9
10
  param :content_url
10
11
  param :owner
@@ -16,6 +17,7 @@ module Actions
16
17
  name: input[:name],
17
18
  contentUrl: input[:content_url],
18
19
  type: input[:type],
20
+ arches: input[:arches],
19
21
  label: input[:label],
20
22
  metadataExpire: 1,
21
23
  vendor: ::Katello::Provider::CUSTOM)
@@ -6,6 +6,7 @@ module Actions
6
6
  param :content_id
7
7
  param :name
8
8
  param :type
9
+ param :arches
9
10
  param :label
10
11
  param :content_url
11
12
  param :gpg_key_url
@@ -20,6 +21,7 @@ module Actions
20
21
  contentUrl: input[:content_url],
21
22
  gpgUrl: input[:gpg_key_url],
22
23
  type: input[:type],
24
+ arches: input[:arches],
23
25
  label: input[:label],
24
26
  metadataExpire: 1,
25
27
  vendor: ::Katello::Provider::CUSTOM)
@@ -4,6 +4,7 @@ module Actions
4
4
  class Create < Candlepin::Abstract
5
5
  input_format do
6
6
  param :name, String
7
+ param :id
7
8
  param :multiplier
8
9
  param :attributes
9
10
  param :owner
@@ -11,19 +12,10 @@ module Actions
11
12
 
12
13
  def run
13
14
  output[:response] = ::Katello::Resources::Candlepin::Product.create(input[:owner], :name => input[:name],
14
- :id => unused_product_id,
15
+ :id => input[:id],
15
16
  :multiplier => input[:multiplier],
16
17
  :attributes => input[:attributes])
17
18
  end
18
-
19
- def unused_product_id
20
- id = SecureRandom.random_number(999_999_999_999)
21
- if ::Katello::Product.find_by(:cp_id => id)
22
- unused_product_id
23
- else
24
- id
25
- end
26
- end
27
19
  end
28
20
  end
29
21
  end
@@ -5,11 +5,18 @@ module Actions
5
5
  input_format do
6
6
  param :owner_key, String
7
7
  param :product_id, String
8
+ param :start_time, Time
8
9
  end
9
10
 
10
11
  def run
12
+ if input[:start_time]
13
+ start_time = Time.iso8601(input[:start_time])
14
+ else
15
+ start_time = nil
16
+ end
11
17
  output[:response] = ::Katello::Resources::Candlepin::Product.create_unlimited_subscription(input[:owner_key],
12
- input[:product_id])
18
+ input[:product_id],
19
+ start_time)
13
20
  end
14
21
  end
15
22
  end
@@ -30,6 +30,7 @@ module Actions
30
30
  repository = ::Katello::Repository.find(repository_id) if repository_id
31
31
  content_view_id = options.fetch(:content_view_id, nil)
32
32
  content_view = ::Katello::ContentView.find(content_view_id) if content_view_id
33
+ skip_metadata_check = options.fetch(:skip_metadata_check, false)
33
34
 
34
35
  fail _("Action not allowed for the default capsule.") if capsule_content.default_capsule?
35
36
 
@@ -42,12 +43,12 @@ module Actions
42
43
  plan_action(Pulp::Repository::Refresh, repo, capsule_id: capsule_content.capsule.id)
43
44
  end
44
45
  plan_action(ConfigureCapsule, capsule_content, environment, content_view, repository)
45
- sync_repos_to_capsule(capsule_content, repository_ids)
46
+ sync_repos_to_capsule(capsule_content, repository_ids, skip_metadata_check)
46
47
  end
47
48
  end
48
49
  end
49
50
 
50
- def sync_repos_to_capsule(capsule_content, repository_ids)
51
+ def sync_repos_to_capsule(capsule_content, repository_ids, skip_metadata_check)
51
52
  concurrence do
52
53
  repository_ids.each do |repo_id|
53
54
  sequence do
@@ -60,10 +61,18 @@ module Actions
60
61
  capsule_id: capsule_content.capsule.id,
61
62
  repo_pulp_id: repo_id)
62
63
  end
64
+ pulp_options = { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) }
65
+ pulp_options[:force_full] = true if skip_metadata_check && repo.content_type == "yum"
63
66
  plan_action(Pulp::Consumer::SyncCapsule,
64
67
  capsule_id: capsule_content.capsule.id,
65
68
  repo_pulp_id: repo_id,
66
- sync_options: { remove_missing: repo && ["puppet", "yum"].include?(repo.content_type) })
69
+ sync_options: pulp_options)
70
+ if skip_metadata_check
71
+ plan_action(Katello::Repository::MetadataGenerate,
72
+ repo,
73
+ capsule_id: capsule_content.capsule.id,
74
+ force: true)
75
+ end
67
76
  end
68
77
  end
69
78
  end
@@ -27,7 +27,7 @@ module Actions
27
27
  end
28
28
 
29
29
  def finalize
30
- ::Katello::Pool.where(:id => input[:pool_ids]).each(&:import_data)
30
+ ::Katello::Pool.where(:id => input[:pool_ids]).map { |pool| pool.import_data(false) }
31
31
  host = ::Host.find_by(:id => input[:host_id])
32
32
  host.subscription_facet.update_subscription_status
33
33
  end
@@ -16,9 +16,7 @@ module Actions
16
16
  hypervisors = input[:hypervisors]
17
17
 
18
18
  if hypervisors
19
- User.as_anonymous_admin do
20
- hypervisors.each { |hypervisor| update_or_create_hypervisor(hypervisor) }
21
- end
19
+ hypervisors.each { |hypervisor| update_or_create_hypervisor(hypervisor) }
22
20
  end
23
21
  end
24
22
 
@@ -49,7 +47,7 @@ module Actions
49
47
  location ||= Location.unscoped.find_by_title(
50
48
  Setting[:default_location_subscribed_hosts])
51
49
  host = ::Host::Managed.new(:name => name, :organization => organization,
52
- :location => location, :managed => false)
50
+ :location => location, :managed => false, :enabled => false)
53
51
  host.save!
54
52
  host
55
53
  end
@@ -26,7 +26,7 @@ module Actions
26
26
  end
27
27
 
28
28
  def finalize
29
- ::Katello::Pool.where(:cp_id => input[:pool_ids]).each(&:import_data)
29
+ ::Katello::Pool.where(:cp_id => input[:pool_ids]).map { |pool| pool.import_data(false) }
30
30
  host = ::Host.find_by(:id => input[:host_id])
31
31
  host.subscription_facet.update_subscription_status
32
32
  end
@@ -5,8 +5,8 @@ module Actions
5
5
  def plan(organization)
6
6
  organization.setup_label_from_name
7
7
  organization.create_library
8
- organization.create_anonymous_provider unless organization.anonymous_provider
9
- organization.create_redhat_provider unless organization.redhat_provider
8
+ organization.create_anonymous_provider
9
+ organization.create_redhat_provider
10
10
  cp_create = nil
11
11
 
12
12
  organization.save!
@@ -31,8 +31,7 @@ module Actions
31
31
  import_products = plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id, :dependency => owner_import.output)
32
32
 
33
33
  if manifest_update && SETTINGS[:katello][:use_pulp]
34
- repositories = ::Katello::Repository.in_default_view.where(:product_id => ::Katello::Product.redhat.in_org(organization))
35
- repositories.each do |repo|
34
+ organization.products.redhat.flat_map(&:repositories).each do |repo|
36
35
  plan_action(Katello::Repository::RefreshRepository, repo, :dependency => import_products.output)
37
36
  end
38
37
  end