katello 2.4.0.rc2 → 2.4.0.rc3
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.
- data/app/controllers/katello/api/v2/activation_keys_controller.rb +14 -1
- data/app/controllers/katello/api/v2/api_controller.rb +0 -55
- data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +8 -6
- data/app/controllers/katello/api/v2/content_view_histories_controller.rb +23 -0
- data/app/controllers/katello/api/v2/content_view_versions_controller.rb +0 -1
- data/app/controllers/katello/api/v2/content_views_controller.rb +0 -13
- data/app/controllers/katello/api/v2/environments_controller.rb +0 -1
- data/app/controllers/katello/api/v2/host_collections_controller.rb +0 -14
- data/app/controllers/katello/api/v2/subscriptions_controller.rb +20 -57
- data/app/controllers/katello/api/v2/sync_plans_controller.rb +0 -1
- data/app/controllers/katello/api/v2/systems_bulk_actions_controller.rb +0 -1
- data/app/controllers/katello/api/v2/systems_controller.rb +56 -38
- data/app/controllers/katello/application_controller.rb +2 -11
- data/app/controllers/katello/concerns/api/api_controller.rb +0 -8
- data/app/controllers/katello/concerns/api/v2/bulk_systems_extensions.rb +2 -14
- data/app/lib/actions/candlepin/import_pool_handler.rb +0 -1
- data/app/lib/actions/katello/content_view/remove.rb +0 -2
- data/app/lib/actions/katello/content_view_version/incremental_update.rb +2 -2
- data/app/lib/actions/katello/product/create.rb +1 -1
- data/app/lib/actions/{elastic_search → katello}/provider/reindex_subscriptions.rb +4 -2
- data/app/lib/actions/katello/repository/clone_docker_content.rb +1 -1
- data/app/lib/actions/katello/repository/clone_yum_content.rb +1 -1
- data/app/lib/actions/{elastic_search → katello}/repository/filtered_index_content.rb +4 -2
- data/app/lib/actions/katello/repository/finish_upload.rb +1 -1
- data/app/lib/actions/{elastic_search → katello}/repository/index_content.rb +4 -2
- data/app/lib/actions/katello/repository/sync.rb +1 -1
- data/app/lib/actions/katello/subscription/subscribe.rb +26 -0
- data/app/lib/actions/katello/system/auto_attach_subscriptions.rb +4 -2
- data/app/lib/actions/katello/system/create.rb +2 -4
- data/app/lib/actions/katello/system/destroy.rb +6 -1
- data/app/lib/actions/katello/system/update.rb +1 -2
- data/app/lib/actions/pulp/abstract_async_task.rb +6 -5
- data/app/lib/katello/resources/candlepin.rb +5 -2
- data/app/lib/katello/util/support.rb +1 -2
- data/app/models/katello/concerns/organization_extensions.rb +1 -18
- data/app/models/katello/content_view.rb +0 -2
- data/app/models/katello/content_view_erratum_filter_rule.rb +0 -2
- data/app/models/katello/content_view_history.rb +2 -2
- data/app/models/katello/content_view_package_filter_rule.rb +0 -2
- data/app/models/katello/content_view_package_group_filter_rule.rb +0 -2
- data/app/models/katello/glue/candlepin/activation_key.rb +2 -2
- data/app/models/katello/glue/candlepin/pool.rb +20 -8
- data/app/models/katello/glue/provider.rb +2 -7
- data/app/models/katello/glue/pulp/repo.rb +0 -1
- data/app/models/katello/host_collection.rb +1 -14
- data/app/models/katello/hypervisor.rb +0 -1
- data/app/models/katello/job.rb +0 -7
- data/app/models/katello/kt_environment.rb +4 -0
- data/app/models/katello/ping.rb +2 -10
- data/app/models/katello/pool.rb +0 -3
- data/app/models/katello/pulp_sync_status.rb +0 -2
- data/app/models/katello/pulp_task_status.rb +0 -1
- data/app/models/katello/rhsm_fact_importer.rb +42 -0
- data/app/models/katello/rhsm_fact_name.rb +9 -0
- data/app/models/katello/rhsm_fact_parser.rb +28 -0
- data/app/models/katello/system.rb +41 -43
- data/app/models/katello/task_status.rb +0 -2
- data/app/presenters/katello/activation_key_subscription_presenter.rb +10 -0
- data/app/presenters/katello/system_subscription_presenter.rb +10 -0
- data/app/views/katello/api/v2/activation_keys/subscriptions.json.rabl +2 -1
- data/app/views/katello/api/v2/ping/show.json.rabl +1 -1
- data/app/views/katello/api/v2/subscriptions/base.json.rabl +10 -1
- data/app/views/katello/api/v2/subscriptions/show.json.rabl +1 -2
- data/app/views/katello/api/v2/systems/subscriptions.json.rabl +8 -0
- data/config/katello.yaml.example +0 -10
- data/config/routes/api/v2.rb +14 -3
- data/db/migrate/20151015152947_add_virt_only_to_katello_pools.rb +11 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-add-subscriptions.controller.js +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-subscriptions.controller.js +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-add-subscriptions.html +4 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/views/activation-key-subscriptions-list.html +15 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host.factory.js +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-add-subscriptions.controller.js +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-base-subscriptions.controller.js +0 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-subscriptions.controller.js +2 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-add-subscriptions.html +4 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-subscriptions-list.html +14 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-view.factory.js +0 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/{content-view-details-history.controller.js → histories/content-view-history.controller.js} +5 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/histories/content-view-history.factory.js +22 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/{views/content-view-details-history.html → histories/views/content-view-history.html} +0 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/new-environment.controller.js +9 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/grouped.filter.js +21 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/subscriptionAttachAmountFilter.filter.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/subscriptions-table-full.html +1 -1
- data/lib/katello.rb +0 -3
- data/lib/katello/engine.rb +3 -8
- data/lib/katello/permissions/content_host_permissions.rb +1 -1
- data/lib/katello/permissions/content_view_permissions.rb +2 -1
- data/lib/katello/plugin.rb +0 -1
- data/lib/katello/tasks/clean_backend_objects.rake +0 -1
- data/lib/katello/tasks/reindex.rake +5 -2
- data/lib/katello/tasks/setup.rake +0 -9
- data/lib/katello/version.rb +1 -1
- metadata +1460 -1449
- checksums.yaml +0 -7
- data/app/lib/actions/elastic_search/abstract.rb +0 -8
- data/app/lib/actions/elastic_search/reindex.rb +0 -26
- data/app/lib/actions/elastic_search/reindex_on_association_change.rb +0 -25
- data/app/lib/actions/elastic_search/repository/remove_packages.rb +0 -16
- data/app/lib/actions/middleware/elasticsearch_services_check.rb +0 -9
- data/app/models/katello/ext/indexed_model.rb +0 -173
- data/app/models/katello/glue/elastic_search/backend_indexed_model.rb +0 -113
- data/app/models/katello/glue/elastic_search/content_view_erratum_filter_rule.rb +0 -31
- data/app/models/katello/glue/elastic_search/content_view_history.rb +0 -31
- data/app/models/katello/glue/elastic_search/content_view_package_filter_rule.rb +0 -32
- data/app/models/katello/glue/elastic_search/content_view_package_group_filter_rule.rb +0 -29
- data/app/models/katello/glue/elastic_search/facet_item.rb +0 -9
- data/app/models/katello/glue/elastic_search/host_collection.rb +0 -10
- data/app/models/katello/glue/elastic_search/items.rb +0 -196
- data/app/models/katello/glue/elastic_search/job.rb +0 -23
- data/app/models/katello/glue/elastic_search/system.rb +0 -153
- data/app/models/katello/glue/elastic_search/task_status.rb +0 -52
- data/lib/katello/tire_bridge.rb +0 -20
@@ -7,7 +7,8 @@ module Katello
|
|
7
7
|
before_filter :find_optional_organization, :only => [:index, :create, :show]
|
8
8
|
before_filter :find_activation_key, :only => [:show, :update, :destroy, :available_releases, :copy, :product_content,
|
9
9
|
:available_host_collections, :add_host_collections, :remove_host_collections,
|
10
|
-
:content_override, :add_subscriptions, :remove_subscriptions
|
10
|
+
:content_override, :add_subscriptions, :remove_subscriptions,
|
11
|
+
:subscriptions]
|
11
12
|
before_filter :authorize
|
12
13
|
|
13
14
|
wrap_parameters :include => (ActivationKey.attribute_names + %w(host_collection_ids service_level auto_attach content_view_environment))
|
@@ -214,6 +215,18 @@ module Katello
|
|
214
215
|
activation_keys
|
215
216
|
end
|
216
217
|
|
218
|
+
api :GET, "/activation_keys/:id/subscriptions", N_("List an activation key's subscriptions")
|
219
|
+
param :activation_key_id, String, :desc => N_("Activation key ID"), :required => true
|
220
|
+
def subscriptions
|
221
|
+
subscriptions = @activation_key.get_key_pools.map { |sub| ActivationKeySubscriptionPresenter.new(sub) }
|
222
|
+
collection = subscriptions.map(&:subscription)
|
223
|
+
@collection = { :results => collection,
|
224
|
+
:total => collection.count,
|
225
|
+
:page => 1,
|
226
|
+
:per_page => collection.count,
|
227
|
+
:subtotal => collection.count }
|
228
|
+
end
|
229
|
+
|
217
230
|
private
|
218
231
|
|
219
232
|
def validate_content_overrides(content_params)
|
@@ -10,7 +10,6 @@ module Katello
|
|
10
10
|
# support for session (thread-local) variables must be the last filter in this class
|
11
11
|
include Foreman::ThreadSession::Cleaner
|
12
12
|
|
13
|
-
before_filter :load_search_service, :only => [:index]
|
14
13
|
skip_before_filter :setup_has_many_params # TODO: get this working #8862
|
15
14
|
|
16
15
|
resource_description do
|
@@ -39,40 +38,6 @@ module Katello
|
|
39
38
|
@resource_class ||= "Katello::#{resource_name.classify}".constantize
|
40
39
|
end
|
41
40
|
|
42
|
-
def item_search(item_class, param_hash, options)
|
43
|
-
fail "@search_service search not defined" if @search_service.nil?
|
44
|
-
if param_hash[:order]
|
45
|
-
(param_hash[:sort_by], param_hash[:sort_order]) = param_hash[:order].split(' ')
|
46
|
-
end
|
47
|
-
options[:sort_by] = param_hash[:sort_by] if param_hash[:sort_by]
|
48
|
-
options[:sort_order] = param_hash[:sort_order] if param_hash[:sort_order]
|
49
|
-
options[:full_result] = param_hash[:full_result] if param_hash[:full_result]
|
50
|
-
|
51
|
-
unless options[:full_result]
|
52
|
-
options[:per_page] = param_hash[:per_page] || ::Setting::General.entries_per_page
|
53
|
-
options[:page] = param_hash[:page] || 1
|
54
|
-
offset = (options[:page].to_i - 1) * options[:per_page].to_i
|
55
|
-
end
|
56
|
-
|
57
|
-
@search_service.model = item_class
|
58
|
-
|
59
|
-
if block_given?
|
60
|
-
options[:offset] = offset
|
61
|
-
@search_service.search_options = options
|
62
|
-
@search_service.query_string = param_hash[:search]
|
63
|
-
results, total_count = yield(@search_service)
|
64
|
-
else
|
65
|
-
results, total_count = @search_service.retrieve(param_hash[:search], offset, options)
|
66
|
-
end
|
67
|
-
{
|
68
|
-
:results => results,
|
69
|
-
:subtotal => total_count,
|
70
|
-
:total => @search_service.total_items,
|
71
|
-
:page => options[:page],
|
72
|
-
:per_page => options[:per_page]
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
41
|
def scoped_search(query, default_sort_by, default_sort_order, options = {})
|
77
42
|
resource = options[:resource_class] || resource_class
|
78
43
|
includes = options.fetch(:includes, [])
|
@@ -110,26 +75,6 @@ module Katello
|
|
110
75
|
}
|
111
76
|
end
|
112
77
|
|
113
|
-
def facet_search(item_class, term, options)
|
114
|
-
fail "@search_service search not defined" if @search_service.nil?
|
115
|
-
facet_name = 'facet_search'
|
116
|
-
|
117
|
-
@search_service.model = item_class
|
118
|
-
options[:per_page] = 1
|
119
|
-
options[:facets] = {facet_name => term}
|
120
|
-
options[:facet_filters] = {:and => options[:filters]}
|
121
|
-
|
122
|
-
@search_service.retrieve('', 0, options)
|
123
|
-
|
124
|
-
facets = @search_service.facets[facet_name]['terms']
|
125
|
-
results = facets.collect { |f| Katello::Glue::ElasticSearch::FacetItem.new(f) }
|
126
|
-
{
|
127
|
-
:results => results.sort_by { |f| f.term },
|
128
|
-
:subtotal => results.length,
|
129
|
-
:total => results.length
|
130
|
-
}
|
131
|
-
end
|
132
|
-
|
133
78
|
protected
|
134
79
|
|
135
80
|
def labelize_params(param_hash)
|
@@ -6,12 +6,14 @@ module Katello
|
|
6
6
|
api :GET, "/content_view_filters/:content_view_filter_id/rules", N_("List filter rules")
|
7
7
|
param :content_view_filter_id, :identifier, :desc => N_("filter identifier"), :required => true
|
8
8
|
def index
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
ids = ContentViewFilter.rule_ids_for(@filter)
|
10
|
+
results = ids.map { |id| ContentViewFilter.rule_class_for(@filter).find(id) }
|
11
|
+
collection = {
|
12
|
+
:results => results.uniq,
|
13
|
+
:subtotal => results.count,
|
14
|
+
:total => results.count
|
15
|
+
}
|
16
|
+
respond :collection => collection
|
15
17
|
end
|
16
18
|
|
17
19
|
api :POST, "/content_view_filters/:content_view_filter_id/rules",
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Katello
|
2
|
+
class Api::V2::ContentViewHistoriesController < Api::V2::ApiController
|
3
|
+
include Katello::Concerns::FilteredAutoCompleteSearch
|
4
|
+
|
5
|
+
before_filter :find_content_view
|
6
|
+
|
7
|
+
api :GET, "/content_views/:id/history", N_("Show a content view's history")
|
8
|
+
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
9
|
+
def index
|
10
|
+
respond_for_index :collection => scoped_search(index_relation.uniq, :katello_content_view_version_id, :asc, :resource_class => ContentViewHistory)
|
11
|
+
end
|
12
|
+
|
13
|
+
def index_relation
|
14
|
+
ContentViewHistory.joins(:content_view_version).where("#{ContentViewVersion.table_name}.content_view_id" => @view.id)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def find_content_view
|
20
|
+
@view = ContentView.find(params[:content_view_id]) if params[:content_view_id]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -8,7 +8,6 @@ module Katello
|
|
8
8
|
before_filter :find_environment, :only => [:promote, :index]
|
9
9
|
before_filter :authorize_promotable, :only => [:promote]
|
10
10
|
before_filter :authorize_destroy, :only => [:destroy]
|
11
|
-
before_filter :load_search_service, :only => [:incremental_update]
|
12
11
|
before_filter :find_version_environments, :only => [:incremental_update]
|
13
12
|
before_filter :find_puppet_module, :only => [:index]
|
14
13
|
|
@@ -6,8 +6,6 @@ module Katello
|
|
6
6
|
before_filter :find_content_view, :except => [:index, :create, :auto_complete_search]
|
7
7
|
before_filter :find_organization, :only => [:create]
|
8
8
|
before_filter :find_optional_organization, :only => [:index, :auto_complete_search]
|
9
|
-
before_filter :load_search_service, :only => [:history, :available_puppet_modules,
|
10
|
-
:available_puppet_module_names]
|
11
9
|
before_filter :find_environment, :only => [:index, :remove_from_environment]
|
12
10
|
|
13
11
|
wrap_parameters :include => (ContentView.attribute_names + %w(repository_ids component_ids))
|
@@ -119,17 +117,6 @@ module Katello
|
|
119
117
|
:collection => scoped_search(modules, 'name', 'ASC', :resource_class => PuppetModule, :group => :name)
|
120
118
|
end
|
121
119
|
|
122
|
-
api :GET, "/content_views/:id/history", N_("Show a content view's history")
|
123
|
-
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
124
|
-
def history
|
125
|
-
options = sort_params
|
126
|
-
options[:load_records?] = true
|
127
|
-
options[:filters] = [{:term => {:content_view_id => @view.id}}]
|
128
|
-
|
129
|
-
respond_for_index :template => '../content_view_histories/index',
|
130
|
-
:collection => item_search(ContentViewHistory, params, options)
|
131
|
-
end
|
132
|
-
|
133
120
|
api :DELETE, "/content_views/:id/environments/:environment_id", N_("Remove a content view from an environment")
|
134
121
|
param :id, :number, :desc => N_("content view numeric identifier"), :required => true
|
135
122
|
param :environment_id, :number, :desc => N_("environment numeric identifier"), :required => true
|
@@ -39,7 +39,6 @@ module Katello
|
|
39
39
|
before_filter :find_prior, :only => [:create]
|
40
40
|
before_filter :find_environment, :only => [:show, :update, :destroy, :repositories]
|
41
41
|
before_filter :find_content_view, :only => [:repositories]
|
42
|
-
before_filter :load_search_service, :only => [:index]
|
43
42
|
|
44
43
|
wrap_parameters :include => (KTEnvironment.attribute_names + %w(prior prior_id new_name))
|
45
44
|
|
@@ -7,7 +7,6 @@ module Katello
|
|
7
7
|
before_filter :find_system
|
8
8
|
before_filter :find_optional_organization, :only => [:index]
|
9
9
|
before_filter :find_organization, :only => [:create, :auto_complete_search]
|
10
|
-
before_filter :load_search_service, :only => [:index, :systems]
|
11
10
|
|
12
11
|
wrap_parameters :include => (HostCollection.attribute_names + %w(system_ids))
|
13
12
|
|
@@ -72,17 +71,6 @@ module Katello
|
|
72
71
|
respond
|
73
72
|
end
|
74
73
|
|
75
|
-
# TODO: switch to systems controller index w/ @adprice pull-request
|
76
|
-
api :GET, "/host_collections/:id/systems", N_("List content hosts in the host collection"), :deprecated => true
|
77
|
-
param :id, :identifier, :desc => N_("Id of the host collection"), :required => true
|
78
|
-
def systems
|
79
|
-
options = {
|
80
|
-
:filters => [{:term => {:host_collection_ids => @host_collection.id }}],
|
81
|
-
:load_records? => true
|
82
|
-
}
|
83
|
-
respond_for_index(:collection => item_search(System, params, options))
|
84
|
-
end
|
85
|
-
|
86
74
|
api :PUT, "/host_collections/:id/add_systems", N_("Add content host to the host collection"), :deprecated => true
|
87
75
|
param :id, :identifier, :desc => N_("Id of the host collection"), :required => true
|
88
76
|
param :system_ids, Array, :desc => N_("Array of content host ids")
|
@@ -92,7 +80,6 @@ module Katello
|
|
92
80
|
@editable_systems = @systems.editable
|
93
81
|
@host_collection.system_ids = (@host_collection.system_ids + @editable_systems.collect { |s| s.id }).uniq
|
94
82
|
@host_collection.save!
|
95
|
-
System.index.refresh
|
96
83
|
|
97
84
|
messages = format_bulk_action_messages(
|
98
85
|
:success => _("Successfully added %s Content Host(s)."),
|
@@ -114,7 +101,6 @@ module Katello
|
|
114
101
|
@editable_systems = @systems.editable
|
115
102
|
@host_collection.system_ids = (@host_collection.system_ids - @editable_systems.collect { |s| s.id }).uniq
|
116
103
|
@host_collection.save!
|
117
|
-
System.index.refresh
|
118
104
|
|
119
105
|
messages = format_bulk_action_messages(
|
120
106
|
:success => _("Successfully removed %s Content Host(s)."),
|
@@ -17,8 +17,6 @@ module Katello
|
|
17
17
|
end
|
18
18
|
|
19
19
|
api :GET, "/organizations/:organization_id/subscriptions", N_("List organization subscriptions")
|
20
|
-
api :GET, "/systems/:system_id/subscriptions", N_("List a content host's subscriptions"), :deprecated => true
|
21
|
-
api :GET, "/activation_keys/:activation_key_id/subscriptions", N_("List an activation key's subscriptions")
|
22
20
|
api :GET, "/subscriptions"
|
23
21
|
param_group :search, Api::V2::ApiController
|
24
22
|
param :organization_id, :number, :desc => N_("Organization ID"), :required => true
|
@@ -36,12 +34,8 @@ module Katello
|
|
36
34
|
return available_for_system if params[:available_for] == "content_host"
|
37
35
|
return available_for_activation_key if params[:available_for] == "activation_key"
|
38
36
|
collection = Pool.readable
|
39
|
-
collection = collection.where(:
|
37
|
+
collection = collection.where(:unmapped_guest => false)
|
40
38
|
collection = collection.get_for_organization(Organization.find(params[:organization_id])) if params[:organization_id]
|
41
|
-
if params[:system_id]
|
42
|
-
pool_ids = System.find_by_uuid(params[:system_id]).pools.map { |x| x['id'] }
|
43
|
-
collection = collection.where(:cp_id => pool_ids)
|
44
|
-
end
|
45
39
|
collection
|
46
40
|
end
|
47
41
|
|
@@ -66,7 +60,6 @@ module Katello
|
|
66
60
|
respond_for_index(:collection => scoped_search(subscriptions.uniq, :cp_id, :asc, :resource_class => Pool), :template => "index")
|
67
61
|
end
|
68
62
|
|
69
|
-
api :POST, "/subscriptions/:id", N_("Add a subscription to a resource")
|
70
63
|
api :POST, "/systems/:system_id/subscriptions", N_("Add a subscription to a content host"), :deprecated => true
|
71
64
|
api :POST, "/activation_keys/:activation_key_id/subscriptions", N_("Add a subscription to an activation key")
|
72
65
|
param :id, String, :desc => N_("Subscription Pool uuid"), :required => false
|
@@ -78,7 +71,7 @@ module Katello
|
|
78
71
|
param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => true
|
79
72
|
end
|
80
73
|
def create
|
81
|
-
object = @system || @activation_key
|
74
|
+
object = @system || @activation_key
|
82
75
|
|
83
76
|
if params[:subscriptions]
|
84
77
|
params[:subscriptions].each do |sub|
|
@@ -94,14 +87,11 @@ module Katello
|
|
94
87
|
index_system
|
95
88
|
elsif @activation_key
|
96
89
|
index_activation_key
|
97
|
-
else
|
98
|
-
index_organization
|
99
90
|
end
|
100
91
|
|
101
92
|
respond_for_index(:collection => subscriptions, :template => 'index')
|
102
93
|
end
|
103
94
|
|
104
|
-
api :DELETE, "/subscriptions/:id", N_("Unattach a subscription")
|
105
95
|
api :DELETE, "/systems/:system_id/subscriptions/:id", N_("Unattach a subscription"), :deprecated => true
|
106
96
|
api :DELETE, "/activation_keys/:activation_key_id/subscriptions/:id", N_("Unattach a subscription")
|
107
97
|
param :id, String, :desc => N_("Subscription ID"), :required => false
|
@@ -111,7 +101,7 @@ module Katello
|
|
111
101
|
param :id, String, :desc => N_("Subscription Pool uuid")
|
112
102
|
end
|
113
103
|
def destroy
|
114
|
-
object = @system || @activation_key
|
104
|
+
object = @system || @activation_key
|
115
105
|
|
116
106
|
if @system
|
117
107
|
params[:subscriptions].each do |subscription|
|
@@ -124,15 +114,7 @@ module Katello
|
|
124
114
|
@system.unsubscribe_all
|
125
115
|
end
|
126
116
|
|
127
|
-
|
128
|
-
index_system
|
129
|
-
elsif @activation_key
|
130
|
-
index_activation_key
|
131
|
-
else
|
132
|
-
index_organization
|
133
|
-
end
|
134
|
-
|
135
|
-
respond_for_index(:collection => subscriptions, :template => 'index')
|
117
|
+
respond_for_index(:collection => scoped_search(import_subscriptions.uniq, :cp_id, :asc, :resource_class => Pool), :template => "index")
|
136
118
|
end
|
137
119
|
|
138
120
|
api :POST, "/organizations/:organization_id/subscriptions/upload", N_("Upload a subscription manifest")
|
@@ -232,48 +214,29 @@ module Katello
|
|
232
214
|
%w(id desc)
|
233
215
|
end
|
234
216
|
|
217
|
+
def import_subscriptions
|
218
|
+
subscriptions = if @system
|
219
|
+
index_system
|
220
|
+
elsif @activation_key
|
221
|
+
index_activation_key
|
222
|
+
else
|
223
|
+
index_organization
|
224
|
+
end
|
225
|
+
cp_ids = subscriptions.collect { |x| x["id"] }
|
226
|
+
index_relation.where("cp_id not in (?)", cp_ids)
|
227
|
+
end
|
228
|
+
|
235
229
|
def index_system
|
236
|
-
|
237
|
-
|
238
|
-
subscriptions = {
|
239
|
-
:results => subs,
|
240
|
-
:subtotal => subs.count,
|
241
|
-
:total => subs.count,
|
242
|
-
:page => 1,
|
243
|
-
:per_page => subs.count
|
244
|
-
}
|
245
|
-
|
246
|
-
return subscriptions
|
230
|
+
Katello::Pool.import_all
|
231
|
+
@system.entitlements
|
247
232
|
end
|
248
233
|
|
249
234
|
def index_activation_key
|
250
|
-
@
|
251
|
-
subs = @activation_key.subscriptions
|
252
|
-
# TODO: pluck id and call elasticsearch?
|
253
|
-
subscriptions = {
|
254
|
-
:results => subs,
|
255
|
-
:subtotal => subs.count,
|
256
|
-
:total => subs.count,
|
257
|
-
:page => 1,
|
258
|
-
:per_page => subs.count
|
259
|
-
}
|
260
|
-
|
261
|
-
return subscriptions
|
235
|
+
@activation_key.subscriptions
|
262
236
|
end
|
263
237
|
|
264
238
|
def index_organization
|
265
|
-
|
266
|
-
filters << {:term => {:org => [@organization.label]}}
|
267
|
-
|
268
|
-
options = {
|
269
|
-
:filters => filters,
|
270
|
-
:load_records? => false,
|
271
|
-
:default_field => :name
|
272
|
-
}
|
273
|
-
|
274
|
-
subscriptions = item_search(Pool, params, options)
|
275
|
-
|
276
|
-
return subscriptions
|
239
|
+
@organization.subscriptions
|
277
240
|
end
|
278
241
|
|
279
242
|
def available_for_activation_key
|
@@ -5,7 +5,6 @@ module Katello
|
|
5
5
|
include Katello::Concerns::FilteredAutoCompleteSearch
|
6
6
|
before_filter :find_organization, :only => [:create, :index, :auto_complete_search]
|
7
7
|
before_filter :find_plan, :only => [:update, :show, :destroy, :add_products, :remove_products]
|
8
|
-
before_filter :load_search_service, :only => [:index]
|
9
8
|
|
10
9
|
def_param_group :sync_plan do
|
11
10
|
param :name, String, :desc => N_("sync plan name"), :required => true, :action_aware => true
|
@@ -5,7 +5,6 @@ module Katello
|
|
5
5
|
before_filter :find_host_collections, :only => [:bulk_add_host_collections, :bulk_remove_host_collections]
|
6
6
|
before_filter :find_environment, :only => [:environment_content_view]
|
7
7
|
before_filter :find_content_view, :only => [:environment_content_view]
|
8
|
-
before_filter :load_search_service
|
9
8
|
before_filter :find_editable_systems, :except => [:destroy_systems, :applicable_errata]
|
10
9
|
before_filter :find_deletable_systems, :only => [:destroy_systems]
|
11
10
|
before_filter :find_readable_systems, :only => [:applicable_errata, :available_incremental_updates]
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# rubocop:disable SymbolName
|
2
2
|
module Katello
|
3
3
|
class Api::V2::SystemsController < Api::V2::ApiController
|
4
|
+
include Katello::Concerns::FilteredAutoCompleteSearch
|
4
5
|
respond_to :json
|
5
6
|
|
6
7
|
wrap_parameters :include => (System.attribute_names + %w(type autoheal facts guest_ids host_collection_ids installed_products content_view environment))
|
@@ -12,7 +13,8 @@ module Katello
|
|
12
13
|
:pools, :enabled_repos, :releases,
|
13
14
|
:available_host_collections,
|
14
15
|
:refresh_subscriptions, :tasks, :content_override,
|
15
|
-
:product_content, :events
|
16
|
+
:product_content, :events, :subscriptions,
|
17
|
+
:add_subscriptions]
|
16
18
|
before_filter :find_environment, :only => [:index, :report]
|
17
19
|
before_filter :find_optional_organization, :only => [:create, :index, :report]
|
18
20
|
before_filter :find_host_collection, :only => [:index]
|
@@ -20,7 +22,6 @@ module Katello
|
|
20
22
|
|
21
23
|
before_filter :find_environment_and_content_view, :only => [:create]
|
22
24
|
before_filter :find_content_view, :only => [:create, :update]
|
23
|
-
before_filter :load_search_service, :only => [:index, :available_host_collections, :tasks]
|
24
25
|
before_filter :authorize_environment, :only => [:create]
|
25
26
|
|
26
27
|
def organization_id_keys
|
@@ -58,39 +59,27 @@ module Katello
|
|
58
59
|
param :erratum_restrict_non_installable, String, :desc => N_("Return only systems where the Erratum specified by erratum_id or errata_ids is unavailable to systems (default False)")
|
59
60
|
param_group :search, Api::V2::ApiController
|
60
61
|
def index
|
62
|
+
respond(:collection => scoped_search(index_relation.uniq, :name, :asc))
|
63
|
+
end
|
64
|
+
|
65
|
+
def index_relation
|
61
66
|
if params[:erratum_id] || params[:errata_ids]
|
62
67
|
errata_ids = params.fetch(:errata_ids, [])
|
63
|
-
|
64
|
-
systems = systems_by_errata(errata_ids, params[:erratum_restrict_installable],
|
68
|
+
collection = systems_by_errata(errata_ids, params[:erratum_restrict_installable],
|
65
69
|
params[:erratum_restrict_non_installable])
|
66
70
|
else
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
systems = systems.where(:content_view_id => params[:content_view_id]) if params[:content_view_id]
|
71
|
-
filters = [{:terms => {:uuid => systems.pluck("#{Katello::System.table_name}.uuid").compact}}]
|
72
|
-
environment_ids = params[:organization_id] ? Organization.find(params[:organization_id]).kt_environments.pluck(:id) : []
|
73
|
-
environment_ids = environment_ids.empty? ? params[:environment_id] : environment_ids & [params[:environment_id].to_i] if params[:environment_id]
|
74
|
-
unless environment_ids.empty?
|
75
|
-
filters << {:terms => {:environment_id => environment_ids}}
|
76
|
-
end
|
77
|
-
if params[:host_collection_id]
|
78
|
-
filters << {:terms => {:host_collection_ids => [params[:host_collection_id]] }}
|
71
|
+
collection = System.readable
|
79
72
|
end
|
80
|
-
if params[:activation_key_id]
|
81
|
-
filters << {:terms => {:activation_key_ids => [params[:activation_key_id]] }}
|
82
|
-
end
|
83
|
-
|
84
|
-
filters << {:terms => {:uuid => System.all_by_pool_uuid(params['pool_id']) }} if params['pool_id']
|
85
|
-
filters << {:terms => {:uuid => [params['uuid']] }} if params['uuid']
|
86
|
-
filters << {:term => {:name => params['name'] }} if params['name']
|
87
73
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
74
|
+
collection = collection.where(:content_view_id => params[:content_view_id]) if params[:content_view_id]
|
75
|
+
collection = collection.where(:id => Organization.find(params[:organization_id]).systems.map(&:id)) if params[:organization_id]
|
76
|
+
collection = collection.where(:environment_id => params[:environment_id]) if params[:environment_id]
|
77
|
+
collection = collection.where(:id => HostCollection.find(params[:host_collection_id]).systems) if params[:host_collection_id]
|
78
|
+
collection = collection.where(:id => Katello::ActivationKey.find(params[:activation_key_id]).systems) if params[:activation_key_id]
|
79
|
+
collection = collection.where(:id => Pool.find(params['pool_id']).systems.map(&:id)) if params['pool_id']
|
80
|
+
collection = collection.where(:uuid => params['uuid']) if params['uuid']
|
81
|
+
collection = collection.where(:name => params['name']) if params['name']
|
82
|
+
collection
|
94
83
|
end
|
95
84
|
|
96
85
|
api :POST, "/systems", N_("Register a content host"), :deprecated => true
|
@@ -155,17 +144,10 @@ module Katello
|
|
155
144
|
param :name, String, :desc => N_("host collection name to filter by")
|
156
145
|
def available_host_collections
|
157
146
|
system_org_id = @system.environment.organization_id
|
158
|
-
pluck_val = "#{Katello::HostCollection.table_name}.id"
|
159
|
-
filters = [:terms => {:id => HostCollection.readable.where(:organization_id => system_org_id).pluck(pluck_val) - @system.host_collection_ids}]
|
160
|
-
filters << {:term => {:name => params[:name]}} if params[:name]
|
161
147
|
|
162
|
-
|
163
|
-
:filters => filters,
|
164
|
-
:load_records? => true
|
165
|
-
}
|
148
|
+
collection = HostCollection.readable.where(:organization_id => system_org_id).where("id not in (?)", @system.host_collection_ids)
|
166
149
|
|
167
|
-
|
168
|
-
respond_for_index(:collection => host_collections)
|
150
|
+
respond_for_index(:collection => scoped_search(collection, :name, :desc, :resource_class => HostCollection))
|
169
151
|
end
|
170
152
|
|
171
153
|
api :DELETE, "/systems/:id", N_("Unregister a content host"), :deprecated => true
|
@@ -243,6 +225,37 @@ module Katello
|
|
243
225
|
respond_for_index :collection => response
|
244
226
|
end
|
245
227
|
|
228
|
+
api :GET, "/systems/:id/subscriptions", N_("List a content host's subscriptions"), :deprecated => true
|
229
|
+
param :id, String, :desc => N_("UUID of the content host"), :required => true
|
230
|
+
def subscriptions
|
231
|
+
subscriptions = @system.entitlements.map { |entitlement| SystemSubscriptionPresenter.new(entitlement) }
|
232
|
+
collection = subscriptions.map(&:subscription)
|
233
|
+
@collection = { :results => collection,
|
234
|
+
:total => collection.count,
|
235
|
+
:page => 1,
|
236
|
+
:per_page => collection.count,
|
237
|
+
:subtotal => collection.count }
|
238
|
+
end
|
239
|
+
|
240
|
+
api :POST, "/systems/:id/subscriptions", N_("Add a subscription to a content host"), :deprecated => true
|
241
|
+
param :subscription_id, String, :desc => N_("Subscription Pool uuid"), :required => false
|
242
|
+
param :id, String, :desc => N_("UUID of a content host"), :required => false
|
243
|
+
param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => false
|
244
|
+
param :subscriptions, Array, :desc => N_("Array of subscriptions to add"), :required => false do
|
245
|
+
param :id, String, :desc => N_("Subscription Pool uuid"), :required => true
|
246
|
+
param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => true
|
247
|
+
end
|
248
|
+
def add_subscriptions
|
249
|
+
if params[:subscriptions]
|
250
|
+
params[:subscriptions].each do |sub_params|
|
251
|
+
attach_subscription(@system, sub_params[:id], sub_params[:quantity])
|
252
|
+
end
|
253
|
+
elsif params[:subscription_id] && params.key?(:quantity)
|
254
|
+
attach_subscription(@system, params[:subscription_id], params[:quantity])
|
255
|
+
end
|
256
|
+
respond_for_show(:resource => @system)
|
257
|
+
end
|
258
|
+
|
246
259
|
api :GET, "/systems/:id/releases", N_("Show releases available for the content host"), :deprecated => true
|
247
260
|
param :id, String, :desc => N_("UUID of the content host"), :required => true
|
248
261
|
desc <<-DESC
|
@@ -293,6 +306,11 @@ module Katello
|
|
293
306
|
respond_for_index :collection => @events
|
294
307
|
end
|
295
308
|
|
309
|
+
def attach_subscription(system, pool_id, quantity)
|
310
|
+
subscription = Pool.find(pool_id)
|
311
|
+
async_task(::Actions::Katello::Subscription::Subscribe, system.id, subscription.cp_id, quantity)
|
312
|
+
end
|
313
|
+
|
296
314
|
private
|
297
315
|
|
298
316
|
def validate_content_overrides(content_params)
|