katello 3.0.0.rc4 → 3.0.0.rc5
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js +129 -47
- data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +2 -2
- data/app/controllers/katello/api/v2/activation_keys_controller.rb +9 -0
- data/app/controllers/katello/api/v2/api_controller.rb +13 -6
- data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +1 -1
- data/app/controllers/katello/api/v2/content_view_filters_controller.rb +1 -1
- data/app/controllers/katello/api/v2/environments_controller.rb +0 -2
- data/app/controllers/katello/api/v2/host_collections_controller.rb +4 -2
- data/app/controllers/katello/api/v2/repositories_controller.rb +10 -4
- data/app/controllers/katello/api/v2/repository_sets_controller.rb +3 -3
- data/app/controllers/katello/api/v2/systems_controller.rb +4 -1
- data/app/controllers/katello/application_controller.rb +1 -1
- data/app/controllers/katello/concerns/organizations_controller_extensions.rb +1 -1
- data/app/helpers/katello/hosts_and_hostgroups_helper.rb +125 -3
- data/app/lib/actions/candlepin/owner/refresh_subscriptions.rb +15 -0
- data/app/lib/actions/katello/host/register.rb +2 -2
- data/app/lib/actions/katello/product/create.rb +20 -15
- data/app/lib/actions/katello/repository/clone_yum_content.rb +4 -3
- data/app/lib/actions/katello/repository/index_errata.rb +0 -3
- data/app/lib/actions/pulp/repository/purge_empty_errata.rb +2 -8
- data/app/lib/actions/pulp/repository/purge_empty_package_groups.rb +3 -5
- data/app/lib/katello/concerns/renderer_extensions.rb +1 -2
- data/app/lib/katello/resources/candlepin.rb +0 -1
- data/app/models/katello/concerns/host_managed_extensions.rb +7 -2
- data/app/models/katello/concerns/hostgroup_extensions.rb +6 -2
- data/app/models/katello/concerns/redhat_extensions.rb +11 -5
- data/app/models/katello/content_view.rb +0 -35
- data/app/models/katello/erratum.rb +2 -1
- data/app/models/katello/host/content_facet.rb +2 -1
- data/app/models/katello/repository.rb +26 -0
- data/app/models/katello/rhsm_fact_parser.rb +6 -2
- data/app/models/setting/katello.rb +2 -2
- data/app/overrides/add_activation_keys_input.rb +10 -0
- data/app/views/katello/api/v2/environments/show.json.rabl +1 -0
- data/app/views/katello/api/v2/host_collections/{_host_collection.json.rabl → base.json.rabl} +0 -0
- data/app/views/katello/api/v2/host_collections/copy.json.rabl +1 -1
- data/app/views/katello/api/v2/host_collections/create.json.rabl +1 -1
- data/app/views/katello/api/v2/host_collections/index.json.rabl +5 -1
- data/app/views/katello/api/v2/host_collections/show.json.rabl +2 -1
- data/app/views/katello/api/v2/host_collections/update.json.rabl +1 -1
- data/app/views/katello/api/v2/subscriptions/show.json.rabl +5 -0
- data/app/views/overrides/activation_keys/_host_environment_select.html.erb +12 -14
- data/app/views/overrides/activation_keys/_host_media_type_select.html.erb +26 -0
- data/app/views/overrides/activation_keys/_host_synced_content_select.html.erb +24 -0
- data/config/routes/overrides.rb +2 -6
- data/db/migrate/20150930183738_migrate_content_hosts.rb +5 -0
- data/db/migrate/20160413230128_add_kickstart_repository_to_hosts_and_hostgroups.rb +9 -0
- data/db/migrate/20160426145517_move_host_description_to_host_comment.rb +27 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +3 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-base-subscriptions.controller.js +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/environments/views/environments.html +4 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/packages/details/package-details-repositories.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-details.controller.js +3 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/views/product-details.html +4 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/new/new-repository.controller.js +14 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/settings/setting.factory.js +15 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/settings/settings.module.js +12 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-associations-content-hosts.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/new/new-sync-plan.controller.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/sync-plans/sync-plans.controller.js +1 -0
- data/lib/katello/engine.rb +5 -1
- data/lib/katello/tasks/clean_backend_objects.rake +6 -0
- data/lib/katello/version.rb +1 -1
- metadata +10 -5
- data/app/controllers/katello/concerns/operatingsystems_controller_extensions.rb +0 -34
- data/lib/katello/permissions/operatingsystems_permissions.rb +0 -5
@@ -251,7 +251,7 @@ module Katello
|
|
251
251
|
def require_org
|
252
252
|
unless session && current_organization
|
253
253
|
execute_after_filters
|
254
|
-
|
254
|
+
redirect_to '/select_organization?toState=' + request.path
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
@@ -32,7 +32,7 @@ module Katello
|
|
32
32
|
if @count_nil_hosts > 0
|
33
33
|
redirect_to send("step2_#{taxonomy_single}_path", @taxonomy)
|
34
34
|
else
|
35
|
-
process_success(:object => @taxonomy)
|
35
|
+
process_success(:object => @taxonomy, :success_redirect => send("edit_#{taxonomy_single}_path", @taxonomy))
|
36
36
|
end
|
37
37
|
rescue ActiveRecord::RecordInvalid
|
38
38
|
process_error(:render => "taxonomies/new", :object => @taxonomy)
|
@@ -4,6 +4,10 @@ module Katello
|
|
4
4
|
"kt_activation_keys"
|
5
5
|
end
|
6
6
|
|
7
|
+
def using_hostgroups_page?
|
8
|
+
controller.controller_name == "hostgroups"
|
9
|
+
end
|
10
|
+
|
7
11
|
def blank_or_inherit_with_id(f, attr)
|
8
12
|
return true unless f.object.respond_to?(:parent_id) && f.object.parent_id
|
9
13
|
inherited_value = f.object.send(attr).try(:id) || ''
|
@@ -34,18 +38,57 @@ module Katello
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
41
|
+
def use_install_media(host, options = {})
|
42
|
+
return true if host && host.errors && host.errors.include?(:medium_id)
|
43
|
+
kickstart_repository_id(host, options).blank?
|
44
|
+
end
|
45
|
+
|
46
|
+
def host_hostgroup_kickstart_repository_id(host)
|
47
|
+
return if host.blank?
|
48
|
+
return host.kickstart_repository_id if host.is_a?(Hostgroup)
|
49
|
+
host.content_facet.kickstart_repository_id if host.try(:content_facet).present?
|
50
|
+
end
|
51
|
+
|
52
|
+
def kickstart_repository_id(host, options = {})
|
53
|
+
return if host.try(:medium_id).present?
|
54
|
+
|
55
|
+
host_ks_repo_id = host_hostgroup_kickstart_repository_id(host)
|
56
|
+
ks_repo_options = kickstart_repository_options(host, options)
|
57
|
+
# if the kickstart repo id is set in the selected_hostgroup use that
|
58
|
+
selected_host_group = options.fetch(:selected_host_group, nil)
|
59
|
+
if selected_host_group.try(:kickstart_repository_id).present?
|
60
|
+
ks_repo_ids = ks_repo_options.map(&:id)
|
61
|
+
|
62
|
+
if ks_repo_ids.include?(selected_host_group.kickstart_repository_id)
|
63
|
+
return selected_host_group.kickstart_repository_id
|
64
|
+
elsif host_ks_repo_id && ks_repo_ids.include?(host_ks_repo_id)
|
65
|
+
return host_ks_repo_id
|
66
|
+
else
|
67
|
+
return ks_repo_options.first.try(:id)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# if the kickstart repo id is set in the host use that
|
72
|
+
return host_ks_repo_id if host_ks_repo_id.present?
|
73
|
+
|
74
|
+
if selected_host_group.try(:medium_id).blank? && host.try(:medium_id).blank?
|
75
|
+
ks_repo_options.first.try(:id)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
37
79
|
def fetch_lifecycle_environment(host, options = {})
|
38
80
|
selected_host_group = options.fetch(:selected_host_group, nil)
|
81
|
+
return lifecycle_environment(selected_host_group) if selected_host_group.present?
|
39
82
|
selected_env = lifecycle_environment(host)
|
40
83
|
return selected_env if selected_env.present?
|
41
|
-
lifecycle_environment(selected_host_group) if selected_host_group.present?
|
42
84
|
end
|
43
85
|
|
44
86
|
def fetch_content_view(host, options = {})
|
45
87
|
selected_host_group = options.fetch(:selected_host_group, nil)
|
88
|
+
return content_view(selected_host_group) if selected_host_group.present?
|
89
|
+
|
46
90
|
selected_content_view = content_view(host)
|
47
|
-
|
48
|
-
content_view(selected_host_group) if selected_host_group.present?
|
91
|
+
selected_content_view if selected_content_view.present?
|
49
92
|
end
|
50
93
|
|
51
94
|
def lifecycle_environment_options(host, options = {})
|
@@ -98,5 +141,84 @@ module Katello
|
|
98
141
|
view_options.insert(0, include_blank) if include_blank
|
99
142
|
view_options.html_safe
|
100
143
|
end
|
144
|
+
|
145
|
+
def view_to_options(view_options, selected_val, include_blank = false)
|
146
|
+
if include_blank == true #check for true specifically
|
147
|
+
include_blank = '<option></option>'
|
148
|
+
end
|
149
|
+
views = view_options.map do |view|
|
150
|
+
selected = selected_val == view.id ? 'selected' : ''
|
151
|
+
%(<option #{selected} value="#{view.id}">#{h(view.name)}</option>)
|
152
|
+
end
|
153
|
+
views = views.join
|
154
|
+
views.insert(0, include_blank) if include_blank
|
155
|
+
views.html_safe
|
156
|
+
end
|
157
|
+
|
158
|
+
def kickstart_repository_options(param_host, options = {})
|
159
|
+
# this method gets called in 2 places
|
160
|
+
# 1) On initial page load or a host group selection. At that point the host object is already
|
161
|
+
# => populated and we should just use that.
|
162
|
+
# 2) Once you chose a diff os/content source/arch/lifecycle env/cv via the os_selected method.
|
163
|
+
# In case 2 we want it to play by the rules of "one of these params" and
|
164
|
+
# in case 1 we want it to behave as if everything is already set right and
|
165
|
+
# We need to figure out the available KS repos in both cases.
|
166
|
+
if param_host.present?
|
167
|
+
# case 1
|
168
|
+
selected_host_group = options.fetch(:selected_host_group, nil)
|
169
|
+
host = selected_host_group.present? ? selected_host_group : param_host
|
170
|
+
return [] unless host.operatingsystem.is_a?(Redhat)
|
171
|
+
|
172
|
+
new_host = ::Host.new
|
173
|
+
# there is foreman bug right now that prevents
|
174
|
+
# os and arch to get updated properly,
|
175
|
+
# http://projects.theforeman.org/issues/14737
|
176
|
+
# so we are going to hard code it to use what
|
177
|
+
# is in the param host for now.
|
178
|
+
new_host.operatingsystem = param_host.operatingsystem.present? ? param_host.operatingsystem : host.operatingsystem
|
179
|
+
new_host.architecture = param_host.architecture.present? ? param_host.architecture : host.architecture
|
180
|
+
|
181
|
+
if (host.is_a? Hostgroup)
|
182
|
+
new_host.content_facet = Host::ContentFacet.new(:lifecycle_environment_id => host.lifecycle_environment_id,
|
183
|
+
:content_view_id => host.content_view_id)
|
184
|
+
elsif host.content_facet.present?
|
185
|
+
new_host.content_facet = Host::ContentFacet.new(:lifecycle_environment_id => host.content_facet.lifecycle_environment_id,
|
186
|
+
:content_view_id => host.content_facet.content_view_id)
|
187
|
+
end
|
188
|
+
|
189
|
+
new_host.content_source = host.content_source
|
190
|
+
new_host.operatingsystem.kickstart_repos(new_host).map { |repo| OpenStruct.new(repo) }
|
191
|
+
else
|
192
|
+
# case 2
|
193
|
+
os_updated_kickstart_options(host)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def os_updated_kickstart_options(host)
|
198
|
+
# this method gets called in 1 place Once you chose a diff os/content source/arch/lifecycle env/cv
|
199
|
+
# via the os_selected method.
|
200
|
+
# In this case we want it play by the rules of "one of these params" and
|
201
|
+
# need to figure out the available KS repos for the given params.
|
202
|
+
os_selection_params = ["operatingsystem_id", 'content_view_id', 'lifecycle_environment_id',
|
203
|
+
'content_source_id', 'architecture_id']
|
204
|
+
view_options = []
|
205
|
+
if os_selection_params.all? { |key| params[key].present? }
|
206
|
+
if host.nil?
|
207
|
+
host = ::Host.new
|
208
|
+
end
|
209
|
+
host.operatingsystem = Operatingsystem.find(params[:operatingsystem_id])
|
210
|
+
host.architecture = Architecture.find(params[:architecture_id])
|
211
|
+
|
212
|
+
lifecycle_env = Katello::KTEnvironment.find(params[:lifecycle_environment_id])
|
213
|
+
content_view = Katello::ContentView.find(params[:content_view_id])
|
214
|
+
host.content_facet = Host::ContentFacet.new(:lifecycle_environment_id => lifecycle_env.id,
|
215
|
+
:content_view_id => content_view.id)
|
216
|
+
host.content_source = SmartProxy.find(params[:content_source_id])
|
217
|
+
if host.operatingsystem.is_a?(Redhat)
|
218
|
+
view_options = host.operatingsystem.kickstart_repos(host).map { |repo| OpenStruct.new(repo) }
|
219
|
+
end
|
220
|
+
end
|
221
|
+
view_options
|
222
|
+
end
|
101
223
|
end
|
102
224
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Actions
|
2
|
+
module Candlepin
|
3
|
+
module Owner
|
4
|
+
class RefreshSubscriptions < Candlepin::AbstractAsyncTask
|
5
|
+
input_format do
|
6
|
+
param :label
|
7
|
+
end
|
8
|
+
|
9
|
+
def invoke_external_task
|
10
|
+
::Katello::Resources::Candlepin::Subscription.refresh_for_owner(input[:label])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -7,6 +7,7 @@ module Actions
|
|
7
7
|
def plan(host, system, consumer_params, content_view_environment, activation_keys = [])
|
8
8
|
sequence do
|
9
9
|
unless host.new_record?
|
10
|
+
host.save!
|
10
11
|
plan_action(Katello::Host::Unregister, host)
|
11
12
|
host.reload
|
12
13
|
end
|
@@ -66,8 +67,7 @@ module Actions
|
|
66
67
|
|
67
68
|
if smart_proxy
|
68
69
|
smart_proxy.content_host = system.content_host
|
69
|
-
|
70
|
-
smart_proxy.organizations << org unless smart_proxy.organizations.include?(org)
|
70
|
+
smart_proxy.organizations << system.organization unless smart_proxy.organizations.include?(system.organization)
|
71
71
|
smart_proxy.save!
|
72
72
|
end
|
73
73
|
end
|
@@ -3,26 +3,31 @@ module Actions
|
|
3
3
|
module Product
|
4
4
|
class Create < Actions::EntryAction
|
5
5
|
def plan(product, organization)
|
6
|
-
|
7
|
-
|
6
|
+
sequence do
|
7
|
+
product.provider = organization.anonymous_provider
|
8
|
+
product.organization = organization
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
cp_create = plan_action(::Actions::Candlepin::Product::Create,
|
11
|
+
:name => product.name,
|
12
|
+
:multiplier => 1,
|
13
|
+
:attributes => [{:name => "arch", :value => "ALL"}])
|
13
14
|
|
14
|
-
|
15
|
+
cp_id = cp_create.output[:response][:id]
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
subscription_id = sub_create.output[:response][:id]
|
17
|
+
sub_create = plan_action(::Actions::Candlepin::Product::CreateUnlimitedSubscription,
|
18
|
+
:owner_key => organization.label,
|
19
|
+
:product_id => cp_id)
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
subscription_id = sub_create.output[:response][:id]
|
22
|
+
|
23
|
+
plan_action(::Actions::Candlepin::Owner::RefreshSubscriptions,
|
24
|
+
:label => organization.label)
|
25
|
+
product.save!
|
26
|
+
action_subject product, :cp_id => cp_id
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
plan_self
|
29
|
+
plan_action Katello::Product::ReindexSubscriptions, product, subscription_id
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
def finalize
|
@@ -38,15 +38,16 @@ module Actions
|
|
38
38
|
plan_copy(Pulp::Repository::CopyYumMetadataFile, source_repo, target_repo)
|
39
39
|
plan_copy(Pulp::Repository::CopyDistribution, source_repo, target_repo)
|
40
40
|
|
41
|
+
plan_action(Katello::Repository::IndexContent, id: target_repo.id) if index_content
|
42
|
+
|
41
43
|
if purge_empty_units
|
42
|
-
plan_action(Katello::Repository::IndexErrata, target_repo)
|
43
44
|
plan_action(Pulp::Repository::PurgeEmptyErrata, :pulp_id => target_repo.pulp_id)
|
44
|
-
plan_action(Katello::Repository::IndexPackageGroups, target_repo)
|
45
45
|
plan_action(Pulp::Repository::PurgeEmptyPackageGroups, :pulp_id => target_repo.pulp_id)
|
46
|
+
plan_action(Katello::Repository::IndexErrata, target_repo)
|
47
|
+
plan_action(Katello::Repository::IndexPackageGroups, target_repo)
|
46
48
|
end
|
47
49
|
|
48
50
|
plan_action(Katello::Repository::MetadataGenerate, target_repo, filters.empty? ? source_repo : nil) if generate_metadata
|
49
|
-
plan_action(Katello::Repository::IndexContent, id: target_repo.id) if index_content
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -8,16 +8,10 @@ module Actions
|
|
8
8
|
|
9
9
|
def invoke_external_task
|
10
10
|
repo = ::Katello::Repository.where(:pulp_id => input[:pulp_id]).first
|
11
|
+
errata_to_delete = repo.empty_errata
|
11
12
|
|
12
|
-
package_lists = repo.package_lists_for_publish
|
13
|
-
filenames = package_lists[:filenames]
|
14
|
-
|
15
|
-
errata_to_delete = repo.errata.collect do |erratum|
|
16
|
-
erratum.errata_id if filenames.intersection(erratum.packages.pluck(:filename)).empty?
|
17
|
-
end
|
18
|
-
errata_to_delete.compact!
|
19
13
|
repo.unassociate_by_filter(::Katello::ContentViewErratumFilter::CONTENT_TYPE,
|
20
|
-
"id" => { "$in" => errata_to_delete })
|
14
|
+
"id" => { "$in" => errata_to_delete.map(&:errata_id) })
|
21
15
|
end
|
22
16
|
end
|
23
17
|
end
|
@@ -8,13 +8,11 @@ module Actions
|
|
8
8
|
|
9
9
|
def invoke_external_task
|
10
10
|
repo = ::Katello::Repository.where(:pulp_id => input[:pulp_id]).first
|
11
|
-
|
12
|
-
package_lists = repo.package_lists_for_publish
|
13
|
-
rpm_names = package_lists[:names]
|
11
|
+
rpm_names = repo.rpms.pluck(:name).uniq
|
14
12
|
|
15
13
|
# Remove all package groups with no packages
|
16
|
-
package_groups_to_delete = repo.package_groups.
|
17
|
-
|
14
|
+
package_groups_to_delete = repo.package_groups.select do |group|
|
15
|
+
(rpm_names & group.package_names).empty?
|
18
16
|
end
|
19
17
|
criteria = {:association => {"unit_id" => {"$in" => package_groups_to_delete.compact}}}
|
20
18
|
|
@@ -11,8 +11,7 @@ module Katello
|
|
11
11
|
kickstart_attributes_without_katello
|
12
12
|
|
13
13
|
if @host.content_facet.try(:content_view) && @host.operatingsystem.is_a?(Redhat) &&
|
14
|
-
|
15
|
-
|
14
|
+
@host.operatingsystem.kickstart_repos(@host).first.present?
|
16
15
|
@mediapath ||= @host.operatingsystem.mediumpath(@host)
|
17
16
|
end
|
18
17
|
end
|
@@ -569,7 +569,6 @@ module Katello
|
|
569
569
|
|
570
570
|
def create_for_owner(owner_key, attrs)
|
571
571
|
subscription = self.post("/candlepin/owners/#{owner_key}/subscriptions", attrs.to_json, self.default_headers).body
|
572
|
-
self.put("/candlepin/owners/#{owner_key}/subscriptions", {}.to_json, self.default_headers).body
|
573
572
|
subscription
|
574
573
|
end
|
575
574
|
|
@@ -10,7 +10,6 @@ module Katello
|
|
10
10
|
alias_method_chain :set_hostgroup_defaults, :katello_attributes
|
11
11
|
alias_method_chain :info, :katello
|
12
12
|
alias_method_chain :smart_proxy_ids, :katello
|
13
|
-
|
14
13
|
has_one :content_host, :class_name => "Katello::System", :foreign_key => :host_id,
|
15
14
|
:dependent => :destroy, :inverse_of => :foreman_host
|
16
15
|
belongs_to :content_source, :class_name => "::SmartProxy", :foreign_key => :content_source_id, :inverse_of => :hosts
|
@@ -33,7 +32,7 @@ module Katello
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def validate_media_with_capsule?
|
36
|
-
content_source_id.blank? && validate_media_without_capsule?
|
35
|
+
(content_source_id.blank? || (content_facet && content_facet.kickstart_repository.blank?)) && validate_media_without_capsule?
|
37
36
|
end
|
38
37
|
|
39
38
|
def rhsm_organization_label
|
@@ -56,6 +55,9 @@ module Katello
|
|
56
55
|
info['parameters']['kt_cv'] = self.content_view.try(:label) #deprecated
|
57
56
|
info['parameters']['lifecycle_environment'] = self.lifecycle_environment.try(:label)
|
58
57
|
info['parameters']['content_view'] = self.content_view.try(:label)
|
58
|
+
if self.content_facet.present?
|
59
|
+
info['parameters']['kickstart_repository'] = self.content_facet.kickstart_repository.try(:label)
|
60
|
+
end
|
59
61
|
info
|
60
62
|
end
|
61
63
|
|
@@ -78,6 +80,9 @@ module Katello
|
|
78
80
|
|
79
81
|
def set_hostgroup_defaults_with_katello_attributes
|
80
82
|
if hostgroup.present?
|
83
|
+
if content_facet.present?
|
84
|
+
self.content_facet.kickstart_repository_id = hostgroup.inherited_kickstart_repository_id
|
85
|
+
end
|
81
86
|
assign_hostgroup_attributes(%w(content_source_id content_view_id lifecycle_environment_id))
|
82
87
|
end
|
83
88
|
set_hostgroup_defaults_without_katello_attributes
|
@@ -5,14 +5,14 @@ module Katello
|
|
5
5
|
|
6
6
|
included do
|
7
7
|
before_save :add_organization_for_environment
|
8
|
-
|
8
|
+
belongs_to :kickstart_repository, :class_name => "::Katello::Repository", :foreign_key => :kickstart_repository_id
|
9
9
|
belongs_to :content_source, :class_name => "::SmartProxy", :foreign_key => :content_source_id, :inverse_of => :hostgroups
|
10
10
|
belongs_to :content_view, :inverse_of => :hostgroups, :class_name => "::Katello::ContentView"
|
11
11
|
belongs_to :lifecycle_environment, :inverse_of => :hostgroups, :class_name => "::Katello::KTEnvironment"
|
12
12
|
|
13
13
|
validates_with Katello::Validators::ContentViewEnvironmentValidator
|
14
14
|
|
15
|
-
attr_accessible :content_view_id, :lifecycle_environment_id, :content_source_id
|
15
|
+
attr_accessible :content_view_id, :lifecycle_environment_id, :content_source_id, :kickstart_repository_id
|
16
16
|
|
17
17
|
scoped_search :in => :content_source, :on => :name, :complete_value => true, :rename => :content_source
|
18
18
|
scoped_search :in => :content_view, :on => :name, :complete_value => true, :rename => :content_view
|
@@ -47,6 +47,10 @@ module Katello
|
|
47
47
|
inherited_ancestry_attribute(:lifecycle_environment_id)
|
48
48
|
end
|
49
49
|
|
50
|
+
def inherited_kickstart_repository_id
|
51
|
+
inherited_ancestry_attribute(:kickstart_repository_id)
|
52
|
+
end
|
53
|
+
|
50
54
|
def rhsm_organization_label
|
51
55
|
#used for rhsm registration snippet, since hostgroup can belong to muliple organizations, use lifecycle environment or cv
|
52
56
|
(self.lifecycle_environment || self.content_view).try(:organization).try(:label)
|
@@ -44,16 +44,22 @@ module Katello
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def medium_uri_with_content_uri(host, url = nil)
|
47
|
-
if host.try(:content_source) && (
|
48
|
-
URI.parse(
|
47
|
+
if host.try(:content_source) && host.content_facet.try(:kickstart_repository).present?
|
48
|
+
return URI.parse(host.content_facet.kickstart_repository.full_path(host.content_source))
|
49
49
|
else
|
50
50
|
medium_uri_without_content_uri(host, url)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
54
|
+
def kickstart_repos(host)
|
55
|
+
distros = distribution_repositories(host)
|
56
|
+
if distros && host.content_source
|
57
|
+
distros.map do |distro|
|
58
|
+
{:id => distro.id, :name => distro.name, :path => distro.full_path(host.content_source)}
|
59
|
+
end
|
60
|
+
else
|
61
|
+
[]
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
def distribution_repositories(host)
|
@@ -454,7 +454,6 @@ module Katello
|
|
454
454
|
fail _("User must be logged in.") if ::User.current.nil?
|
455
455
|
fail _("Cannot publish default content view") if default?
|
456
456
|
check_composite_action_allowed!(organization.library)
|
457
|
-
check_distribution_conflicts!
|
458
457
|
true
|
459
458
|
end
|
460
459
|
|
@@ -511,40 +510,6 @@ module Katello
|
|
511
510
|
return true
|
512
511
|
end
|
513
512
|
|
514
|
-
def check_distribution_conflicts!
|
515
|
-
duplicates = duplicate_distributions
|
516
|
-
if duplicates.any?
|
517
|
-
failed_distribution = duplicates.first
|
518
|
-
else
|
519
|
-
conflicts = distribution_conflicts
|
520
|
-
if conflicts.any?
|
521
|
-
failed_distribution = conflicts.first
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
if failed_distribution
|
526
|
-
failed_repos = [duplicates, conflicts].flat_map { |i| i }
|
527
|
-
fail _("Content Views cannot contain multiple Kickstart trees with the same version and architecture. " \
|
528
|
-
"Multiple Kickstart trees of %{release} %{arch} were found in Repositories: %{repos}") %
|
529
|
-
{:release => failed_distribution.distribution_version, :arch => failed_distribution.distribution_arch,
|
530
|
-
:repos => failed_repos.compact.map { |repo| repo.name if repo.name }}
|
531
|
-
end
|
532
|
-
end
|
533
|
-
|
534
|
-
def distribution_conflicts
|
535
|
-
#find distributions, where there are two in the content view with the same version and Arch
|
536
|
-
repos = self.repositories_to_publish.where("distribution_arch IS NOT NULL OR distribution_version IS NOT NULL")
|
537
|
-
repos = repos.select { |repo| repo.distribution_bootable? }
|
538
|
-
repos.group_by { |repo| [repo.distribution_arch, repo.distribution_version] }
|
539
|
-
.select { |_, value| value.length > 1 }.values.flatten
|
540
|
-
end
|
541
|
-
|
542
|
-
def duplicate_distributions
|
543
|
-
#find distributions where two repositories in the content view share them
|
544
|
-
repos = self.repositories_to_publish.where("distribution_uuid IS NOT NULL")
|
545
|
-
repos.group_by { |i| i.distribution_uuid }.select { |_, v| v.length > 1 }.values.flatten
|
546
|
-
end
|
547
|
-
|
548
513
|
protected
|
549
514
|
|
550
515
|
def remove_repository(repository)
|