katello 3.2.0.rc1.1 → 3.2.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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js +1 -1
  3. data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +5 -0
  4. data/app/controllers/katello/api/v2/organizations_controller.rb +1 -1
  5. data/app/controllers/katello/api/v2/repositories_controller.rb +1 -1
  6. data/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb +1 -1
  7. data/app/controllers/katello/products_controller.rb +1 -1
  8. data/app/lib/actions/katello/capsule_content/create_repos.rb +1 -1
  9. data/app/lib/actions/katello/capsule_content/sync.rb +3 -22
  10. data/app/lib/actions/katello/repository/clone_to_environment.rb +6 -0
  11. data/app/lib/actions/katello/repository/create.rb +3 -1
  12. data/app/lib/actions/katello/repository/destroy.rb +0 -2
  13. data/app/lib/actions/katello/repository/sync.rb +0 -1
  14. data/app/models/katello/activation_key.rb +2 -1
  15. data/app/models/katello/concerns/content_facet_host_extensions.rb +6 -4
  16. data/app/models/katello/concerns/host_managed_extensions.rb +3 -3
  17. data/app/models/katello/concerns/redhat_extensions.rb +3 -1
  18. data/app/models/katello/concerns/subscription_facet_host_extensions.rb +3 -3
  19. data/app/models/katello/glue/pulp/repo.rb +17 -0
  20. data/app/models/katello/ping.rb +13 -4
  21. data/app/models/katello/product.rb +9 -1
  22. data/app/models/katello/repository.rb +7 -0
  23. data/app/models/katello/subscription.rb +5 -0
  24. data/app/views/dashboard/_content_views_widget.html.erb +3 -3
  25. data/app/views/dashboard/_errata_widget.html.erb +2 -2
  26. data/app/views/dashboard/_host_collection_widget.html.erb +3 -3
  27. data/app/views/dashboard/_subscription_status_widget.html.erb +32 -27
  28. data/app/views/dashboard/_subscription_widget.html.erb +57 -54
  29. data/app/views/dashboard/_sync_widget.html.erb +3 -3
  30. data/app/views/foreman/unattended/finish-katello.erb +7 -19
  31. data/app/views/foreman/unattended/kickstart-katello.erb +7 -20
  32. data/app/views/foreman/unattended/userdata-katello.erb +14 -21
  33. data/app/views/overrides/activation_keys/_host_environment_select.html.erb +2 -2
  34. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-errata.html +1 -1
  35. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-docker-repositories.html +1 -1
  36. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-file-repositories.html +1 -1
  37. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-ostree-repositories.html +1 -1
  38. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-repositories.html +1 -1
  39. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repositories/details/repository-details-info.controller.js +3 -2
  40. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-products.controller.js +3 -1
  41. data/lib/katello/engine.rb +0 -1
  42. data/lib/katello/version.rb +1 -1
  43. metadata +3 -7
  44. data/app/lib/actions/katello/repository/destroy_medium.rb +0 -12
  45. data/app/lib/actions/katello/repository/update_media.rb +0 -17
  46. data/app/models/katello/concerns/medium_extensions.rb +0 -79
  47. data/db/seeds.d/109-atomic_os.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8dee65c514ba950ad42d12bf0cd772721e54af2
4
- data.tar.gz: 8daaf70daafc83d71199964d9aeb2fa654babb5d
3
+ metadata.gz: 1746a52c274c0de6f5d7d9bfe445688ac837f11e
4
+ data.tar.gz: 99ca72367e3c93ec650f2269d7438fc050aec55c
5
5
  SHA512:
6
- metadata.gz: 527fc3d079158603bd6c7e79f5fabe589d18f00563268d2f0c822629862c0e9572d78063cec75a9dcf493a03e29d7aafceebc80d37e950c6694dd8f2cd9209e2
7
- data.tar.gz: 1b57947ddf8cdb1b579df28450018b9fba84baa137dfa1142f28892f771127c1e2758ae4e8320dcf2baac8ee66a763685f4890f15726019c69d93481617a8cd7
6
+ metadata.gz: 6dd2a6dcf3602edad6b41282a2d2e5238648f718124cfc04aa8d0ca2c7258d7142c35173e85f4e048656ef7db0ce763705eb4d189f0b2b0d9dda5b12601db98e
7
+ data.tar.gz: b64938cda76dc55a07e01453d4c99139e79e4e33479298656efb8269fed805d76b8e07bc8e8270a89536728323e7f354f1ec2ee5ca61a220ccc6726930634b77
@@ -257,7 +257,7 @@ function os_selected(element){
257
257
  'lifecycle_environment_id', 'content_source_id', 'architecture_id', 'hostgroup_id',
258
258
  'medium_id', 'kickstart_repository_id']);
259
259
  var url = $(element).attr('data-url');
260
- foreman.tools.showSpinner();
260
+ tfm.tools.showSpinner();
261
261
  $.ajax({
262
262
  data: attrs,
263
263
  type:'post',
@@ -12,6 +12,11 @@ module Katello
12
12
 
13
13
  before_action :validate_content_action, :only => [:install_content, :update_content, :remove_content]
14
14
 
15
+ resource_description do
16
+ api_version 'v2'
17
+ api_base_url "/api"
18
+ end
19
+
15
20
  PARAM_ACTIONS = {
16
21
  :install_content => {
17
22
  :package => :install_packages,
@@ -22,7 +22,7 @@ module Katello
22
22
  param :user_ids, Array, N_("User IDs"), :required => false
23
23
  param :smart_proxy_ids, Array, N_("Smart proxy IDs"), :required => false
24
24
  param :compute_resource_ids, Array, N_("Compute resource IDs"), :required => false
25
- param :media_ids, Array, N_("Media IDs"), :required => false
25
+ param :medium_ids, Array, N_("Medium IDs"), :required => false
26
26
  param :config_template_ids, Array, N_("Provisioning template IDs"), :required => false # FIXME: deprecated
27
27
  param :ptable_ids, Array, N_("Partition template IDs"), :required => false
28
28
  param :provisioning_template_ids, Array, N_("Provisioning template IDs"), :required => false
@@ -287,7 +287,7 @@ module Katello
287
287
 
288
288
  if !filepaths.blank?
289
289
  sync_task(::Actions::Katello::Repository::UploadFiles, @repository, filepaths)
290
- render :json => {:status => "success"}
290
+ render :json => {:status => "success", :filenames => filepaths.map { |item| item[:filename] }}
291
291
  else
292
292
  fail HttpErrors::BadRequest, _("No file uploaded")
293
293
  end
@@ -39,7 +39,7 @@ module Katello
39
39
  param :id, :identifier, :required => true
40
40
  param_group :hostgroup
41
41
  def update
42
- process_response @hostgroup.update_attributes(params[:hostgroup])
42
+ process_response @hostgroup.update_attributes(hostgroup_params)
43
43
  end
44
44
 
45
45
  api :GET, "/hostgroups/:id", N_("Show a host group")
@@ -72,7 +72,7 @@ module Katello
72
72
  repos.select do |repo|
73
73
  if repo[:path].include?('kickstart')
74
74
  variants = ['Server', 'Client', 'ComputeNode', 'Workstation']
75
- has_variant = variants.any? { |v| repo[:substitutions][:releasever].include?(v) }
75
+ has_variant = variants.any? { |v| repo[:substitutions][:releasever].try(:include?, v) }
76
76
  has_variant ? repo[:enabled] : true
77
77
  else
78
78
  true
@@ -24,7 +24,7 @@ module Actions
24
24
  content_type: repository.content_type,
25
25
  pulp_id: repository.pulp_id,
26
26
  name: repository.name,
27
- feed: repository.docker? ? repository.docker_feed_url(true) : repository.full_path,
27
+ feed: repository.docker? ? repository.docker_feed_url(true) : repository.full_path(nil, true),
28
28
  ssl_ca_cert: ::Cert::Certs.ca_cert,
29
29
  ssl_client_cert: ueber_cert[:cert],
30
30
  ssl_client_key: ueber_cert[:key],
@@ -74,29 +74,10 @@ module Actions
74
74
  end
75
75
 
76
76
  def repos_needing_updates(capsule_content, environment, content_view)
77
- need_importer_update = repos_needing_importer_updates(capsule_content, environment, content_view)
78
- need_distributor_update = repos_needing_distributor_updates(capsule_content, environment, content_view)
79
- (need_distributor_update + need_importer_update).uniq
80
- end
81
-
82
- def repos_needing_distributor_updates(capsule_content, environment, content_view)
83
77
  repos = capsule_content.repos_available_to_capsule(environment, content_view)
84
- repos.select do |repo|
85
- repo_details = capsule_content.pulp_repo_facts(repo.pulp_id)
86
- next unless repo_details
87
- capsule_distributors = repo_details["distributors"]
88
- !repo.distributors_match?(capsule_distributors, capsule_content.capsule)
89
- end
90
- end
91
-
92
- def repos_needing_importer_updates(capsule, environment, content_view)
93
- repos = capsule.repos_available_to_capsule(environment, content_view)
94
- repos.select do |repo|
95
- repo_details = capsule.pulp_repo_facts(repo.pulp_id)
96
- next unless repo_details
97
- capsule_importer = repo_details["importers"][0]
98
- !repo.importer_matches?(capsule_importer)
99
- end
78
+ need_importer_update = ::Katello::Repository.needs_importer_updates(repos, capsule_content)
79
+ need_distributor_update = ::Katello::Repository.needs_distributor_updates(repos, capsule_content)
80
+ (need_distributor_update + need_importer_update).uniq
100
81
  end
101
82
 
102
83
  def rescue_strategy
@@ -12,6 +12,12 @@ module Actions
12
12
  plan_action(Repository::Create, clone, true, false)
13
13
  else
14
14
  plan_action(Repository::Clear, clone)
15
+ clone.copy_library_instance_attributes
16
+ clone.save!
17
+
18
+ if ::Katello::Repository.needs_distributor_updates([clone]).first
19
+ plan_action(Pulp::Repository::Refresh, clone)
20
+ end
15
21
  end
16
22
 
17
23
  if repository.yum?
@@ -46,7 +46,9 @@ module Actions
46
46
  end
47
47
 
48
48
  concurrence do
49
- plan_action(::Actions::Pulp::Repos::Update, repository.product) if repository.product.sync_plan
49
+ if !clone && repository.product.sync_plan
50
+ plan_action(::Actions::Pulp::Repos::Update, repository.product)
51
+ end
50
52
  plan_self(:repository_id => repository.id, :clone => clone)
51
53
  end
52
54
  end
@@ -30,8 +30,6 @@ module Actions
30
30
  else
31
31
  handle_custom_content(repository) unless skip_environment_update
32
32
  end
33
-
34
- plan_action(Repository::DestroyMedium, repository)
35
33
  end
36
34
 
37
35
  plan_self(:user_id => ::User.current.id, :planned_destroy => planned_destroy)
@@ -37,7 +37,6 @@ module Actions
37
37
  plan_action(Katello::Foreman::ContentUpdate, repo.environment, repo.content_view, repo)
38
38
  plan_action(Katello::Repository::CorrectChecksum, repo)
39
39
  concurrence do
40
- plan_action(Katello::Repository::UpdateMedia, :repo_id => repo.id, :contents_changed => contents_changed)
41
40
  plan_action(Katello::Repository::ErrataMail, repo, nil, contents_changed)
42
41
  plan_self(:id => repo.id, :sync_result => output, :user_id => ::User.current.id, :contents_changed => contents_changed)
43
42
  plan_action(Pulp::Repository::RegenerateApplicability, :pulp_id => repo.pulp_id, :contents_changed => contents_changed)
@@ -87,7 +87,8 @@ module Katello
87
87
  all_pools = self.get_pools.map { |pool| pool["id"] }
88
88
  added_pools = self.get_key_pools.map { |pool| pool["id"] }
89
89
  available_pools = all_pools - added_pools
90
- Pool.where(:cp_id => available_pools)
90
+ Pool.where(:cp_id => available_pools,
91
+ :subscription_id => Subscription.with_subscribable_content)
91
92
  end
92
93
 
93
94
  def products
@@ -23,11 +23,13 @@ module Katello
23
23
  has_many :applicable_errata, :through => :content_facet
24
24
 
25
25
  scoped_search :in => :content_view, :on => :name, :complete_value => true, :rename => :content_view
26
- scoped_search :in => :content_facet, :on => :content_view_id, :rename => :content_view_id
26
+ scoped_search :in => :content_facet, :on => :content_view_id, :rename => :content_view_id, :only_explicit => true
27
27
  scoped_search :in => :lifecycle_environment, :on => :name, :complete_value => true, :rename => :lifecycle_environment
28
- scoped_search :in => :content_facet, :on => :lifecycle_environment_id, :rename => :lifecycle_environment_id
29
- scoped_search :in => :applicable_errata, :on => :errata_id, :rename => :applicable_errata, :complete_value => true, :ext_method => :find_by_applicable_errata
30
- scoped_search :in => :applicable_errata, :on => :errata_id, :rename => :installable_errata, :complete_value => true, :ext_method => :find_by_installable_errata
28
+ scoped_search :in => :content_facet, :on => :lifecycle_environment_id, :rename => :lifecycle_environment_id, :only_explicit => true
29
+ scoped_search :in => :applicable_errata, :on => :errata_id, :rename => :applicable_errata, :complete_value => true, :ext_method => :find_by_applicable_errata, :only_explicit => true
30
+ scoped_search :in => :applicable_errata, :on => :errata_id, :rename => :installable_errata, :complete_value => true, :ext_method => :find_by_installable_errata, :only_explicit => true
31
+ scoped_search :in => :applicable_rpms, :on => :nvra, :rename => :applicable_rpms, :complete_value => true, :ext_method => :find_by_applicable_rpms, :only_explicit => true
32
+ scoped_search :in => :applicable_rpms, :on => :nvra, :rename => :upgradable_rpms, :complete_value => true, :ext_method => :find_by_installable_rpms, :only_explicit => true
31
33
 
32
34
  accepts_nested_attributes_for :content_facet, :reject_if => proc { |attributes| attributes['content_view_id'].blank? && attributes['lifecycle_environment_id'].blank? }
33
35
  end
@@ -21,10 +21,10 @@ module Katello
21
21
  before_save :correct_puppet_environment
22
22
 
23
23
  scoped_search :in => :content_source, :on => :name, :complete_value => true, :rename => :content_source
24
- scoped_search :in => :host_collections, :on => :id, :complete_value => false, :rename => :host_collection_id
24
+ scoped_search :in => :host_collections, :on => :id, :complete_value => false, :rename => :host_collection_id, :only_explicit => true
25
25
  scoped_search :in => :host_collections, :on => :name, :complete_value => true, :rename => :host_collection
26
- scoped_search :in => :installed_packages, :on => :nvra, :complete_value => true, :rename => :installed_package
27
- scoped_search :in => :installed_packages, :on => :name, :complete_value => true, :rename => :installed_package_name
26
+ scoped_search :in => :installed_packages, :on => :nvra, :complete_value => true, :rename => :installed_package, :only_explicit => true
27
+ scoped_search :in => :installed_packages, :on => :name, :complete_value => true, :rename => :installed_package_name, :only_explicit => true
28
28
  end
29
29
 
30
30
  def validate_media_with_capsule?
@@ -35,7 +35,9 @@ module Katello
35
35
  end
36
36
 
37
37
  def construct_name(family)
38
- if family.include? 'Red Hat'
38
+ if family == ::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME
39
+ return ::Operatingsystem::REDHAT_ATOMIC_HOST_OS
40
+ elsif family.include? 'Red Hat'
39
41
  return 'RedHat'
40
42
  else
41
43
  return family.tr(' ', '_')
@@ -22,12 +22,12 @@ module Katello
22
22
  scoped_search :on => :release_version, :in => :subscription_facet, :complete_value => true
23
23
  scoped_search :on => :autoheal, :in => :subscription_facet, :complete_value => true
24
24
  scoped_search :on => :service_level, :in => :subscription_facet, :complete_value => true
25
- scoped_search :on => :last_checkin, :in => :subscription_facet, :complete_value => true
25
+ scoped_search :on => :last_checkin, :in => :subscription_facet, :complete_value => true, :only_explicit => true
26
26
  scoped_search :on => :registered_through, :in => :subscription_facet, :complete_value => true
27
- scoped_search :on => :registered_at, :in => :subscription_facet, :rename => :registered_at
27
+ scoped_search :on => :registered_at, :in => :subscription_facet, :rename => :registered_at, :only_explicit => true
28
28
  scoped_search :on => :uuid, :in => :subscription_facet, :rename => :subscription_uuid
29
29
  scoped_search :in => :activation_keys, :on => :name, :rename => :activation_key, :complete_value => true, :ext_method => :find_by_activation_key
30
- scoped_search :in => :activation_keys, :on => :id, :rename => :activation_key_id, :complete_value => true, :ext_method => :find_by_activation_key_id
30
+ scoped_search :in => :activation_keys, :on => :id, :rename => :activation_key_id, :complete_value => true, :ext_method => :find_by_activation_key_id, :only_explicit => true
31
31
  end
32
32
 
33
33
  def update_action
@@ -57,6 +57,23 @@ module Katello
57
57
  filename.include?("vmlinuz") || filename.include?("pxeboot")
58
58
  end
59
59
  end
60
+
61
+ def self.needs_importer_updates(repos, capsule = nil)
62
+ repos.select do |repo|
63
+ repo_details = capsule ? capsule.pulp_repo_facts(repo.pulp_id) : repo.pulp_repo_facts
64
+ next unless repo_details
65
+ capsule_importer = repo_details["importers"][0]
66
+ !repo.importer_matches?(capsule_importer)
67
+ end
68
+ end
69
+
70
+ def self.needs_distributor_updates(repos, capsule = nil)
71
+ repos.select do |repo|
72
+ repo_details = capsule ? capsule.pulp_repo_facts(repo.pulp_id) : repo.pulp_repo_facts
73
+ next unless repo_details
74
+ !repo.distributors_match?(repo_details["distributors"], capsule)
75
+ end
76
+ end
60
77
  end
61
78
  end
62
79
 
@@ -117,10 +117,6 @@ module Katello
117
117
  fail _("Pulp does not appear to be running.") if body.empty?
118
118
  json = JSON.parse(body)
119
119
 
120
- if json['known_workers'].empty?
121
- fail _("No pulp workers running.")
122
- end
123
-
124
120
  if json['database_connection'] && json['database_connection']['connected'] != true
125
121
  fail _("Pulp database connection issue.")
126
122
  end
@@ -129,8 +125,21 @@ module Katello
129
125
  fail _("Pulp message bus connection issue.")
130
126
  end
131
127
 
128
+ unless all_pulp_workers_present?(json)
129
+ fail _("Not all necessary pulp workers running.")
130
+ end
131
+
132
132
  json
133
133
  end
134
+
135
+ def all_pulp_workers_present?(json)
136
+ worker_ids = json["known_workers"].collect { |worker| worker["_id"] }
137
+ return false unless worker_ids.any?
138
+ scheduler = worker_ids.any? { |worker| worker.include?("scheduler@") }
139
+ resource_manager = worker_ids.any? { |worker| worker.include?("resource_manager@") }
140
+ reservered_resource_worker = worker_ids.any? { |worker| worker =~ /reserved_resource_worker-./ }
141
+ scheduler && resource_manager && reservered_resource_worker
142
+ end
134
143
  end
135
144
  end
136
145
  end
@@ -57,6 +57,12 @@ module Katello
57
57
  scope :redhat, -> { joins(:provider).where("#{Provider.table_name}.provider_type" => Provider::REDHAT) }
58
58
  scope :custom, -> { joins(:provider).where("#{Provider.table_name}.provider_type" => [Provider::CUSTOM, Provider::ANONYMOUS]) }
59
59
 
60
+ def self.with_subscribable_content
61
+ joins(:repositories).uniq.
62
+ where("#{Katello::Repository.table_name}.content_type IN (?)",
63
+ Repository::SUBSCRIBABLE_TYPES)
64
+ end
65
+
60
66
  def self.enabled
61
67
  self.where("#{Product.table_name}.id in (?) or #{Product.table_name}.id in (?)",
62
68
  Product.redhat.joins(:repositories).uniq.pluck(:id), Product.custom.pluck(:id))
@@ -209,7 +215,9 @@ module Katello
209
215
  end
210
216
 
211
217
  def available_content
212
- self.productContent.find_all { |content| self.repositories.where(:content_id => content.content.id).any? }
218
+ self.productContent.select do |content|
219
+ self.repositories.subscribable.where(content_id: content.content.id).exists?
220
+ end
213
221
  end
214
222
 
215
223
  def related_resources
@@ -24,6 +24,7 @@ module Katello
24
24
  OSTREE_TYPE = 'ostree'.freeze
25
25
 
26
26
  CHECKSUM_TYPES = %w(sha1 sha256).freeze
27
+ SUBSCRIBABLE_TYPES = [YUM_TYPE, OSTREE_TYPE].freeze
27
28
 
28
29
  belongs_to :environment, :inverse_of => :repositories, :class_name => "Katello::KTEnvironment"
29
30
  belongs_to :product, :inverse_of => :repositories
@@ -115,6 +116,7 @@ module Katello
115
116
  scope :non_puppet, -> { where("content_type != ?", PUPPET_TYPE) }
116
117
  scope :non_archived, -> { where('environment_id is not NULL') }
117
118
  scope :archived, -> { where('environment_id is NULL') }
119
+ scope :subscribable, -> { where(content_type: SUBSCRIBABLE_TYPES) }
118
120
 
119
121
  scoped_search :on => :name, :complete_value => true
120
122
  scoped_search :rename => :product, :on => :name, :in => :product, :complete_value => true
@@ -265,6 +267,11 @@ module Katello
265
267
  end
266
268
  end
267
269
 
270
+ def copy_library_instance_attributes
271
+ self.unprotected = library_instance.unprotected
272
+ self.checksum_type = library_instance.checksum_type
273
+ end
274
+
268
275
  # Returns true if the pulp_task_id was triggered by the last synchronization
269
276
  # action for the repository. Dynflow action handles the synchronization
270
277
  # by it's own so no need to synchronize it again in this callback. Since the
@@ -12,6 +12,11 @@ module Katello
12
12
 
13
13
  scope :in_organization, ->(org) { where(:organization => org) }
14
14
 
15
+ def self.with_subscribable_content
16
+ joins(:products).
17
+ where("#{Katello::Product.table_name}.id" => Product.with_subscribable_content)
18
+ end
19
+
15
20
  def redhat?
16
21
  self.products.any? { |product| product.redhat? }
17
22
  end
@@ -12,9 +12,9 @@
12
12
  <table class="table table-fixed table-striped table-bordered">
13
13
  <thead>
14
14
  <tr>
15
- <th>Content View</th>
16
- <th>Task</th>
17
- <th>Status</th>
15
+ <th><%= _("Content View") %></th>
16
+ <th><%= _("Task") %></th>
17
+ <th><%= _("Status") %></th>
18
18
  </tr>
19
19
  </thead>
20
20
  <tbody>
@@ -12,8 +12,8 @@
12
12
  <table class="table table-fixed table-striped">
13
13
  <thead>
14
14
  <tr>
15
- <th>Type</th>
16
- <th>Errata</th>
15
+ <th><%= _("Type") %></th>
16
+ <th><%= _("Errata") %></th>
17
17
  </tr>
18
18
  </thead>
19
19
  <tbody>
@@ -12,9 +12,9 @@
12
12
  <table class="table table-fixed table-striped table-bordered">
13
13
  <thead>
14
14
  <tr>
15
- <th>Updates</th>
16
- <th>Name</th>
17
- <th>Content Hosts</th>
15
+ <th><%= _("Updates") %></th>
16
+ <th><%= _("Name") %></th>
17
+ <th><%= _("Content Hosts") %></th>
18
18
  </tr>
19
19
  </thead>
20
20
  <tbody>
@@ -2,31 +2,36 @@
2
2
  <%= _("Current Subscription Totals") %>
3
3
  </h4>
4
4
 
5
- <% organizations = Organization.current.present? ? [Organization.current] : User.current.allowed_organizations %>
6
- <% subscriptions = Katello::Subscription.in_organization(organizations).includes(:pools) %>
7
- <% total_active_subscriptions = organizations.map {|org| org.active_pools_count}.reduce(:+) %>
8
- <% total_expiring_subscriptions = subscriptions.select(&:expiring_soon?).count %>
9
- <% total_recently_expired_subscriptions = subscriptions.select(&:recently_expired?).count %>
5
+ <% unless Organization.current.present? %>
6
+ <p class="ca"><%= _("Please select an organization to view subscription totals.") %></p>
7
+ <% else %>
8
+ <% subscriptions = Katello::Subscription.in_organization([Organization.current]).includes(:pools) %>
9
+ <% total_active_subscriptions = Organization.current.active_pools_count %>
10
+ <% total_expiring_subscriptions = subscriptions.select(&:expiring_soon?).count %>
11
+ <% total_recently_expired_subscriptions = subscriptions.select(&:recently_expired?).count %>
12
+
13
+ <table class="table table-fixed table-striped table-bordered">
14
+ <thead>
15
+ <tr>
16
+ <th><%= _("Subscription Status") %></th>
17
+ <th><%= _("Count") %></th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <tr>
22
+ <td><%= _("Active Subscriptions") %></td>
23
+ <td style="text-align:right;"><%= total_active_subscriptions %></td>
24
+ </tr>
25
+ <tr>
26
+ <td><%= _("Subscriptions Expiring in 120 Days") %></td>
27
+ <td style="text-align:right;"><%= total_expiring_subscriptions %></td>
28
+ </tr>
29
+ <tr>
30
+ <td><%= _("Recently Expired Subscriptions") %></td>
31
+ <td style="text-align:right;"><%= total_recently_expired_subscriptions %></td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ <% end %>
36
+
10
37
 
11
- <table class="table table-fixed table-striped table-bordered">
12
- <thead>
13
- <tr>
14
- <th>Subscription Status</th>
15
- <th>Count</th>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <tr>
20
- <td><%= _("Active Subscriptions") %></td>
21
- <td style="text-align:right;"><%= total_active_subscriptions %></td>
22
- </tr>
23
- <tr>
24
- <td><%= _("Subscriptions Expiring in 120 Days") %></td>
25
- <td style="text-align:right;"><%= total_expiring_subscriptions %></td>
26
- </tr>
27
- <tr>
28
- <td><%= _("Recently Expired Subscriptions") %></td>
29
- <td style="text-align:right;"><%= total_recently_expired_subscriptions %></td>
30
- </tr>
31
- </tbody>
32
- </table>
@@ -2,58 +2,61 @@
2
2
  <%= _("Content Host Subscription Status") %>
3
3
  </h4>
4
4
 
5
- <% organizations = Organization.current.present? ? [Organization.current] : User.current.allowed_organizations %>
6
- <% owner_infos = organizations.map(&:owner_info) %>
7
- <% invalid_consumer_count = owner_infos.map(&:total_invalid_compliance_consumers).reduce(:+) %>
8
- <% partial_consumer_count = owner_infos.map(&:total_partial_compliance_consumers).reduce(:+) %>
9
- <% valid_consumer_count = owner_infos.map(&:total_valid_compliance_consumers).reduce(:+) %>
10
- <% total_count = owner_infos.map(&:total_consumers).reduce(:+) %>
5
+ <% unless Organization.current.present? %>
6
+ <p class="ca"><%= _("Please select an organization to view subscription status.") %></p>
7
+ <% else %>
8
+ <% owner_info = Organization.current.owner_info %>
9
+ <% invalid_consumer_count = owner_info.total_invalid_compliance_consumers %>
10
+ <% partial_consumer_count = owner_info.total_partial_compliance_consumers %>
11
+ <% valid_consumer_count = owner_info.total_valid_compliance_consumers %>
12
+ <% total_count = owner_info.total_consumers %>
11
13
 
12
- <table class="table table-fixed table-striped table-bordered">
13
- <thead>
14
- <tr>
15
- <th></th>
16
- <th>Count</th>
17
- </tr>
18
- </thead>
19
- <tbody>
20
- <tr>
21
- <td>
22
- <%= link_to('/content_hosts?search=subscription_status=invalid') do %>
23
- <i class="label label-danger" style="margin-right: 6px">&nbsp;</i><%= _("Invalid") %>
24
- <% end %>
25
- </td>
26
- <td style="text-align:right">
27
- <%= link_to( "#{invalid_consumer_count}", '/content_hosts?search=subscription_status=invalid')%>
28
- </td>
29
- </tr>
30
- <tr>
31
- <td>
32
- <%= link_to('/content_hosts?search=subscription_status=partial') do %>
33
- <i class="label label-warning" style="margin-right: 6px">&nbsp;</i><%= _("Partial") %>
34
- <% end %>
35
- </td>
36
- <td style="text-align:right">
37
- <%= link_to( "#{partial_consumer_count}", '/content_hosts?search=subscription_status=partial')%>
38
- </td>
39
- </tr>
40
- <tr>
41
- <td>
42
- <%= link_to('/content_hosts?search=subscription_status=valid') do %>
43
- <i class="label label-success" style="margin-right: 6px">&nbsp;</i><%= _("Valid") %>
44
- <% end %>
45
- </td>
46
- <td style="text-align:right">
47
- <%= link_to( "#{valid_consumer_count}", '/content_hosts?search=subscription_status=valid')%>
48
- </td>
49
- </tr>
50
- <tr>
51
- <td><h4>
52
- <%= link_to("Total Content Hosts", '/content_hosts')%>
53
- </h4></td>
54
- <td style="text-align:right;">
55
- <%= link_to( "#{total_count}", '/content_hosts')%>
56
- </td>
57
- </tr>
58
- </tbody>
59
- </table>
14
+ <table class="table table-fixed table-striped table-bordered">
15
+ <thead>
16
+ <tr>
17
+ <th></th>
18
+ <th><%= _("Count") %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <tr>
23
+ <td>
24
+ <%= link_to('/content_hosts?search=subscription_status=invalid') do %>
25
+ <i class="label label-danger" style="margin-right: 6px">&nbsp;</i><%= _("Invalid") %>
26
+ <% end %>
27
+ </td>
28
+ <td style="text-align:right">
29
+ <%= link_to( "#{invalid_consumer_count}", '/content_hosts?search=subscription_status=invalid')%>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td>
34
+ <%= link_to('/content_hosts?search=subscription_status=partial') do %>
35
+ <i class="label label-warning" style="margin-right: 6px">&nbsp;</i><%= _("Partial") %>
36
+ <% end %>
37
+ </td>
38
+ <td style="text-align:right">
39
+ <%= link_to( "#{partial_consumer_count}", '/content_hosts?search=subscription_status=partial')%>
40
+ </td>
41
+ </tr>
42
+ <tr>
43
+ <td>
44
+ <%= link_to('/content_hosts?search=subscription_status=valid') do %>
45
+ <i class="label label-success" style="margin-right: 6px">&nbsp;</i><%= _("Valid") %>
46
+ <% end %>
47
+ </td>
48
+ <td style="text-align:right">
49
+ <%= link_to( "#{valid_consumer_count}", '/content_hosts?search=subscription_status=valid')%>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td><h4>
54
+ <%= link_to("Total Content Hosts", '/content_hosts')%>
55
+ </h4></td>
56
+ <td style="text-align:right;">
57
+ <%= link_to( "#{total_count}", '/content_hosts')%>
58
+ </td>
59
+ </tr>
60
+ </tbody>
61
+ </table>
62
+ <% end %>
@@ -14,9 +14,9 @@
14
14
  <table class="table table-fixed table-striped table-bordered">
15
15
  <thead>
16
16
  <tr>
17
- <th>Product</th>
18
- <th>Status</th>
19
- <th>Finished</th>
17
+ <th><%= _("Product") %></th>
18
+ <th><%= _("Status") %></th>
19
+ <th><%= _("Finished") %></th>
20
20
  </tr>
21
21
  </thead>
22
22
  <tbody>
@@ -22,6 +22,7 @@ service network restart
22
22
  pm_set = @host.puppetmaster.empty? ? false : true
23
23
  puppet_enabled = pm_set || @host.params['force-puppet']
24
24
  salt_enabled = @host.params['salt_master'] ? true : false
25
+ chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
25
26
  %>
26
27
 
27
28
  <%= snippet "subscription_manager_registration" %>
@@ -44,29 +45,16 @@ yum -t -y -e 0 update
44
45
 
45
46
  <%= snippet('remote_execution_ssh_keys') %>
46
47
 
47
- <% if salt_enabled %>
48
- yum -t -y -e 0 install salt-minion
49
- cat > /etc/salt/minion << EOF
50
- <%= snippet 'saltstack_minion' %>
51
- EOF
52
- # Setup salt-minion to run on system reboot
53
- /sbin/chkconfig --level 345 salt-minion on
54
- # Running salt-call to trigger key signing
55
- salt-call --no-color --grains >/dev/null
48
+ <% if chef_enabled %>
49
+ <%= snippet 'chef_client' %>
56
50
  <% end -%>
57
51
 
58
52
  <% if puppet_enabled %>
59
- yum -t -y -e 0 install puppet
60
- echo "Configuring puppet"
61
- cat > /etc/puppet/puppet.conf << EOF
62
- <%= snippet 'puppet.conf' %>
63
- EOF
64
-
65
- # Setup puppet to run on system reboot
66
- /sbin/chkconfig --level 345 puppet on
53
+ <%= snippet 'puppet_setup' %>
54
+ <% end -%>
67
55
 
68
- /usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
69
- /sbin/service puppet start
56
+ <% if salt_enabled %>
57
+ <%= snippet 'saltstack_setup' %>
70
58
  <% end -%>
71
59
 
72
60
  exit 0
@@ -18,6 +18,7 @@ oses:
18
18
  pm_set = @host.puppetmaster.empty? ? false : true
19
19
  puppet_enabled = pm_set || @host.params['force-puppet']
20
20
  salt_enabled = @host.params['salt_master'] ? true : false
21
+ chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
21
22
  section_end = (rhel_compatible && os_major <= 5) ? '' : '%end'
22
23
  %>
23
24
  install
@@ -113,30 +114,16 @@ yum -t -y -e 0 update
113
114
 
114
115
  <%= snippet('remote_execution_ssh_keys') %>
115
116
 
116
- <% if salt_enabled %>
117
- yum -t -y -e 0 install salt-minion
118
- cat > /etc/salt/minion << EOF
119
- <%= snippet 'saltstack_minion' %>
120
- EOF
121
- # Setup salt-minion to run on system reboot
122
- /sbin/chkconfig --level 345 salt-minion on
123
- # Running salt-call to trigger key signing
124
- salt-call --no-color --grains >/dev/null
117
+ <% if chef_enabled %>
118
+ <%= snippet 'chef_client' %>
125
119
  <% end -%>
126
120
 
127
121
  <% if puppet_enabled %>
128
- # and add the puppet package
129
- yum -t -y -e 0 install puppet
130
-
131
- echo "Configuring puppet"
132
- cat > /etc/puppet/puppet.conf << EOF
133
- <%= snippet 'puppet.conf' %>
134
- EOF
135
-
136
- # Setup puppet to run on system reboot
137
- /sbin/chkconfig --level 345 puppet on
122
+ <%= snippet 'puppet_setup' %>
123
+ <% end -%>
138
124
 
139
- /usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
125
+ <% if salt_enabled %>
126
+ <%= snippet 'saltstack_setup' %>
140
127
  <% end -%>
141
128
 
142
129
  sync
@@ -63,31 +63,24 @@ write_files:
63
63
  pm_set = @host.puppetmaster.empty? ? false : true
64
64
  puppet_enabled = non_atomic && (pm_set || @host.params['force-puppet'])
65
65
  salt_enabled = non_atomic && (@host.params['salt_master'] ? true : false)
66
+ chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
66
67
  %>
67
- <% if salt_enabled %>
68
- yum -t -y -e 0 install salt-minion
69
- cat > /etc/salt/minion << EOF
70
- <%= indent 4 do
71
- snippet 'saltstack_minion'
72
- end %>
73
- EOF
74
- # Setup salt-minion to run on system reboot
75
- /sbin/chkconfig --level 345 salt-minion on
76
- # Running salt-call to trigger key signing
77
- salt-call --no-color --grains >/dev/null
68
+ <% if chef_enabled %>
69
+ <%= indent 4 do
70
+ snippet 'chef_client'
71
+ end %>
78
72
  <% end -%>
73
+
79
74
  <% if puppet_enabled %>
80
- yum install -y puppet
81
- cat > /etc/puppet/puppet.conf << EOF
82
- <%= indent 4 do
83
- snippet 'puppet.conf'
84
- end %>
85
- EOF
86
- # Setup puppet to run on system reboot
87
- /sbin/chkconfig --level 345 puppet on
75
+ <%= indent 4 do
76
+ snippet 'puppet_setup'
77
+ end %>
78
+ <% end -%>
88
79
 
89
- /usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize
90
- /sbin/service puppet start
80
+ <% if salt_enabled %>
81
+ <%= indent 4 do
82
+ snippet 'saltstack_setup'
83
+ end %>
91
84
  <% end -%>
92
85
  phone_home:
93
86
  url: <%= foreman_url('built') %>
@@ -14,7 +14,7 @@
14
14
  select_tag env_select_id, lifecycle_environment_options(@hostgroup, :include_blank => blank_or_inherit_with_id(f, :lifecycle_environment)),
15
15
  :class => 'form-control', :name => env_select_name
16
16
  else
17
- select_tag env_select_id, lifecycle_environment_options(@host, :selected_host_group => @hostgroup, :include_blank => blank_or_inherit_with_id(f, :lifecycle_environment)), :class => 'form-control', :name => env_select_name
17
+ select_tag env_select_id, lifecycle_environment_options(@host, :selected_host_group => @hostgroup || @host.hostgroup, :include_blank => blank_or_inherit_with_id(f, :lifecycle_environment)), :class => 'form-control', :name => env_select_name
18
18
  end
19
19
  end %>
20
20
 
@@ -26,7 +26,7 @@ end %>
26
26
  select_tag cv_select_id, content_views_for_host(@hostgroup, :include_blank => blank_or_inherit_with_id(f, :content_view)), :data => {"spinner_path" => spinner_path},
27
27
  :class => 'form-control', :name => cv_select_name
28
28
  else
29
- select_tag cv_select_id, content_views_for_host(@host, :selected_host_group => @hostgroup, :include_blank => blank_or_inherit_with_id(f, :content_view)), :data => {"spinner_path" => spinner_path}, :class => 'form-control', :name => cv_select_name
29
+ select_tag cv_select_id, content_views_for_host(@host, :selected_host_group => @hostgroup || @host.hostgroup, :include_blank => blank_or_inherit_with_id(f, :content_view)), :data => {"spinner_path" => spinner_path}, :class => 'form-control', :name => cv_select_name
30
30
  end
31
31
  end %>
32
32
 
@@ -64,7 +64,7 @@
64
64
  </div>
65
65
 
66
66
  <span bst-feature-flag="remote_actions">
67
- <span class="input-group-btn">
67
+ <span class="btn-group" uib-dropdown>
68
68
  <button class="btn btn-primary"
69
69
  translate
70
70
  ng-hide="denied('edit_hosts', host)"
@@ -7,7 +7,7 @@
7
7
  </h3>
8
8
 
9
9
  <nav>
10
- <ul class="nav nav-tabs">
10
+ <ul class="nav nav-tabs" ng-show="permitted('edit_content_views', contentView)">
11
11
  <li ng-class="{active: isState('content-views.details.repositories.docker.list')}">
12
12
  <a ui-sref="content-views.details.repositories.docker.list">
13
13
  <span translate>
@@ -7,7 +7,7 @@
7
7
  </h3>
8
8
 
9
9
  <nav>
10
- <ul class="nav nav-tabs">
10
+ <ul class="nav nav-tabs" ng-show="permitted('edit_content_views', contentView)">
11
11
  <li ng-class="{active: isState('content-views.details.repositories.file.list')}">
12
12
  <a ui-sref="content-views.details.repositories.file.list">
13
13
  <span translate>
@@ -7,7 +7,7 @@
7
7
  </h3>
8
8
 
9
9
  <nav>
10
- <ul class="nav nav-tabs">
10
+ <ul class="nav nav-tabs" ng-show="permitted('edit_content_views', contentView)">
11
11
  <li ng-class="{active: isState('content-views.details.repositories.ostree.list')}">
12
12
  <a ui-sref="content-views.details.repositories.ostree.list">
13
13
  <span translate>
@@ -7,7 +7,7 @@
7
7
  </h3>
8
8
 
9
9
  <nav>
10
- <ul class="nav nav-tabs">
10
+ <ul class="nav nav-tabs" ng-show="permitted('edit_content_views', contentView)">
11
11
  <li ng-class="{active: isState('content-views.details.repositories.yum.list')}">
12
12
  <a ui-sref="content-views.details.repositories.yum.list">
13
13
  <span translate>
@@ -81,7 +81,7 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
81
81
  };
82
82
 
83
83
  $scope.uploadContent = function (content) {
84
- var returnData, error;
84
+ var returnData, error, uploaded;
85
85
 
86
86
  if (content) {
87
87
  try {
@@ -95,7 +95,8 @@ angular.module('Bastion.repositories').controller('RepositoryDetailsInfoControll
95
95
  }
96
96
 
97
97
  if (returnData !== null && returnData.status === 'success') {
98
- $scope.uploadSuccessMessages = [translate('Content successfully uploaded')];
98
+ uploaded = returnData.filenames.join(', ');
99
+ $scope.uploadSuccessMessages = [translate('Successfully uploaded content: ') + uploaded];
99
100
  $scope.repository.$get();
100
101
  updateRepositoriesTable();
101
102
  } else {
@@ -18,7 +18,9 @@ angular.module('Bastion.subscriptions').controller('SubscriptionProductsControll
18
18
 
19
19
  Product.queryUnpaged({'organization_id': CurrentOrganization,
20
20
  'subscription_id': $scope.$stateParams.subscriptionId,
21
- enabled: true
21
+ enabled: true,
22
+ 'full_result': true,
23
+ 'include_available_content': true
22
24
  }, function (response) {
23
25
  $scope.products = response.results;
24
26
  $scope.displayArea.working = false;
@@ -172,7 +172,6 @@ module Katello
172
172
  ::Host::Managed.send :include, ::Katello::Concerns::SubscriptionFacetHostExtensions
173
173
  ::Hostgroup.send :include, Katello::Concerns::HostgroupExtensions
174
174
  ::Location.send :include, Katello::Concerns::LocationExtensions
175
- ::Medium.send :include, Katello::Concerns::MediumExtensions
176
175
  ::Redhat.send :include, Katello::Concerns::RedhatExtensions
177
176
  ::Operatingsystem.send :include, Katello::Concerns::OperatingsystemExtensions
178
177
  ::Organization.send :include, Katello::Concerns::OrganizationExtensions
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "3.2.0.rc1.1".freeze
2
+ VERSION = "3.2.0.rc2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.rc1.1
4
+ version: 3.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-20 00:00:00.000000000 Z
11
+ date: 2016-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -653,7 +653,6 @@ files:
653
653
  - app/lib/actions/katello/repository/correct_checksum.rb
654
654
  - app/lib/actions/katello/repository/create.rb
655
655
  - app/lib/actions/katello/repository/destroy.rb
656
- - app/lib/actions/katello/repository/destroy_medium.rb
657
656
  - app/lib/actions/katello/repository/discover.rb
658
657
  - app/lib/actions/katello/repository/errata_mail.rb
659
658
  - app/lib/actions/katello/repository/export.rb
@@ -669,7 +668,6 @@ files:
669
668
  - app/lib/actions/katello/repository/remove_content.rb
670
669
  - app/lib/actions/katello/repository/sync.rb
671
670
  - app/lib/actions/katello/repository/update.rb
672
- - app/lib/actions/katello/repository/update_media.rb
673
671
  - app/lib/actions/katello/repository/upload_errata.rb
674
672
  - app/lib/actions/katello/repository/upload_files.rb
675
673
  - app/lib/actions/katello/repository_set/disable_repository.rb
@@ -830,7 +828,6 @@ files:
830
828
  - app/models/katello/concerns/host_managed_extensions.rb
831
829
  - app/models/katello/concerns/hostgroup_extensions.rb
832
830
  - app/models/katello/concerns/location_extensions.rb
833
- - app/models/katello/concerns/medium_extensions.rb
834
831
  - app/models/katello/concerns/operatingsystem_extensions.rb
835
832
  - app/models/katello/concerns/organization_extensions.rb
836
833
  - app/models/katello/concerns/pulp_database_unit.rb
@@ -1354,7 +1351,6 @@ files:
1354
1351
  - db/seeds.d/106-mail_notifications.rb
1355
1352
  - db/seeds.d/107-enable_dynflow.rb
1356
1353
  - db/seeds.d/108-ensure_sync_notification.rb
1357
- - db/seeds.d/109-atomic_os.rb
1358
1354
  - db/seeds.d/75-job_templates.rb
1359
1355
  - engines/bastion_katello/README.md
1360
1356
  - engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/activation-key.factory.js
@@ -1990,7 +1986,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1990
1986
  version: 1.3.1
1991
1987
  requirements: []
1992
1988
  rubyforge_project:
1993
- rubygems_version: 2.4.8
1989
+ rubygems_version: 2.2.5
1994
1990
  signing_key:
1995
1991
  specification_version: 4
1996
1992
  summary: ''
@@ -1,12 +0,0 @@
1
- module Actions
2
- module Katello
3
- module Repository
4
- class DestroyMedium < Actions::Base
5
- def plan(repo)
6
- medium = Medium.find_medium(repo)
7
- medium.destroy! if medium
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,17 +0,0 @@
1
- module Actions
2
- module Katello
3
- module Repository
4
- class UpdateMedia < Actions::Base
5
- input_format do
6
- param :repo_id
7
- param :contents_changed
8
- end
9
-
10
- def finalize
11
- repo = ::Katello::Repository.find(input[:repo_id])
12
- Medium.update_media(repo)
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,79 +0,0 @@
1
- module Katello
2
- module Concerns
3
- module MediumExtensions
4
- extend ActiveSupport::Concern
5
-
6
- def destroy!
7
- unless destroy
8
- fail self.errors.full_messages.join('; ')
9
- end
10
- end
11
-
12
- module ClassMethods
13
- def update_media(repo)
14
- return if repo.puppet?
15
-
16
- medium_path = ::Medium.installation_media_path(repo.uri)
17
-
18
- if (distribution = repo.distribution_bootable?)
19
- return if ::Medium.find_by(:path => medium_path)
20
-
21
- os = ::Redhat.find_or_create_operating_system(repo)
22
-
23
- arch = ::Architecture.where(:name => repo.distribution_arch).first_or_create!
24
- os.architectures << arch unless os.architectures.include?(arch)
25
-
26
- medium_name = ::Medium.construct_name(repo, distribution)
27
- medium = ::Medium.find_or_create_medium(repo.organization, medium_name, medium_path)
28
- os.media << medium
29
-
30
- os.save!
31
-
32
- else
33
- if (medium = ::Medium.find_by(:path => medium_path))
34
- medium.destroy
35
- end
36
- end
37
- end
38
-
39
- def find_or_create_medium(org, medium_name, medium_path)
40
- params = { :name => medium_name, :path => medium_path,
41
- :os_family => 'Redhat' }
42
-
43
- medium = ::Medium.joins(:organizations).where(params).where("taxonomies.id in (?)", [org.id]).first
44
- medium = ::Medium.create!(params.merge(:organization_ids => [org.id])) unless medium
45
-
46
- return medium
47
- end
48
-
49
- def find_medium(repo)
50
- path = ::Medium.installation_media_path(repo.uri)
51
- ::Medium.find_by(:path => path)
52
- end
53
-
54
- def construct_name(repo, _distribution)
55
- parts = [repo.organization.label, repo.environment.label]
56
- if repo.content_view && !repo.content_view.default?
57
- parts << repo.content_view.label
58
- end
59
- parts << repo.product.label
60
- parts << repo.label
61
- return normalize_name(parts.compact.join('/'))
62
- end
63
-
64
- # Foreman and Puppet uses RedHat name for Red Hat Enterprise Linux
65
- def normalize_name(name)
66
- name.sub('Red_Hat_Enterprise_Linux', 'Red_Hat')
67
- end
68
-
69
- # takes repo uri from Katello and makes installation media url
70
- # suitable for provisioning from it
71
- def installation_media_path(repo_uri)
72
- path = repo_uri.sub(/\Ahttps/, 'http')
73
- path << "/" unless path.end_with?('/')
74
- return path
75
- end
76
- end
77
- end
78
- end
79
- end
@@ -1,11 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # !!! PLEASE KEEP THIS SCRIPT IDEMPOTENT !!!
5
- #
6
-
7
- ::User.current = ::User.anonymous_api_admin
8
- os_attributes = {:major => "7", :minor => "2", :name => ::Operatingsystem::REDHAT_ATOMIC_HOST_OS}
9
- Operatingsystem.where(os_attributes).first_or_create!
10
-
11
- ::User.current = nil