katello 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/katello/katello.scss +5 -5
  3. data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +3 -3
  4. data/app/controllers/katello/api/v2/activation_keys_controller.rb +12 -12
  5. data/app/controllers/katello/api/v2/api_controller.rb +13 -5
  6. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +30 -27
  7. data/app/controllers/katello/api/v2/content_views_controller.rb +4 -1
  8. data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +100 -3
  9. data/app/controllers/katello/api/v2/repositories_controller.rb +2 -2
  10. data/app/controllers/katello/api/v2/repository_sets_controller.rb +1 -1
  11. data/app/controllers/katello/api/v2/subscriptions_controller.rb +0 -1
  12. data/app/controllers/katello/api/v2/systems_controller.rb +1 -88
  13. data/app/controllers/katello/concerns/api/v2/bulk_hosts_extensions.rb +10 -4
  14. data/app/controllers/katello/remote_execution_controller.rb +1 -1
  15. data/app/helpers/katello/concerns/settings_helper_extensions.rb +50 -0
  16. data/app/helpers/katello/hosts_and_hostgroups_helper.rb +17 -4
  17. data/app/helpers/katello/katello_urls_helper.rb +3 -2
  18. data/app/helpers/katello/providers_helper.rb +2 -5
  19. data/app/lib/actions/katello/capsule_content/configure_capsule.rb +1 -1
  20. data/app/lib/actions/katello/capsule_content/{create_or_update.rb → create_repos.rb} +2 -7
  21. data/app/lib/actions/katello/capsule_content/remove_orphans.rb +15 -0
  22. data/app/lib/actions/katello/capsule_content/remove_unneeded_repos.rb +6 -5
  23. data/app/lib/actions/katello/capsule_content/sync.rb +32 -0
  24. data/app/lib/actions/katello/content_view/incremental_updates.rb +4 -3
  25. data/app/lib/actions/katello/content_view/promote.rb +4 -0
  26. data/app/lib/actions/katello/content_view/publish.rb +4 -0
  27. data/app/lib/actions/katello/content_view_puppet_module/destroy.rb +4 -5
  28. data/app/lib/actions/katello/content_view_version/incremental_update.rb +5 -3
  29. data/app/lib/actions/katello/host/erratum/applicable_errata_install.rb +2 -2
  30. data/app/lib/actions/katello/host/generate_applicability.rb +1 -1
  31. data/app/lib/actions/katello/host/hypervisors_update.rb +1 -1
  32. data/app/lib/actions/katello/host/register.rb +10 -4
  33. data/app/lib/actions/katello/repository/destroy.rb +2 -1
  34. data/app/lib/actions/katello/repository/import_applicability.rb +23 -0
  35. data/app/lib/actions/katello/repository/sync.rb +1 -8
  36. data/app/lib/actions/pulp/abstract_async_task.rb +8 -0
  37. data/app/lib/actions/pulp/consumer/content_install.rb +14 -0
  38. data/app/lib/actions/pulp/repository/create.rb +2 -1
  39. data/app/lib/actions/pulp/repository/delete_distributor.rb +18 -0
  40. data/app/lib/actions/pulp/repository/refresh.rb +25 -7
  41. data/app/lib/katello/api/v2/error_handling.rb +2 -2
  42. data/app/lib/katello/capsule_content.rb +11 -0
  43. data/app/lib/katello/errors.rb +1 -1
  44. data/app/mailers/katello/errata_mailer.rb +3 -3
  45. data/app/models/katello/activation_key.rb +6 -6
  46. data/app/models/katello/candlepin/product_content.rb +15 -0
  47. data/app/models/katello/concerns/content_facet_host_extensions.rb +13 -0
  48. data/app/models/katello/concerns/operatingsystem_extensions.rb +17 -1
  49. data/app/models/katello/concerns/pulp_database_unit.rb +3 -1
  50. data/app/models/katello/concerns/setting_extensions.rb +12 -0
  51. data/app/models/katello/content_view.rb +2 -2
  52. data/app/models/katello/erratum.rb +7 -0
  53. data/app/models/katello/glue/candlepin/product.rb +4 -0
  54. data/app/models/katello/glue/candlepin/subscription.rb +1 -1
  55. data/app/models/katello/glue/pulp/repo.rb +31 -3
  56. data/app/models/katello/host/content_facet.rb +43 -16
  57. data/app/models/katello/host/subscription_facet.rb +1 -0
  58. data/app/models/katello/pool.rb +6 -11
  59. data/app/models/katello/repository.rb +20 -15
  60. data/app/models/katello/subscription.rb +14 -0
  61. data/app/models/katello/sync_plan.rb +5 -0
  62. data/app/models/katello/system.rb +0 -10
  63. data/app/models/setting/katello.rb +2 -1
  64. data/app/presenters/katello/product_content_presenter.rb +16 -0
  65. data/app/services/katello/candlepin/consumer.rb +22 -1
  66. data/app/services/katello/repository_type_manager.rb +4 -0
  67. data/app/views/dashboard/_content_views_widget.html.erb +2 -2
  68. data/app/views/dashboard/_errata_widget.html.erb +1 -1
  69. data/app/views/dashboard/_host_collection_widget.html.erb +2 -2
  70. data/app/views/dashboard/_subscription_status_widget.html.erb +5 -5
  71. data/app/views/dashboard/_subscription_widget.html.erb +1 -1
  72. data/app/views/dashboard/_sync_widget.html.erb +2 -2
  73. data/app/views/foreman/unattended/finish-katello.erb +2 -0
  74. data/app/views/foreman/unattended/kickstart-katello-atomic.erb +42 -0
  75. data/app/views/foreman/unattended/kickstart-katello.erb +2 -0
  76. data/app/views/foreman/unattended/snippets/_subscription_manager_registration.erb +15 -9
  77. data/app/views/foreman/unattended/userdata-katello.erb +6 -1
  78. data/app/views/katello/api/v2/activation_keys/show.json.rabl +2 -2
  79. data/app/views/katello/api/v2/common/_metadata.json.rabl +1 -0
  80. data/app/views/katello/api/v2/content_facet/show.json.rabl +4 -0
  81. data/app/views/katello/api/v2/host_subscriptions/content_override.json.rabl +3 -0
  82. data/app/views/katello/api/v2/{systems/_content.json.rabl → host_subscriptions/product_content.json.rabl} +1 -3
  83. data/app/views/katello/api/v2/sync_plans/show.json.rabl +5 -1
  84. data/app/views/katello/errata_mailer/host_errata.html.erb +2 -2
  85. data/app/views/katello/errata_mailer/promote_errata.html.erb +1 -1
  86. data/app/views/katello/errata_mailer/promote_errata.text.erb +1 -1
  87. data/app/views/katello/errata_mailer/sync_errata.html.erb +1 -1
  88. data/app/views/katello/errata_mailer/sync_errata.text.erb +1 -1
  89. data/app/views/overrides/activation_keys/_host_environment_select.html.erb +21 -11
  90. data/config/katello.yaml.example +1 -0
  91. data/config/routes/api/v2.rb +0 -6
  92. data/config/routes/overrides.rb +3 -0
  93. data/db/migrate/20140117160939_refactor_content_views.rb +1 -0
  94. data/db/migrate/20140222022712_remove_provider_discovery.rb +2 -0
  95. data/db/migrate/20140502164009_rename_system_groups_to_host_collections.rb +7 -0
  96. data/db/migrate/20141210173220_create_docker_tables.rb +4 -3
  97. data/db/migrate/20151219203225_rename_index_repository_puppet_module.rb +1 -1
  98. data/db/migrate/20160203195736_remove_docker_image_schema.rb +1 -0
  99. data/db/migrate/20160317171813_change_activation_key_column_names.rb +11 -0
  100. data/db/migrate/20160323065901_increase_cdn_length.rb +11 -0
  101. data/db/migrate/20160404132250_remove_katello_from_notification_name.rb +26 -0
  102. data/db/seeds.d/103-provisioning_templates.rb +3 -1
  103. data/db/seeds.d/106-mail_notifications.rb +3 -3
  104. data/db/seeds.d/109-atomic_os.rb +11 -0
  105. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/activationKeyConsumed.filter.js +1 -1
  106. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-associations.controller.js +21 -9
  107. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-add-subscriptions.html +3 -3
  108. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-associations-content-hosts.html +41 -40
  109. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-details.html +1 -1
  110. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-info.html +7 -7
  111. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-subscriptions-list.html +3 -3
  112. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/new/new-activation-key.controller.js +1 -1
  113. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/new/views/activation-key-new.html +8 -8
  114. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.routes.js +2 -2
  115. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +0 -8
  116. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-errata.controller.js +19 -16
  117. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-errata.html +1 -1
  118. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details-info.controller.js +5 -3
  119. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details.controller.js +27 -3
  120. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-products.controller.js +79 -26
  121. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-add-subscriptions.html +3 -3
  122. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-details.html +32 -10
  123. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +8 -8
  124. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-products.html +11 -11
  125. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-subscriptions-list.html +3 -3
  126. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-promotion.html +1 -1
  127. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-puppet-modules.html +3 -3
  128. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +1 -1
  129. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/errata-content-hosts.controller.js +33 -10
  130. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/views/errata-details-content-hosts.html +5 -5
  131. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/apply-errata-confirm.html +2 -2
  132. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/details/views/gpg-key-details.html +1 -1
  133. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/gpg-keys/new/new-gpg-key.controller.js +7 -3
  134. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/views/host-collection-details.html +1 -1
  135. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/new/views/host-collection-new-form.html +1 -1
  136. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-subscription.factory.js +3 -1
  137. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/check-current-organization.run.js +3 -15
  138. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/fenced-pages.service.js +36 -0
  139. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/organizations/organization.factory.js +1 -1
  140. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/bulk-actions.html +14 -3
  141. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-details.html +1 -1
  142. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-repositories.html +13 -3
  143. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/details/views/repository-info.html +1 -1
  144. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/details/views/repository-manage-docker-manifests.html +3 -1
  145. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/details/views/repository-manage-packages.html +7 -5
  146. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/details/views/repository-manage-puppet-modules.html +5 -3
  147. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/manifest-import.controller.js +16 -6
  148. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/sync-plan-details-info.controller.js +7 -2
  149. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/details/views/sync-plan-details.html +1 -1
  150. data/engines/bastion_katello/app/assets/stylesheets/bastion_katello/bastion_katello.scss +6 -0
  151. data/lib/katello/engine.rb +4 -3
  152. data/lib/katello/permissions/host_permissions.rb +1 -0
  153. data/lib/katello/version.rb +1 -1
  154. metadata +17 -11
  155. data/app/controllers/katello/concerns/api/v2/bulk_systems_extensions.rb +0 -39
  156. data/app/views/katello/api/v2/systems/content_override.json.rabl +0 -3
  157. data/app/views/katello/api/v2/systems/product_content.json.rabl +0 -3
  158. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-product-details.controller.js +0 -97
  159. data/lib/katello/tasks/upgrades/2.1/import_errata.rake +0 -45
  160. data/lib/katello/tasks/upgrades/2.2/update_gpg_key_urls.rake +0 -20
  161. data/lib/katello/tasks/upgrades/2.2/update_metadata_expire.rake +0 -18
@@ -65,6 +65,10 @@ module Katello
65
65
  super
66
66
  end
67
67
 
68
+ def displayable_product_contents
69
+ self.productContent.select(&:displayable?)
70
+ end
71
+
68
72
  def orphaned?
69
73
  self.provider.redhat_provider? && self.certificate.nil?
70
74
  end
@@ -47,7 +47,7 @@ module Katello
47
47
  cp_product_ids = products.map { |product| product["id"] }
48
48
  cp_product_ids << self.product_id if self.product_id
49
49
  cp_product_ids.each do |cp_id|
50
- product = ::Katello::Product.where(:cp_id => cp_id)
50
+ product = ::Katello::Product.where(:cp_id => cp_id, :organization_id => self.organization_id)
51
51
  if product.any?
52
52
  ::Katello::SubscriptionProduct.where(:subscription_id => self.id, :product_id => product.first.id).first_or_create
53
53
  end
@@ -130,7 +130,7 @@ module Katello
130
130
  Runcible::Models::IsoImporter.new(importer_ssl_options(capsule).merge(:feed => importer_feed_url(capsule)))
131
131
  when Repository::PUPPET_TYPE
132
132
  options = {}
133
- options[:feed] = importer_feed_url(capsule) if self.respond_to?(:url)
133
+ options[:feed] = importer_feed_url(capsule)
134
134
  Runcible::Models::PuppetImporter.new(options)
135
135
  when Repository::DOCKER_TYPE
136
136
  options = {}
@@ -203,7 +203,7 @@ module Katello
203
203
  end
204
204
  end
205
205
 
206
- def generate_distributors
206
+ def generate_distributors(capsule = false)
207
207
  case self.content_type
208
208
  when Repository::YUM_TYPE
209
209
  yum_dist_id = self.pulp_id
@@ -215,7 +215,8 @@ module Katello
215
215
  clone_dist = Runcible::Models::YumCloneDistributor.new(:id => "#{self.pulp_id}_clone",
216
216
  :destination_distributor_id => yum_dist_id)
217
217
  export_dist = Runcible::Models::ExportDistributor.new(false, false, self.relative_path)
218
- distributors = [yum_dist, clone_dist, export_dist]
218
+ distributors = [yum_dist, export_dist]
219
+ distributors << clone_dist unless capsule
219
220
  when Repository::FILE_TYPE
220
221
  dist = Runcible::Models::IsoDistributor.new(true, true)
221
222
  dist.auto_publish = true
@@ -777,8 +778,35 @@ module Katello
777
778
  end
778
779
  end
779
780
 
781
+ def distributors_match?(capsule_distributors)
782
+ generated_distributors = self.generate_distributors(true).map(&:as_json)
783
+ capsule_distributors.each do |dist|
784
+ dist.merge!(dist["config"])
785
+ dist.delete("config")
786
+ end
787
+
788
+ config_check = generated_distributors.any? do |gen_dist|
789
+ capsule_distributors.any? do |cap_dist|
790
+ (gen_dist.to_a - cap_dist.to_a).empty?
791
+ end
792
+ end
793
+ equal_amount_check = generated_distributors.count == capsule_distributors.count
794
+ config_check && equal_amount_check
795
+ end
796
+
797
+ def importer_matches?(capsule_importer)
798
+ generated_importer = self.generate_importer(true).as_json
799
+ (generated_importer.to_a - capsule_importer.to_a).empty?
800
+ end
801
+
780
802
  protected
781
803
 
804
+ def object_to_hash(object)
805
+ hash = {}
806
+ object.instance_variables.each { |var| hash[var.to_s.delete("@")] = object.instance_variable_get(var) }
807
+ hash
808
+ end
809
+
782
810
  def _get_most_recent_sync_status
783
811
  begin
784
812
  history = Katello.pulp_server.extensions.repository.sync_status(pulp_id)
@@ -52,22 +52,34 @@ module Katello
52
52
 
53
53
  def import_applicability(partial = false)
54
54
  facet = self
55
+ errata_uuids = ::Katello::Pulp::Consumer.new(self.uuid).applicable_errata_ids
55
56
  ::Katello::Util::Support.active_record_retry do
57
+ if partial
58
+ consumer_uuids = applicable_errata.pluck("#{Erratum.table_name}.uuid")
59
+ to_remove = consumer_uuids - errata_uuids
60
+ to_add = errata_uuids - consumer_uuids
61
+ else
62
+ to_add = errata_uuids
63
+ to_remove = nil
64
+ Katello::ContentFacetErratum.where(:content_facet_id => facet.id).delete_all
65
+ end
66
+
56
67
  ActiveRecord::Base.transaction do
57
- errata_uuids = ::Katello::Pulp::Consumer.new(self.uuid).applicable_errata_ids
58
- if partial
59
- consumer_uuids = applicable_errata.pluck("#{Erratum.table_name}.uuid")
60
- to_remove = consumer_uuids - errata_uuids
61
- to_add = errata_uuids - consumer_uuids
62
- else
63
- to_add = errata_uuids
64
- to_remove = nil
65
- Katello::ContentFacetErratum.where(:content_facet_id => facet.id).delete_all
66
- end
67
68
  insert_errata_applicability(to_add) unless to_add.blank?
68
69
  remove_errata_applicability(to_remove) unless to_remove.blank?
69
70
  end
70
71
  end
72
+ self.update_errata_status
73
+ end
74
+
75
+ def self.in_content_view_version_environments(version_environments)
76
+ #takes a structure of [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
77
+ queries = version_environments.map do |version_environment|
78
+ version = version_environment[:content_view_version]
79
+ env_ids = version_environment[:environments].map(&:id)
80
+ "(#{table_name}.content_view_id = #{version.content_view_id} AND #{table_name}.lifecycle_environment_id IN (#{env_ids.join(',')}))"
81
+ end
82
+ where(queries.join(" OR "))
71
83
  end
72
84
 
73
85
  def self.with_non_installable_errata(errata)
@@ -81,13 +93,19 @@ module Katello
81
93
  end
82
94
 
83
95
  def self.with_installable_errata(errata)
84
- non_installable = Katello::Host::ContentFacet.with_non_installable_errata(errata)
85
- subquery = Katello::Erratum.select("#{Katello::Erratum.table_name}.id").installable_for_hosts.
86
- where("#{Katello::ContentFacetRepository.table_name}.content_facet_id = #{Katello::Host::ContentFacet.table_name}.id")
96
+ joins_installable_errata.where("#{Katello::Erratum.table_name}.id" => errata)
97
+ end
87
98
 
88
- query = self.joins(:applicable_errata).where("#{Katello::Erratum.table_name}.id" => errata).where("#{Katello::Erratum.table_name}.id" => subquery)
89
- query = query.where.not("#{Katello::Host::ContentFacet.table_name}.id" => non_installable) unless non_installable.empty?
90
- query.uniq
99
+ def self.joins_installable_errata
100
+ facet_repository = Katello::ContentFacetRepository.table_name
101
+ facet_errata = Katello::ContentFacetErratum.table_name
102
+ repository_erratum = Katello::RepositoryErratum.table_name
103
+ erratum = Katello::Erratum.table_name
104
+
105
+ self.joins("INNER JOIN #{facet_repository} on #{facet_repository}.content_facet_id = #{table_name}.id",
106
+ "INNER JOIN #{repository_erratum} on #{repository_erratum}.repository_id = #{facet_repository}.repository_id",
107
+ "INNER JOIN #{erratum} on #{erratum}.id = #{repository_erratum}.erratum_id",
108
+ "INNER JOIN #{facet_errata} on #{facet_errata}.erratum_id = #{erratum}.id")
91
109
  end
92
110
 
93
111
  def content_view_version
@@ -98,6 +116,15 @@ module Katello
98
116
  self.content_view.version(self.lifecycle_environment).available_releases
99
117
  end
100
118
 
119
+ def katello_agent_installed?
120
+ self.host.installed_packages.where("#{Katello::InstalledPackage.table_name}.name" => 'katello-agent').any?
121
+ end
122
+
123
+ def update_errata_status
124
+ host.get_status(::Katello::ErrataStatus).refresh!
125
+ host.refresh_global_status!
126
+ end
127
+
101
128
  private
102
129
 
103
130
  def insert_errata_applicability(uuids)
@@ -44,6 +44,7 @@ module Katello
44
44
 
45
45
  def update_subscription_status
46
46
  host.get_status(::Katello::SubscriptionStatus).refresh!
47
+ host.refresh_global_status!
47
48
  end
48
49
 
49
50
  def self.new_host_from_facts(facts, org, location)
@@ -38,21 +38,16 @@ module Katello
38
38
  DAYS_EXPIRING_SOON = 120
39
39
  DAYS_RECENTLY_EXPIRED = 30
40
40
 
41
- def self.active(subscriptions)
42
- subscriptions.select { |s| s.active }
41
+ def active?
42
+ active
43
43
  end
44
44
 
45
- def self.expiring_soon(subscriptions)
46
- subscriptions.select { |s| (s.end_date.to_date - Date.today) <= DAYS_EXPIRING_SOON }
45
+ def expiring_soon?
46
+ (end_date.to_date - Date.today) <= DAYS_EXPIRING_SOON
47
47
  end
48
48
 
49
- def self.recently_expired(subscriptions)
50
- today_date = Date.today
51
-
52
- subscriptions.select do |s|
53
- end_date = s.end_date.to_date
54
- today_date >= end_date && today_date - end_date <= DAYS_RECENTLY_EXPIRED
55
- end
49
+ def recently_expired?
50
+ Date.today >= end_date.to_date && (Date.today - end_date.to_date) <= DAYS_RECENTLY_EXPIRED
56
51
  end
57
52
 
58
53
  def quantity_available
@@ -33,7 +33,7 @@ module Katello
33
33
  :dependent => :restrict_with_exception,
34
34
  :foreign_key => :library_instance_id
35
35
  has_many :content_view_repositories, :class_name => "Katello::ContentViewRepository",
36
- :dependent => :destroy
36
+ :dependent => :destroy, :inverse_of => :repository
37
37
  has_many :content_views, :through => :content_view_repositories
38
38
 
39
39
  has_many :repository_errata, :class_name => "Katello::RepositoryErratum", :dependent => :destroy
@@ -90,7 +90,10 @@ module Katello
90
90
  :allow_blank => false,
91
91
  :message => ->(_, _) { _("must be one of the following: %s") % Katello::RepositoryTypeManager.repository_types.keys.join(', ') }
92
92
  }
93
- validates :download_policy, inclusion: { in: ::Runcible::Models::YumImporter::DOWNLOAD_POLICIES }, if: :yum?
93
+ validates :download_policy, inclusion: {
94
+ :in => ::Runcible::Models::YumImporter::DOWNLOAD_POLICIES,
95
+ :message => _("must be one of the following: %s") % ::Runcible::Models::YumImporter::DOWNLOAD_POLICIES.join(', ')
96
+ }, if: :yum?
94
97
  validate :ensure_no_download_policy, if: ->(repo) { !repo.yum? }
95
98
  validate :ensure_valid_docker_attributes, :if => :docker?
96
99
  validate :ensure_docker_repo_unprotected, :if => :docker?
@@ -463,18 +466,6 @@ module Katello
463
466
  end
464
467
  end
465
468
 
466
- def systems_with_applicability
467
- ::Katello::System.joins(:bound_repositories).
468
- where("#{::Katello::Repository.table_name}.id" => (self.clones.pluck(:id) + [self.id]))
469
- end
470
-
471
- def import_system_applicability
472
- fail "Can only calculate applicability for Library repositories" unless self.content_view.default?
473
- systems_with_applicability.find_each do |system|
474
- system.import_applicability
475
- end
476
- end
477
-
478
469
  def ostree_branch_names
479
470
  self.ostree_branches.map(&:name)
480
471
  end
@@ -554,6 +545,20 @@ module Katello
554
545
  end
555
546
  end
556
547
 
548
+ def import_host_applicability
549
+ self.hosts_with_applicability.find_each do |host|
550
+ begin
551
+ host.content_facet.import_applicability if host.content_facet.try(:uuid)
552
+ rescue => e
553
+ Rails.logger.error("Could not import applicability for #{host.name}: #{e}")
554
+ end
555
+ end
556
+ end
557
+
558
+ def hosts_with_applicability
559
+ ::Host.joins(:content_facet => :bound_repositories).where("#{Katello::Repository.table_name}.id" => (self.clones.pluck(:id) + [self.id]))
560
+ end
561
+
557
562
  protected
558
563
 
559
564
  def removable_unit_association
@@ -579,7 +584,7 @@ module Katello
579
584
  end
580
585
 
581
586
  def ensure_valid_docker_attributes
582
- if url.blank? || docker_upstream_name.blank?
587
+ if library_instance? && (url.blank? || docker_upstream_name.blank?)
583
588
  errors.add(:base, N_("Repository URL or Upstream Name is empty. Both are required for syncing from the upstream."))
584
589
  end
585
590
  end
@@ -10,8 +10,22 @@ module Katello
10
10
 
11
11
  belongs_to :organization, :class_name => "Organization", :inverse_of => :subscriptions
12
12
 
13
+ scope :in_organization, ->(org) { where(:organization => org) }
14
+
13
15
  def redhat?
14
16
  self.products.any? { |product| product.redhat? }
15
17
  end
18
+
19
+ def active?
20
+ pools.any?(&:active?)
21
+ end
22
+
23
+ def expiring_soon?
24
+ pools.any?(&:expiring_soon?)
25
+ end
26
+
27
+ def recently_expired?
28
+ pools.any?(&:recently_expired?)
29
+ end
16
30
  end
17
31
  end
@@ -53,6 +53,11 @@ module Katello
53
53
  date_obj.strftime('%I:%M %p')
54
54
  end
55
55
 
56
+ def plan_date_time(localtime = true)
57
+ date_obj = localtime ? self.zone_converted : self.sync_date
58
+ date_obj.strftime('%m/%d/%Y %I:%M:%p')
59
+ end
60
+
56
61
  def schedule_format
57
62
  if (self.interval != DURATION[self.interval])
58
63
  format = self.sync_date.iso8601 << "/P" << DURATION[self.interval]
@@ -65,16 +65,6 @@ module Katello
65
65
  where(:environment_id => organization.kt_environments.pluck(:id))
66
66
  end
67
67
 
68
- def self.in_content_view_version_environments(version_environments)
69
- #takes a structure of [{:content_view_version => ContentViewVersion, :environments => [KTEnvironment]}]
70
- queries = version_environments.map do |version_environment|
71
- version = version_environment[:content_view_version]
72
- env_ids = version_environment[:environments].map(&:id)
73
- "(#{table_name}.content_view_id = #{version.content_view_id} AND #{table_name}.environment_id IN (#{env_ids.join(',')}))"
74
- end
75
- where(queries.join(" OR "))
76
- end
77
-
78
68
  def self.uuids_to_ids(uuids)
79
69
  systems = by_uuids(uuids)
80
70
  ids_not_found = Set.new(uuids).subtract(systems.pluck(:uuid))
@@ -4,13 +4,14 @@ class Setting::Katello < Setting
4
4
 
5
5
  self.transaction do
6
6
  [
7
- self.set('default_cdn_ostree_branch_name', N_("Name of the default OSTree branch when enabling a Red Hat OSTree repo"), 'rhel-atomic-host/7/x86_64/standard'),
8
7
  self.set('katello_default_provision', N_("Default provisioning template for new Operating Systems"), 'Katello Kickstart Default'),
9
8
  self.set('katello_default_finish', N_("Default finish template for new Operating Systems"), 'Katello Kickstart Default Finish'),
10
9
  self.set('katello_default_user_data', N_("Default user data for new Operating Systems"), 'Katello Kickstart Default User Data'),
11
10
  self.set('katello_default_PXELinux', N_("Default PXElinux template for new Operating Systems"), 'Kickstart default PXELinux'),
12
11
  self.set('katello_default_iPXE', N_("Default iPXE template for new Operating Systems"), 'Kickstart default iPXE'),
13
12
  self.set('katello_default_ptable', N_("Default partitioning table for new Operating Systems"), 'Kickstart default'),
13
+ self.set('katello_default_kexec', N_("Default kexec template for new Operating Systems"), 'Discovery Red Hat kexec'),
14
+ self.set('katello_default_atomic_provision', N_("Default provisioning template for new Atomic Operating Systems"), 'Katello Atomic Kickstart Default'),
14
15
  self.set('content_action_accept_timeout', N_("Time in seconds to wait for a Host to pickup a remote action"), 20),
15
16
  self.set('content_action_finish_timeout', N_("Time in seconds to wait for a Host to finish a remote action"), 3600),
16
17
  self.set('restrict_composite_view', N_("If set to true, a composite content view may not be published or "\
@@ -0,0 +1,16 @@
1
+ module Katello
2
+ class ProductContentPresenter
3
+ attr_accessor :product_content, :overrides
4
+ delegate :content, :enabled, :product, :to => :product_content
5
+
6
+ def initialize(product_content, overrides)
7
+ @product_content = product_content
8
+ @overrides = overrides
9
+ end
10
+
11
+ def enabled_override
12
+ override = overrides.find { |pc| pc[:contentLabel] == content.label }
13
+ override.nil? ? 'default' : override[:value]
14
+ end
15
+ end
16
+ end
@@ -7,12 +7,18 @@ module Katello
7
7
  ENTITLEMENTS_PARTIAL = 'partial'
8
8
  ENTITLEMENTS_INVALID = 'invalid'
9
9
 
10
+ SYSTEM = "system"
11
+ HYPERVISOR = "hypervisor"
12
+ CANDLEPIN = "candlepin"
13
+ CP_TYPES = [SYSTEM, HYPERVISOR, CANDLEPIN]
14
+
10
15
  lazy_accessor :entitlements, :initializer => lambda { |_s| Resources::Candlepin::Consumer.entitlements(uuid) }
11
16
  lazy_accessor :events, :initializer => lambda { |_s| Resources::Candlepin::Consumer.events(uuid) }
12
17
  lazy_accessor :consumer_attributes, :initializer => lambda { |_s| Resources::Candlepin::Consumer.get(uuid) }
13
18
  lazy_accessor :installed_products, :initializer => lambda { |_s| consumer_attributes['installedProducts'] }
14
19
  lazy_accessor :available_pools, :initializer => lambda { |_s| Resources::Candlepin::Consumer.available_pools(uuid, false) }
15
20
  lazy_accessor :all_available_pools, :initializer => lambda { |_s| Resources::Candlepin::Consumer.available_pools(uuid, true) }
21
+ lazy_accessor :content_overrides, :initializer => lambda { |_s| Resources::Candlepin::Consumer.content_overrides(uuid) }
16
22
 
17
23
  attr_accessor :uuid
18
24
 
@@ -91,10 +97,23 @@ module Katello
91
97
 
92
98
  def virtual_host
93
99
  if virtual_host_info = Resources::Candlepin::Consumer.virtual_host(self.uuid)
94
- Katello::Host::SubscriptionFacet.find_by_uuid(virtual_host_info[:uuid])
100
+ ::Host.joins(:subscription_facet).where("#{Katello::Host::SubscriptionFacet.table_name}.uuid" => virtual_host_info[:uuid]).first
95
101
  end
96
102
  end
97
103
 
104
+ def set_content_override(content_label, name, value = nil)
105
+ Resources::Candlepin::Consumer.update_content_override(self.uuid, content_label, name, value)
106
+ end
107
+
108
+ def products
109
+ pool_ids = self.entitlements.map { |entitlement| entitlement['pool']['id'] }
110
+ Katello::Product.joins(:subscriptions => :pools).where("#{Katello::Pool.table_name}.cp_id" => pool_ids).enabled.uniq
111
+ end
112
+
113
+ def available_product_content
114
+ products.flat_map(&:available_content)
115
+ end
116
+
98
117
  def compliance_reasons
99
118
  Resources::Candlepin::Consumer.compliance(uuid)['reasons'].map do |reason|
100
119
  "#{reason['attributes']['name']}: #{reason['message']}"
@@ -102,6 +121,8 @@ module Katello
102
121
  end
103
122
 
104
123
  def self.distribution_to_puppet_os(name)
124
+ return ::Operatingsystem::REDHAT_ATOMIC_HOST_OS if name == ::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME
125
+
105
126
  name = name.downcase
106
127
  if name =~ /red\s*hat/
107
128
  'RedHat'
@@ -28,6 +28,10 @@ module Katello
28
28
  def find(repository_type)
29
29
  repository_types[repository_type.to_s]
30
30
  end
31
+
32
+ def enabled?(repository_type)
33
+ find(repository_type).present?
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -9,7 +9,7 @@
9
9
  <% if histories.empty? %>
10
10
  <p class="ca"><%= _("No content view history events found.") %></p>
11
11
  <% else %>
12
- <table class="table table-striped ellipsis table-bordered">
12
+ <table class="table table-fixed table-striped table-bordered">
13
13
  <thead>
14
14
  <tr>
15
15
  <th>Content View</th>
@@ -20,7 +20,7 @@
20
20
  <tbody>
21
21
  <% histories.each do |history| %>
22
22
  <tr>
23
- <td>
23
+ <td class='ellipsis'>
24
24
  <a href="/content_views/<%= history.content_view_version.content_view.id %>/versions/<%= history.content_view_version.id %>/details">
25
25
  <%= history.content_view_version.content_view.name %> <%= history.content_view_version.version %>
26
26
  </a>