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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6556a9a45be788950f7121e13324f371dae87f9c
4
- data.tar.gz: e5df82ecc9631da6506fa9d86120c3e487261719
3
+ metadata.gz: d6829678768affb483093b13a2110018c840afa8
4
+ data.tar.gz: 1fc206b7a87207c04f93769ff55dce2f4ade0728
5
5
  SHA512:
6
- metadata.gz: f816179cda53ada12c385dbd8006096fcd3f218a9e12a993b5eaec365b7f89ca1ebd8d93a324808249fe96c167ebf69953c30d7f31cbe00871ae9c6322b82237
7
- data.tar.gz: f669b7c4724baef60b37de2416500cff4373d27b3b85c5a0d3167b1f3fc107d8d64e98c6a27b11fb6fd2529850d073521a94a68e58bb3ffa79c0acdbbc9b6e67
6
+ metadata.gz: bb875205693ff0f2cdc55a4fd06dedf91ebb571f70a33e44c69655b1d08c365630efe93a0d0b491372d2f84462a0e946f832eebf23a7eb54c2fb047e27730ff9
7
+ data.tar.gz: 7a5a4f83be8c4d6c8f81d44ea9bcc4fae3820ad37e3059d2a5e15f108ecfdde6783cfa20f9557df674ab8addc62ad10362fbef721f9740424cf5a0c12e92852f
@@ -8,11 +8,11 @@
8
8
  @import "katello/widgets/tabs";
9
9
  @import "katello/katello_sprites";
10
10
 
11
- @import "jquery-ui-1.8.11.custom.css";
12
- @import "jquery.loadmask.css";
13
- @import "jquery.treeTable.css";
14
- @import "jquery.jscrollpane.css";
15
- @import "ui.spinner.css";
11
+ @import "katello/jquery.loadmask";
12
+ @import "katello/jquery-ui-1.8.11.custom";
13
+ @import "katello/jquery.treeTable";
14
+ @import "katello/jquery.jscrollpane";
15
+ @import "katello/ui.spinner";
16
16
 
17
17
  @import "katello/contents";
18
18
  @import "katello/generic";
@@ -352,9 +352,9 @@ module Katello
352
352
  activation_key = organization.activation_keys.find_by(:name => ak_name)
353
353
  fail HttpErrors::NotFound, _("Couldn't find activation key '%s'") % ak_name unless activation_key
354
354
 
355
- if !activation_key.unlimited_content_hosts && activation_key.usage_count >= activation_key.max_content_hosts
356
- fail Errors::MaxContentHostsReachedException, _("Max Content Hosts (%{limit}) reached for activation key '%{name}'") %
357
- { :limit => activation_key.max_content_hosts, :name => activation_key.name }
355
+ if !activation_key.unlimited_hosts && activation_key.usage_count >= activation_key.max_hosts
356
+ fail Errors::MaxHostsReachedException, _("Max Hosts (%{limit}) reached for activation key '%{name}'") %
357
+ { :limit => activation_key.max_hosts, :name => activation_key.name }
358
358
  end
359
359
  activation_key
360
360
  end
@@ -33,8 +33,8 @@ module Katello
33
33
  param :environment, Hash, :desc => N_("environment")
34
34
  param :environment_id, :identifier, :desc => N_("environment id")
35
35
  param :content_view_id, :identifier, :desc => N_("content view id")
36
- param :max_content_hosts, :number, :desc => N_("maximum number of registered content hosts")
37
- param :unlimited_content_hosts, :bool, :desc => N_("can the activation key have unlimited content hosts")
36
+ param :max_hosts, :number, :desc => N_("maximum number of registered content hosts")
37
+ param :unlimited_hosts, :bool, :desc => N_("can the activation key have unlimited hosts")
38
38
  def create
39
39
  @activation_key = ActivationKey.new(activation_key_params) do |activation_key|
40
40
  activation_key.environment = @environment if @environment
@@ -53,8 +53,8 @@ module Katello
53
53
  param :description, String, :desc => N_("description")
54
54
  param :environment_id, :identifier, :desc => N_("environment id")
55
55
  param :content_view_id, :identifier, :desc => N_("content view id")
56
- param :max_content_hosts, :number, :desc => N_("maximum number of registered content hosts")
57
- param :unlimited_content_hosts, :bool, :desc => N_("can the activation key have unlimited content hosts")
56
+ param :max_hosts, :number, :desc => N_("maximum number of registered content hosts")
57
+ param :unlimited_hosts, :bool, :desc => N_("can the activation key have unlimited hosts")
58
58
  param :release_version, String, :desc => N_("content release version")
59
59
  param :service_level, String, :desc => N_("service level")
60
60
  param :auto_attach, :bool, :desc => N_("auto attach subscriptions upon registration")
@@ -302,22 +302,22 @@ module Katello
302
302
  :release_version,
303
303
  :service_level,
304
304
  :auto_attach,
305
- :max_content_hosts,
306
- :unlimited_content_hosts,
305
+ :max_hosts,
306
+ :unlimited_hosts,
307
307
  :content_overrides => [],
308
308
  :host_collection_ids => [])
309
309
 
310
310
  key_params[:environment_id] = params[:environment][:id] if params[:environment].try(:[], :id)
311
311
  key_params[:content_view_id] = params[:content_view][:id] if params[:content_view].try(:[], :id)
312
- unlimited = params[:activation_key].try(:[], :unlimited_content_hosts)
313
- max_hosts = params[:activation_key].try(:[], :max_content_hosts)
312
+ unlimited = params[:activation_key].try(:[], :unlimited_hosts)
313
+ max_hosts = params[:activation_key].try(:[], :max_hosts)
314
314
 
315
315
  if unlimited && max_hosts
316
- key_params[:unlimited_content_hosts] = true
317
- key_params[:max_content_hosts] = nil
316
+ key_params[:unlimited_hosts] = true
317
+ key_params[:max_hosts] = nil
318
318
  else
319
- key_params[:unlimited_content_hosts] = false if max_hosts
320
- key_params[:max_content_hosts] = nil if unlimited
319
+ key_params[:unlimited_hosts] = false if max_hosts
320
+ key_params[:max_hosts] = nil if unlimited
321
321
  end
322
322
 
323
323
  key_params
@@ -44,7 +44,6 @@ module Katello
44
44
  :subtotal => collection.count }
45
45
  end
46
46
 
47
- # rubocop:disable MethodLength
48
47
  def scoped_search(query, default_sort_by, default_sort_order, options = {})
49
48
  resource = options[:resource_class] || resource_class
50
49
  includes = options.fetch(:includes, [])
@@ -76,18 +75,27 @@ module Katello
76
75
  else
77
76
  query = query.paginate(paginate_options)
78
77
  end
78
+ page = params[:page] || 1
79
+ per_page = params[:per_page] || ::Setting::General.entries_per_page
79
80
 
81
+ scoped_search_results(query, sub_total, total, page, per_page)
82
+ rescue ScopedSearch::QueryNotSupported => error
83
+ return scoped_search_results(query, sub_total, total, page, per_page, error.message)
84
+ end
85
+
86
+ protected
87
+
88
+ def scoped_search_results(query, sub_total, total, page, per_page, error = nil)
80
89
  {
81
90
  :results => query,
82
91
  :subtotal => sub_total,
83
92
  :total => total,
84
- :page => params[:page] || 1,
85
- :per_page => params[:per_page] || ::Setting::General.entries_per_page
93
+ :page => page,
94
+ :per_page => per_page,
95
+ :error => error
86
96
  }
87
97
  end
88
98
 
89
- protected
90
-
91
99
  def labelize_params(param_hash)
92
100
  return param_hash[:label] unless param_hash.try(:[], :label).nil?
93
101
  return Util::Model.labelize(param_hash[:name]) unless param_hash.try(:[], :name).nil?
@@ -1,6 +1,6 @@
1
1
  module Katello
2
2
  class Api::V2::ContentViewVersionsController < Api::V2::ApiController
3
- include Concerns::Api::V2::BulkSystemsExtensions
3
+ include Concerns::Api::V2::BulkHostsExtensions
4
4
  include Katello::Concerns::FilteredAutoCompleteSearch
5
5
 
6
6
  before_filter :find_content_view_version, :only => [:show, :promote, :destroy, :export]
@@ -94,47 +94,47 @@ module Katello
94
94
  param :resolve_dependencies, :bool, :desc => N_("If true, when adding the specified errata or packages, any needed dependencies will be copied as well.")
95
95
  param :propagate_all_composites, :bool, :desc => N_("If true, will publish a new composite version using any specified content_view_version_id that has been promoted to a lifecycle environment.")
96
96
  param :add_content, Hash do
97
- param :errata_ids, Array, :desc => "Errata uuids to copy into the new versions."
98
- param :package_ids, Array, :desc => "Package uuids to copy into the new versions."
99
- param :puppet_module_ids, Array, :desc => "Puppet Modules to copy into the new versions."
97
+ param :errata_ids, Array, :desc => "Errata ids or uuids to copy into the new versions."
98
+ param :package_ids, Array, :desc => "Package ids or uuids to copy into the new versions."
99
+ param :puppet_module_ids, Array, :desc => "Puppet Module ids or uuids to copy into the new versions."
100
100
  end
101
- param :update_systems, Hash, :desc => N_("After generating the incremental update, apply the changes to the specified systems. Only Errata are supported currently.") do
101
+ param :update_hosts, Hash, :desc => N_("After generating the incremental update, apply the changes to the specified hosts. Only Errata are supported currently.") do
102
102
  param :included, Hash, :required => true, :action_aware => true do
103
- param :search, String, :required => false, :desc => N_("Search string for systems to perform an action on")
104
- param :ids, Array, :required => false, :desc => N_("List of system ids to perform an action on")
103
+ param :search, String, :required => false, :desc => N_("Search string for host to perform an action on")
104
+ param :ids, Array, :required => false, :desc => N_("List of host ids to perform an action on")
105
105
  end
106
106
  param :excluded, Hash, :required => false, :action_aware => true do
107
- param :ids, Array, :required => false, :desc => N_("List of system ids to exclude and not run an action on")
107
+ param :ids, Array, :required => false, :desc => N_("List of host ids to exclude and not run an action on")
108
108
  end
109
- param :update_all_systems, :bool, :required => false, :desc => N_("Update all editable and applicable systems, not just ones using the selected Content View Versions and Environments")
110
109
  end
111
110
  def incremental_update
112
- if params[:add_content] && params[:add_content].key?(:errata_ids) && params[:update_systems]
113
- systems = calculate_systems_for_incremental(params[:update_systems], params[:propagate_to_composites])
111
+ if params[:add_content] && params[:add_content].key?(:errata_ids) && params[:update_hosts]
112
+ hosts = calculate_hosts_for_incremental(params[:update_hosts], params[:propagate_to_composites])
114
113
  else
115
- systems = []
114
+ hosts = []
116
115
  end
117
116
 
118
117
  validate_content(params[:add_content])
119
118
  task = async_task(::Actions::Katello::ContentView::IncrementalUpdates, @version_environments, @composite_version_environments, params[:add_content],
120
- params[:resolve_dependencies], systems, params[:description])
119
+ params[:resolve_dependencies], hosts, params[:description])
121
120
  respond_for_async :resource => task
122
121
  end
123
122
 
124
123
  private
125
124
 
126
- def calculate_systems_for_incremental(bulk_params, use_composites)
127
- if bulk_params[:update_all_systems]
128
- version_environments = find_version_environments_for_systems(use_composites)
129
- restrict_systems = lambda do |relation|
130
- errata = Erratum.where(:uuid => params[:add_content][:errata_ids])
131
- relation.in_content_view_version_environments(version_environments).with_applicable_errata(errata)
125
+ def calculate_hosts_for_incremental(bulk_params, use_composites)
126
+ if bulk_params[:included].try(:[], :search)
127
+ version_environments = find_version_environments_for_hosts(use_composites)
128
+ restrict_hosts = lambda do |relation|
129
+ errata = Erratum.with_identifiers(params[:add_content][:errata_ids])
130
+ content_facets = Host::ContentFacet.in_content_view_version_environments(version_environments).with_applicable_errata(errata)
131
+ relation.where(:id => content_facets.pluck(:host_id))
132
132
  end
133
133
  else
134
- restrict_systems = nil
134
+ restrict_hosts = nil
135
135
  end
136
136
 
137
- find_bulk_systems(:editable, params[:update_systems], restrict_systems)
137
+ find_bulk_hosts(:editable, params[:update_hosts], restrict_hosts)
138
138
  end
139
139
 
140
140
  def find_content_view_version
@@ -178,14 +178,14 @@ module Katello
178
178
  @composite_version_environments << version_environment
179
179
  else
180
180
  @version_environments << version_environment
181
- @composite_version_environments += lookup_all_composites(version) if params[:propagate_all_composites]
181
+ @composite_version_environments += lookup_all_composites(version_environment[:content_view_version]) if params[:propagate_all_composites]
182
182
  end
183
183
  end
184
184
  @composite_version_environments.uniq! { |cve| cve[:content_view_version] }
185
185
  end
186
186
 
187
187
  def lookup_all_composites(component)
188
- component.composites.select { |c| c.environment.any? }.map do |composite|
188
+ component.composites.select { |c| c.environments.any? }.map do |composite|
189
189
  {
190
190
  :content_view_version => composite,
191
191
  :environments => composite.environments
@@ -193,7 +193,7 @@ module Katello
193
193
  end
194
194
  end
195
195
 
196
- def find_version_environments_for_systems(include_composites)
196
+ def find_version_environments_for_hosts(include_composites)
197
197
  if include_composites
198
198
  version_environments_for_systems_map = {}
199
199
  @version_environments.each do |version_environment|
@@ -220,9 +220,12 @@ module Katello
220
220
 
221
221
  def validate_content(content)
222
222
  if content[:errata_ids]
223
- errata = Erratum.where(:uuid => content[:errata_ids])
224
- not_found = content[:errata_ids] - errata.pluck(:uuid)
225
- fail _("Could not find errata with id: %s") % not_found.join(", ") unless not_found.empty?
223
+ errata = Erratum.with_identifiers(content[:errata_ids])
224
+ not_found_count = content[:errata_ids].length - errata.length
225
+ if not_found_count > 0
226
+ fail _("Could not find %{count} errata. Only found: %{found}") %
227
+ { :count => not_found_count, :found => errata.pluck(:errata_id).join(',') }
228
+ end
226
229
  end
227
230
 
228
231
  if content[:package_ids]
@@ -191,7 +191,10 @@ module Katello
191
191
  def view_params
192
192
  attrs = [:name, :description, {:repository_ids => []}, {:component_ids => []}]
193
193
  attrs.push(:label, :composite) if action_name == "create"
194
- params.require(:content_view).permit(*attrs)
194
+ permitted_params = params.require(:content_view).permit(*attrs)
195
+ permitted_params[:repository_ids] ||= [] if params[:content_view].key?(:repository_ids)
196
+ permitted_params[:component_ids] ||= [] if params[:content_view].key?(:component_ids)
197
+ permitted_params
195
198
  end
196
199
 
197
200
  def find_environment
@@ -1,7 +1,8 @@
1
1
  module Katello
2
2
  class Api::V2::HostSubscriptionsController < Katello::Api::V2::ApiController
3
- before_filter :find_host
3
+ before_filter :find_host, :except => :create
4
4
  before_filter :check_subscriptions, :only => [:add_subscriptions, :remove_subscriptions]
5
+ before_filter :find_content_view_environment, :only => :create
5
6
 
6
7
  resource_description do
7
8
  api_version 'v2'
@@ -35,6 +36,56 @@ module Katello
35
36
  respond_for_index :collection => collection
36
37
  end
37
38
 
39
+ api :DELETE, "/hosts/:host_id/subscriptions/", N_("Unregister the host as a subscription consumer")
40
+ param :host_id, Integer, :desc => N_("Id of the host"), :required => true
41
+ def destroy
42
+ sync_task(::Actions::Katello::Host::Unregister, @host)
43
+ @host.reload
44
+ respond_for_destroy(:resource => @host)
45
+ end
46
+
47
+ api :POST, "/hosts/subscriptions/", N_("Register a host with subscription and information.")
48
+ param :name, String, :desc => N_("Name of the host"), :required => true
49
+ param :uuid, String, :desc => N_("UUID to use for registered host, random uuid is generated if not provided")
50
+ param :facts, Hash, :desc => N_("Key-value hash of subscription-manager facts, nesting uses a period delimiter (.)")
51
+ param :hypervisor_guest_uuids, Array, :desc => N_("UUIDs of the virtual guests from the host's hypervisor")
52
+ param :installed_products, Array, :desc => N_("List of products installed on the host") do
53
+ param :product_id, String, :desc => N_("Product id as listed from a host's installed products, \
54
+ this is not the same product id as the products api returns")
55
+ param :product_name, String, :desc => N_("Product name as listed from a host's installed products")
56
+ end
57
+ param :release_version, String, :desc => N_("Release version of the content host")
58
+ param :service_level, String, :desc => N_("A service level for auto-healing process, e.g. SELF-SUPPORT")
59
+ param :lifecycle_environment_id, Integer, :desc => N_("Lifecycle Environment ID"), :required => true
60
+ param :content_view_id, Integer, :desc => N_("Content View ID"), :required => true
61
+ def create
62
+ rhsm_params = params_to_rhsm_params
63
+ name = rhsm_params[:facts]['network.hostname']
64
+
65
+ host = Katello::Host::SubscriptionFacet.find_or_create_host(name, @content_view_environment.environment.organization, rhsm_params)
66
+ sync_task(::Actions::Katello::Host::Register, host, System.new, rhsm_params, @content_view_environment)
67
+ host.reload
68
+
69
+ respond_for_show(:resource => host, :template => '../../../api/v2/hosts/show')
70
+ end
71
+
72
+ def params_to_rhsm_params
73
+ rhsm_params = params.slice(:facts, :uuid, :name)
74
+ rhsm_params[:releaseVer] = params['release_version'] if params['release_version']
75
+ rhsm_params[:serviceLevel] = params['service_level'] if params['service_level']
76
+ rhsm_params[:guestIds] = params['hypervisor_guest_uuids'] if params[:hypervisor_guest_uuids]
77
+ rhsm_params[:type] = Katello::Candlepin::Consumer::SYSTEM
78
+ rhsm_params[:facts] ||= {}
79
+ rhsm_params[:facts]['network.hostname'] ||= rhsm_params[:name]
80
+
81
+ if params['installed_products']
82
+ rhsm_params[:installedProducts] = params['installed_products'].map do |product|
83
+ { :productId => product['product_id'], :productName => product['product_name'] }
84
+ end
85
+ end
86
+ rhsm_params
87
+ end
88
+
38
89
  api :PUT, "/hosts/:host_id/subscriptions/remove_subscriptions"
39
90
  param :host_id, Integer, :desc => N_("Id of the host"), :required => true
40
91
  param :subscriptions, Array, :desc => N_("Array of subscriptions to remove") do
@@ -68,8 +119,54 @@ module Katello
68
119
  respond_for_index(:collection => index_response, :template => "index")
69
120
  end
70
121
 
122
+ api :PUT, "/hosts/:host_id/subscriptions/content_override", N_("Set content overrides for the host")
123
+ param :host_id, String, :desc => N_("Id of the content host"), :required => true
124
+ param :content_label, String, :desc => N_("Label of the content"), :required => true
125
+ param :value, [0, 1, "default"], :desc => N_("Override to 0/1, or 'default'"), :required => true
126
+ def content_override
127
+ content_override = validate_content_overrides(params)
128
+ @host.subscription_facet.candlepin_consumer.set_content_override(content_override[:content_label], 'enabled', content_override[:value])
129
+
130
+ product_content
131
+ end
132
+
133
+ api :GET, "/hosts/:host_id/subscriptions/product_content", N_("Get content and overrides for the host")
134
+ param :host_id, String, :desc => N_("Id of the host"), :required => true
135
+ def product_content
136
+ content = @host.subscription_facet.candlepin_consumer.available_product_content
137
+ overrides = @host.subscription_facet.candlepin_consumer.content_overrides
138
+ results = content.map { |product_content| Katello::ProductContentPresenter.new(product_content, overrides) }
139
+
140
+ respond_for_index(:collection => full_result_response(results))
141
+ end
142
+
71
143
  private
72
144
 
145
+ def validate_content_overrides(content_params)
146
+ case content_params[:value].to_s
147
+ when 'default'
148
+ content_params[:value] = nil
149
+ when '1'
150
+ content_params[:value] = 1
151
+ when '0'
152
+ content_params[:value] = 0
153
+ else
154
+ fail HttpErrors::BadRequest, _("Value must be 0/1, or 'default'")
155
+ end
156
+
157
+ available_content = @host.subscription_facet.candlepin_consumer.available_product_content
158
+ unless available_content.map(&:content).any? { |content| content.label == content_params[:content_label] }
159
+ fail HttpErrors::BadRequest, _("Invalid content label: %s") % content_params[:content_label]
160
+ end
161
+ content_params
162
+ end
163
+
164
+ def find_content_view_environment
165
+ @content_view_environment = Katello::ContentViewEnvironment.where(:content_view_id => params[:content_view_id],
166
+ :environment_id => params[:lifecycle_environment_id]).first
167
+ fail HttpErrors::NotFound, _("Couldn't find specified Content View and Lifecycle Environment.") if @content_view_environment.nil?
168
+ end
169
+
73
170
  def check_subscriptions
74
171
  fail HttpErrors::BadRequest, _("subscriptions not specified") if params[:subscriptions].nil? || params[:subscriptions].empty?
75
172
  end
@@ -79,9 +176,9 @@ module Katello
79
176
  end
80
177
 
81
178
  def action_permission
82
- if ['add_subscriptions', 'remove_subscriptions', 'auto_attach'].include?(params[:action])
179
+ if ['add_subscriptions', 'remove_subscriptions', 'auto_attach', 'content_override'].include?(params[:action])
83
180
  :edit
84
- elsif ['index', 'events'].include?(params[:action])
181
+ elsif ['index', 'events', 'product_content'].include?(params[:action])
85
182
  :view
86
183
  end
87
184
  end
@@ -144,7 +144,7 @@ module Katello
144
144
  render :json => repo_types.values
145
145
  end
146
146
 
147
- api :GET, "/repositories/:id", N_("Show a custom repository")
147
+ api :GET, "/repositories/:id", N_("Show a repository")
148
148
  param :id, :identifier, :required => true, :desc => N_("repository ID")
149
149
  def show
150
150
  respond_for_show(:resource => @repository)
@@ -194,7 +194,7 @@ module Katello
194
194
  respond_for_async :resource => task
195
195
  end
196
196
 
197
- api :PUT, "/repositories/:id", N_("Update a custom repository")
197
+ api :PUT, "/repositories/:id", N_("Update a repository")
198
198
  param :name, String, :desc => N_("New name for the repository")
199
199
  param :id, :identifier, :required => true, :desc => N_("repository ID")
200
200
  param :gpg_key_id, :number, :desc => N_("ID of a gpg key that will be assigned to this repository")
@@ -15,7 +15,7 @@ module Katello
15
15
  param :name, String, :required => false, :desc => N_("Repository set name to search on")
16
16
  def index
17
17
  collection = {}
18
- collection[:results] = @product.productContent
18
+ collection[:results] = @product.displayable_product_contents
19
19
  # filter on name if it is provided
20
20
  collection[:results] = collection[:results].select { |pc| pc.content.name == params[:name] } if params[:name]
21
21
  collection[:subtotal] = collection[:results].size
@@ -81,7 +81,6 @@ module Katello
81
81
  end
82
82
 
83
83
  api :POST, "/organizations/:organization_id/subscriptions/upload", N_("Upload a subscription manifest")
84
- api :POST, "/subscriptions/upload", N_("Upload a subscription manifest")
85
84
  param :organization_id, :number, :desc => N_("Organization id"), :required => true
86
85
  param :content, File, :desc => N_("Subscription manifest file"), :required => true
87
86
  param :repository_url, String, :desc => N_("repository url"), :required => false
@@ -7,7 +7,7 @@ module Katello
7
7
 
8
8
  skip_before_filter :set_default_response_format, :only => :report
9
9
 
10
- before_filter :find_system, :only => [:destroy, :show, :update, :enabled_repos, :releases, :tasks,
10
+ before_filter :find_system, :only => [:show, :update, :enabled_repos, :releases, :tasks,
11
11
  :content_override, :product_content]
12
12
  before_filter :find_environment, :only => [:index, :report]
13
13
  before_filter :find_optional_organization, :only => [:create, :index, :report]
@@ -61,37 +61,6 @@ module Katello
61
61
  collection
62
62
  end
63
63
 
64
- api :POST, "/systems", N_("Register a content host"), :deprecated => true
65
- api :POST, "/environments/:environment_id/systems", N_("Register a content host in environment"), :deprecated => true
66
- api :POST, "/host_collections/:host_collection_id/systems", N_("Register a content host in environment"), :deprecated => true
67
- param :name, String, :desc => N_("Name of the content host"), :required => true, :action_aware => true
68
- param :description, String, :desc => N_("Description of the content host")
69
- param :location, String, :desc => N_("Physical location of the content host")
70
- param :facts, Hash, :desc => N_("Key-value hash of content host-specific facts"), :action_aware => true, :required => true do
71
- param :fact, String, :desc => N_("Any number of facts about this content host")
72
- end
73
- param :type, String, :desc => N_("Type of the content host, it should always be 'system'"), :required => true, :action_aware => true
74
- param :guest_ids, Array, :desc => N_("IDs of the virtual guests running on this content host")
75
- param :installed_products, Array, :desc => N_("List of products installed on the content host"), :action_aware => true
76
- param :release_ver, String, :desc => N_("Release version of the content host")
77
- param :service_level, String, :allow_nil => true, :desc => N_("A service level for auto-healing process, e.g. SELF-SUPPORT"), :action_aware => true
78
- param :last_checkin, String, :desc => N_("Last check-in time of this content host")
79
- param :organization_id, :number, :desc => N_("Specify the organization"), :required => true
80
- param :environment_id, String, :desc => N_("Specify the environment")
81
- param :content_view_id, String, :desc => N_("Specify the content view")
82
- param :host_collection_ids, Array, :desc => N_("Specify the host collections as an array")
83
- def create
84
- rhsm_params = system_params(params)
85
- rhsm_params[:facts] ||= {}
86
- rhsm_params[:facts]['network.hostname'] ||= rhsm_params[:name]
87
- content_view_environment = ContentViewEnvironment.where(:content_view_id => @content_view, :environment_id => @environment).first
88
- host = Katello::Host::SubscriptionFacet.new_host_from_facts(rhsm_params[:facts], @organization, Location.default_location)
89
-
90
- sync_task(::Actions::Katello::Host::Register, host, System.new, rhsm_params, content_view_environment)
91
- @system = host.reload.content_host
92
- respond_for_create
93
- end
94
-
95
64
  api :PUT, "/systems/:id", N_("Update content host information"), :deprecated => true
96
65
  param :id, String, :desc => N_("UUID of the content host"), :required => true
97
66
  param :release_ver, String, :desc => N_("Release version of the content host")
@@ -111,13 +80,6 @@ module Katello
111
80
  respond
112
81
  end
113
82
 
114
- api :DELETE, "/systems/:id", N_("Unregister a content host"), :deprecated => true
115
- param :id, String, :desc => N_("UUID of the content host"), :required => true
116
- def destroy
117
- sync_task(::Actions::Katello::System::Destroy, @system, :unregistering => true)
118
- respond :message => _("Deleted content host '%s'") % params[:id], :status => 204
119
- end
120
-
121
83
  api :GET, "/systems/:id/releases", N_("Show releases available for the content host"), :deprecated => true
122
84
  param :id, String, :desc => N_("UUID of the content host"), :required => true
123
85
  desc <<-DESC
@@ -130,37 +92,6 @@ module Katello
130
92
  respond_for_index :collection => response
131
93
  end
132
94
 
133
- api :PUT, "/systems/:id/content_override", N_("Set content overrides for the content host")
134
- param :id, String, :desc => N_("UUID of the content host"), :required => true
135
- param :content_override, Hash, :desc => N_("Content override parameters") do
136
- param :content_label, String, :desc => N_("Label of the content"), :required => true
137
- param :value, [0, 1, "default"], :desc => N_("Override to 0/1, or 'default'"), :required => true
138
- end
139
- def content_override
140
- content_override = validate_content_overrides(params[:content_override])
141
- @system.set_content_override(content_override[:content_label], 'enabled', content_override[:value])
142
-
143
- content = @system.available_content
144
- response = {
145
- :results => content,
146
- :total => content.size,
147
- :subtotal => content.size
148
- }
149
- respond_for_index :collection => response
150
- end
151
-
152
- api :GET, "/systems/:id/product_content", N_("Get content overrides for the content host")
153
- param :id, String, :desc => N_("UUID of the content host"), :required => true
154
- def product_content
155
- content = @system.available_content
156
- response = {
157
- :results => content,
158
- :total => content.size,
159
- :subtotal => content.size
160
- }
161
- respond_for_index :collection => response
162
- end
163
-
164
95
  private
165
96
 
166
97
  def system_params_to_host_params(sys_params)
@@ -179,24 +110,6 @@ module Katello
179
110
  host_params
180
111
  end
181
112
 
182
- def validate_content_overrides(content_params)
183
- case content_params[:value].to_s
184
- when 'default'
185
- content_params[:value] = nil
186
- when '1'
187
- content_params[:value] = 1
188
- when '0'
189
- content_params[:value] = 0
190
- else
191
- fail HttpErrors::BadRequest, _("Value must be 0/1, or 'default'")
192
- end
193
-
194
- unless @system.available_content.map(&:content).any? { |content| content.label == content_params[:content_label] }
195
- fail HttpErrors::BadRequest, _("Invalid content label: %s") % content_params[:content_label]
196
- end
197
- content_params
198
- end
199
-
200
113
  def find_system
201
114
  @system = System.where(:uuid => params[:id]).first
202
115
  if @system.nil?