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
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentFacetApplicableRpm < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :content_facet, :inverse_of => :content_facet_applicable_rpms, :class_name => 'Katello::Host::ContentFacet'
6
4
  belongs_to :rpm, :inverse_of => :content_facet_applicable_rpms, :class_name => 'Katello::Rpm'
7
5
  end
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentFacetErratum < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  # Do not use active record callbacks in this join model. Direct INSERTs and DELETEs are done
6
4
  belongs_to :content_facet, :inverse_of => :content_facet_errata, :class_name => 'Katello::Host::ContentFacet'
7
5
  belongs_to :erratum, :inverse_of => :content_facet_errata, :class_name => 'Katello::Erratum'
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentFacetRepository < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :content_facet, :inverse_of => :content_facet_repositories, :class_name => 'Katello::Host::ContentFacet'
6
4
  belongs_to :repository, :inverse_of => :content_facet_repositories, :class_name => 'Katello::Repository'
7
5
  end
@@ -1,8 +1,6 @@
1
1
  module Katello
2
2
  # rubocop:disable Metrics/ClassLength
3
3
  class ContentView < Katello::Model
4
- self.include_root_in_json = false
5
-
6
4
  include Ext::LabelFromName
7
5
  include Katello::Authorization::ContentView
8
6
  include ForemanTasks::Concerns::ActionSubject
@@ -613,11 +611,12 @@ module Katello
613
611
  end
614
612
 
615
613
  def generate_cp_environment_id(env)
616
- # The id for a default view, will simply be the env id; otherwise, it
614
+ # The id for a default view, will simply be the org label; otherwise, it
617
615
  # will be a combination of env id and view id. The reason being,
618
616
  # for a default view, the same candlepin environment will be referenced
619
617
  # by the kt_environment and content_view_environment.
620
- self.default ? env.id.to_s : [env.id, self.id].join('-')
618
+ value = self.default ? env.organization.label.to_s : [env.organization.label, env.label, self.label].join('-')
619
+ Katello::Util::Data.md5hash(value)
621
620
  end
622
621
 
623
622
  def confirm_not_promoted
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewComponent < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :composite_content_view, :class_name => "Katello::ContentView",
6
4
  :inverse_of => :content_view_components
7
5
  belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion",
@@ -74,7 +72,7 @@ module Katello
74
72
  end
75
73
 
76
74
  def update_content_view
77
- if content_view_version.present? && !content_view.present?
75
+ if content_view_version.present? && content_view.blank?
78
76
  self.content_view = content_view_version.content_view
79
77
  end
80
78
  end
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewDockerFilterRule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :filter,
6
4
  :class_name => "Katello::ContentViewDockerFilter",
7
5
  :inverse_of => :docker_rules,
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewEnvironment < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  include ForemanTasks::Concerns::ActionSubject
6
4
  include Glue::Candlepin::Environment if SETTINGS[:katello][:use_cp]
7
5
  include Glue if SETTINGS[:katello][:use_cp]
@@ -45,10 +43,10 @@ module Katello
45
43
 
46
44
  if content_view.default?
47
45
  self.label ||= environment.label
48
- self.cp_id ||= environment.id.to_s
46
+ self.cp_id ||= Katello::Util::Data.md5hash(environment.organization.label)
49
47
  else
50
48
  self.label ||= [environment.label, content_view.label].join('/')
51
- self.cp_id ||= [environment.id, content_view.id].join('-')
49
+ self.cp_id ||= Katello::Util::Data.md5hash([environment.id, content_view.id].join('-'))
52
50
  end
53
51
  end
54
52
  end
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewErratumFilterRule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  before_create :default_types
6
4
 
7
5
  ISSUED = "issued".freeze
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewFilter < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  DOCKER = 'docker'.freeze
6
4
  RPM = Rpm::CONTENT_TYPE
7
5
  PACKAGE_GROUP = PackageGroup::CONTENT_TYPE
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewPackageFilterRule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :filter,
6
4
  :class_name => "Katello::ContentViewPackageFilter",
7
5
  :inverse_of => :package_rules,
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewPackageGroupFilterRule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :filter,
6
4
  :class_name => "Katello::ContentViewPackageGroupFilter",
7
5
  :inverse_of => :package_group_rules,
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewPuppetEnvironment < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  include ForemanTasks::Concerns::ActionSubject
6
4
  include Glue::Pulp::Repo if SETTINGS[:katello][:use_pulp]
7
5
  include Glue if SETTINGS[:katello][:use_pulp]
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewPuppetEnvironmentPuppetModule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  # Do not use active record callbacks in this join model. Direct INSERTs and DELETEs are done
6
4
  belongs_to :content_view_puppet_environment,
7
5
  :inverse_of => :content_view_puppet_environment_puppet_modules,
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewPuppetModule < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_versions
6
4
 
7
5
  validates_lengths_from_database
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewRepository < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  ALLOWED_REPOSITORY_TYPES = [Repository::YUM_TYPE,
6
4
  Repository::DOCKER_TYPE,
7
5
  Repository::OSTREE_TYPE,
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ContentViewVersion < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  include Authorization::ContentViewVersion
6
4
  include ForemanTasks::Concerns::ActionSubject
7
5
 
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ErratumBugzilla < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :erratum, :inverse_of => :bugzillas, :class_name => 'Katello::Erratum'
6
4
  end
7
5
  end
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ErratumCve < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :erratum, :inverse_of => :cves, :class_name => 'Katello::Erratum'
6
4
  end
7
5
  end
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class ErratumPackage < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  belongs_to :erratum, :inverse_of => :packages, :class_name => 'Katello::Erratum'
6
4
  end
7
5
  end
@@ -9,7 +9,7 @@ module Katello
9
9
  end
10
10
 
11
11
  def setup_label_from_name
12
- unless label.present?
12
+ if label.blank?
13
13
  self.label = Util::Model.labelize(name)
14
14
  if self.class.where(:label => self.label).any?
15
15
  self.label = Util::Model.uuid
@@ -31,12 +31,12 @@ module Katello
31
31
  Katello::Resources::Candlepin::Pool.get_for_owner(organization, true)
32
32
  end
33
33
 
34
- def import_pool(cp_pool_id)
34
+ def import_pool(cp_pool_id, index_hosts = true)
35
35
  pool = nil
36
36
  ::Katello::Util::Support.active_record_retry do
37
37
  pool = Katello::Pool.where(:cp_id => cp_pool_id).first_or_create
38
38
  end
39
- pool.import_data
39
+ pool.import_data(index_hosts)
40
40
  end
41
41
  end
42
42
 
@@ -93,8 +93,7 @@ module Katello
93
93
  subscription
94
94
  end
95
95
 
96
- # rubocop:disable MethodLength
97
- def import_data
96
+ def import_data(index_hosts = true)
98
97
  pool_attributes = {}.with_indifferent_access
99
98
  pool_json = self.backend_data
100
99
  product_attributes = pool_json["productAttributes"] + pool_json["attributes"]
@@ -127,22 +126,30 @@ module Katello
127
126
  pool_attributes[:unmapped_guest] = true
128
127
  end
129
128
 
130
- if subscription.try(:redhat?)
131
- pool_attributes[:virt_who] = pool_attributes['virt_limit'] != "0" && pool_attributes['virt_limit'].present?
132
- else
133
- pool_attributes[:virt_who] = false
134
- end
129
+ pool_attributes[:virt_who] = pool_attributes['virt_limit'] != "0" && !pool_attributes['virt_limit'].nil? && subscription.try(:redhat?)
135
130
 
136
131
  exceptions = pool_attributes.keys.map(&:to_sym) - self.attribute_names.map(&:to_sym)
137
132
  self.update_attributes(pool_attributes.except!(*exceptions))
138
133
  self.save!
139
134
  self.create_activation_key_associations
135
+ self.import_hosts if index_hosts
140
136
  end
141
137
 
142
- def hosts
138
+ def import_hosts
143
139
  entitlements = Resources::Candlepin::Pool.entitlements(self.cp_id, ["consumer.uuid"])
144
140
  uuids = entitlements.map { |ent| ent["consumer"]["uuid"] }
145
- ::Host.where(:id => Katello::Host::SubscriptionFacet.where(:uuid => uuids).pluck(:host_id))
141
+ sub_facets = Katello::Host::SubscriptionFacet.where(:uuid => uuids)
142
+ sub_facet_ids = sub_facets.pluck(:id)
143
+ sub_facet_ids.each do |sub_facet_id|
144
+ Katello::SubscriptionFacetPool.where(:pool_id => self.id, :subscription_facet_id => sub_facet_id).first_or_create
145
+ end
146
+ existing_associations = Katello::SubscriptionFacetPool.where(:pool_id => self.id)
147
+ correct_associations = Katello::SubscriptionFacetPool.where(:pool_id => self.id, :subscription_facet_id => sub_facet_ids)
148
+ (existing_associations - correct_associations).map(&:destroy)
149
+ end
150
+
151
+ def hosts
152
+ ::Host.where(:id => self.subscription_facets.pluck(:host_id))
146
153
  end
147
154
 
148
155
  def create_activation_key_associations
@@ -49,7 +49,6 @@ module Katello
49
49
  product.productContent_will_change!
50
50
  product.productContent = product.build_product_content(product_content_attrs)
51
51
  product.save!
52
-
53
52
  rescue => e
54
53
  [Rails.logger, import_logger].each do |logger|
55
54
  logger.error "Failed to create product #{attrs['name']}: #{e}" if logger
@@ -58,7 +57,7 @@ module Katello
58
57
  end
59
58
 
60
59
  module InstanceMethods
61
- def initialize(attribs = nil, options = {})
60
+ def initialize(attribs = nil)
62
61
  unless attribs.nil?
63
62
  attributes_key = attribs.key?(:attributes) ? :attributes : 'attributes'
64
63
  if attribs.key?(attributes_key)
@@ -85,7 +85,7 @@ module Katello
85
85
  last.nil? ? nil : last.to_s
86
86
  end
87
87
 
88
- def initialize(attrs = nil, options = {})
88
+ def initialize(attrs = nil)
89
89
  if attrs.nil?
90
90
  super
91
91
  else
@@ -97,7 +97,7 @@ module Katello
97
97
  attrs_used_by_model = attrs.reject do |k, _v|
98
98
  !self.class.column_defaults.keys.member?(k.to_s) && (!respond_to?(:"#{k.to_s}=") rescue true)
99
99
  end
100
- super(attrs_used_by_model, options)
100
+ super(attrs_used_by_model)
101
101
  end
102
102
  end
103
103
 
@@ -157,8 +157,7 @@ module Katello
157
157
  when Repository::FILE_TYPE
158
158
  Runcible::Models::IsoImporter.new(importer_ssl_options(capsule).merge(:feed => importer_feed_url(capsule)))
159
159
  when Repository::PUPPET_TYPE
160
- options = {:feed => importer_feed_url(capsule)}
161
- Runcible::Models::PuppetImporter.new(importer_ssl_options(capsule).merge(options))
160
+ Runcible::Models::PuppetImporter.new(puppet_importer_values(capsule))
162
161
  when Repository::DOCKER_TYPE
163
162
  options = {}
164
163
  options[:upstream_name] = capsule.default_capsule? ? self.docker_upstream_name : self.container_repository_name
@@ -207,6 +206,14 @@ module Katello
207
206
  config.merge(importer_ssl_options(capsule))
208
207
  end
209
208
 
209
+ def puppet_importer_values(capsule)
210
+ config = {
211
+ :feed => self.importer_feed_url(capsule),
212
+ :remove_missing => capsule.default_capsule? ? self.mirror_on_sync? : true
213
+ }
214
+ config.merge(importer_ssl_options(capsule))
215
+ end
216
+
210
217
  def importer_ssl_options(capsule = SmartProxy.default_capsule!)
211
218
  if !capsule.default_capsule?
212
219
  ueber_cert = ::Cert::Certs.ueber_cert(organization)
@@ -709,14 +716,14 @@ module Katello
709
716
  begin
710
717
  history = Katello.pulp_server.extensions.repository.sync_status(pulp_id)
711
718
 
712
- if history.nil? || history.empty?
719
+ if history.blank?
713
720
  history = PulpSyncStatus.convert_history(Katello.pulp_server.extensions.repository.sync_history(pulp_id))
714
721
  end
715
722
  rescue
716
723
  history = PulpSyncStatus.convert_history(Katello.pulp_server.extensions.repository.sync_history(pulp_id))
717
724
  end
718
725
 
719
- if history.nil? || history.empty?
726
+ if history.blank?
720
727
  return PulpSyncStatus.new(:state => PulpSyncStatus::Status::NOT_SYNCED)
721
728
  else
722
729
  history = sort_sync_status(history)
@@ -213,30 +213,30 @@ module Katello
213
213
  end
214
214
  end
215
215
 
216
- def add_repo(label, name, url, repo_type, unprotected = false, gpg = nil, checksum_type = nil, download_policy = nil)
217
- unprotected = unprotected.nil? ? false : unprotected
216
+ def add_repo(repo_param)
217
+ repo_param[:unprotected] = repo_param[:unprotected].nil? ? false : repo_param[:unprotected]
218
218
 
219
- if download_policy.blank? && repo_type == Repository::YUM_TYPE
220
- download_policy = Setting[:default_download_policy]
219
+ if repo_param[:download_policy].blank? && repo_param[:content_type] == Repository::YUM_TYPE
220
+ repo_param[:download_policy] = Setting[:default_download_policy]
221
221
  end
222
222
 
223
- rel_path = if repo_type == 'docker'
224
- Glue::Pulp::Repos.custom_docker_repo_path(self.library, self, label)
223
+ rel_path = if repo_param[:content_type] == 'docker'
224
+ Glue::Pulp::Repos.custom_docker_repo_path(self.library, self, repo_param[:label])
225
225
  else
226
- Glue::Pulp::Repos.custom_repo_path(self.library, self, label)
226
+ Glue::Pulp::Repos.custom_repo_path(self.library, self, repo_param[:label])
227
227
  end
228
228
  Repository.new(:environment => self.organization.library,
229
229
  :product => self,
230
230
  :relative_path => rel_path,
231
- :arch => arch,
232
- :name => name,
233
- :label => label,
234
- :url => url,
235
- :gpg_key => gpg,
236
- :unprotected => unprotected,
237
- :content_type => repo_type,
238
- :checksum_type => checksum_type,
239
- :download_policy => download_policy,
231
+ :arch => repo_param[:arch],
232
+ :name => repo_param[:name],
233
+ :label => repo_param[:label],
234
+ :url => repo_param[:url],
235
+ :gpg_key => repo_param[:gpg_key],
236
+ :unprotected => repo_param[:unprotected],
237
+ :content_type => repo_param[:content_type],
238
+ :checksum_type => repo_param[:checksum_type],
239
+ :download_policy => repo_param[:download_policy],
240
240
  :content_view_version => self.organization.library.default_content_view_version)
241
241
  end
242
242
 
@@ -1,7 +1,5 @@
1
1
  module Katello
2
2
  class GpgKey < Katello::Model
3
- self.include_root_in_json = false
4
-
5
3
  include Katello::Authorization::GpgKey
6
4
  MAX_CONTENT_LENGTH = 100_000
7
5
  MAX_CONTENT_LINE_LENGTH = 65
@@ -64,9 +64,30 @@ module Katello
64
64
  self.applicable_rpms.in_repositories(repos).uniq
65
65
  end
66
66
 
67
+ def errata_counts
68
+ hash = {
69
+ :security => installable_security_errata_count,
70
+ :bugfix => installable_bugfix_errata_count,
71
+ :enhancement => installable_enhancement_errata_count
72
+ }
73
+ hash[:total] = hash.values.inject(:+)
74
+ hash
75
+ end
76
+
67
77
  def import_applicability(partial = false)
68
78
  import_errata_applicability(partial)
69
79
  import_rpm_applicability(partial)
80
+ update_applicability_counts
81
+ end
82
+
83
+ def update_applicability_counts
84
+ self.update_attributes!(
85
+ :installable_security_errata_count => self.installable_errata.security.count,
86
+ :installable_bugfix_errata_count => self.installable_errata.bugfix.count,
87
+ :installable_enhancement_errata_count => self.installable_errata.enhancement.count,
88
+ :applicable_rpm_count => self.applicable_rpms.count,
89
+ :upgradable_rpm_count => self.installable_rpms.count
90
+ )
70
91
  end
71
92
 
72
93
  def import_rpm_applicability(partial)
@@ -0,0 +1,56 @@
1
+ require 'host_info'
2
+
3
+ module Katello
4
+ module Host
5
+ class InfoProvider < ::HostInfo::Provider
6
+ def host_info
7
+ info = {}
8
+ info['parameters'] = {
9
+ 'kt_env' => host.lifecycle_environment.try(:label), #deprecated
10
+ 'kt_cv' => host.content_view.try(:label), #deprecated
11
+ 'foreman_host_collections' => host.host_collections.map(&:name),
12
+ 'lifecycle_environment' => host.lifecycle_environment.try(:label),
13
+
14
+ 'content_view' => host.content_view.try(:label),
15
+ 'content_view_info' => content_view_info
16
+ }
17
+
18
+ if host.content_facet.present?
19
+ info['parameters']['kickstart_repository'] = host.content_facet.kickstart_repository.try(:label)
20
+ end
21
+ info
22
+ end
23
+
24
+ def content_view_info
25
+ return {} if host.content_view.blank?
26
+
27
+ content_view_info = {
28
+ 'label' => host.content_view.try(:label),
29
+ 'latest-version' => host.content_view.try(:latest_version),
30
+ 'version' => content_version.try(:version),
31
+ 'published' => content_version.try(:created_at),
32
+ 'components' => content_view_components
33
+ }
34
+
35
+ content_view_info
36
+ end
37
+
38
+ def content_view_components
39
+ return {} unless host.content_view.try(:composite)
40
+
41
+ components = {}
42
+ content_version.try(:content_view_version_components).map do |cv|
43
+ cv_label = cv.component_version.content_view.label
44
+ components[cv_label] = {}
45
+ components[cv_label]['version'] = cv.component_version.try(:version)
46
+ components[cv_label]['published'] = cv.component_version.try(:created_at)
47
+ end
48
+ components
49
+ end
50
+
51
+ def content_version
52
+ host.content_view.try(:version, host.lifecycle_environment)
53
+ end
54
+ end
55
+ end
56
+ end