katello 3.5.0.rc2 → 3.5.0

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/katello/containers/container.js +10 -1
  3. data/app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js +7 -3
  4. data/app/controllers/katello/api/v2/api_controller.rb +11 -7
  5. data/app/controllers/katello/api/v2/host_collections_controller.rb +1 -1
  6. data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +1 -1
  7. data/app/controllers/katello/concerns/containers/steps_controller_extensions.rb +11 -3
  8. data/app/lib/actions/katello/capsule_content/create_repos.rb +1 -0
  9. data/app/lib/actions/katello/content_view/errata_mail.rb +1 -1
  10. data/app/lib/actions/katello/host/hypervisors_update.rb +1 -2
  11. data/app/lib/actions/katello/host/update.rb +2 -2
  12. data/app/lib/actions/katello/repository/errata_mail.rb +1 -1
  13. data/app/lib/actions/pulp/repository/abstract_copy_content.rb +1 -1
  14. data/app/lib/katello/resources/candlepin.rb +28 -2
  15. data/app/models/katello/activation_key.rb +1 -1
  16. data/app/models/katello/concerns/container_extensions.rb +1 -1
  17. data/app/models/katello/concerns/docker_container_wizard_state_image_extensions.rb +39 -0
  18. data/app/models/katello/concerns/environment_extensions.rb +1 -1
  19. data/app/models/katello/concerns/location_extensions.rb +33 -8
  20. data/app/models/katello/content_view_puppet_environment.rb +4 -0
  21. data/app/models/katello/docker_manifest.rb +2 -0
  22. data/app/models/katello/docker_meta_tag.rb +33 -0
  23. data/app/models/katello/docker_tag.rb +19 -9
  24. data/app/models/katello/host/subscription_facet.rb +5 -7
  25. data/app/models/katello/product.rb +4 -4
  26. data/app/models/katello/subscription.rb +4 -3
  27. data/app/services/katello/candlepin/consumer.rb +0 -14
  28. data/app/services/katello/pulp/erratum.rb +1 -1
  29. data/app/views/dashboard/_content_views_widget.html.erb +1 -1
  30. data/app/views/foreman_docker/containers/steps/_katello_container.html.erb +15 -1
  31. data/app/views/katello/api/v2/docker_manifests/show.json.rabl +2 -1
  32. data/app/views/katello/api/v2/docker_tags/show.json.rabl +1 -1
  33. data/app/views/katello/api/v2/errata/show.json.rabl +2 -2
  34. data/config/katello.yaml.example +1 -1
  35. data/config/routes/api/v2.rb +6 -1
  36. data/db/migrate/20170822104447_add_katello_content_to_image.rb +5 -0
  37. data/db/migrate/20170913183848_add_errata_counts.rb +1 -0
  38. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/architectures/architecture.factory.js +1 -1
  39. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/content-view-version.controller.js +5 -4
  40. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-manifests/docker-manifest.factory.js +4 -1
  41. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/details/docker-tag-details.controller.js +2 -20
  42. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/details/docker-tag-environments.controller.js +64 -0
  43. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/docker-tags.routes.js +1 -0
  44. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +11 -15
  45. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/erratum-content-hosts.controller.js +3 -0
  46. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/incremental-update.service.js +0 -11
  47. data/lib/katello/engine.rb +3 -1
  48. data/lib/katello/plugin.rb +11 -9
  49. data/lib/katello/tasks/clean_backend_objects.rake +65 -39
  50. data/lib/katello/version.rb +1 -1
  51. metadata +9 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19f6ac9b45e23cc6121072ab218c177f2ce4046c
4
- data.tar.gz: 3b31f09c6475ee12c5b85320c1d0f9fca3ade74d
3
+ metadata.gz: f7792cb8398a9e19e7c8fae76fb5b0fe9ca4c626
4
+ data.tar.gz: fb99940f9ef3827a47fbd91acff229bff0ef5c31
5
5
  SHA512:
6
- metadata.gz: 49d401266bc295ce1885ab5e8bfb6df86cabc5087146416bc683d2126ba1420875e6e360360893457d6860808fa2a82f9af70d2254cd60f42efe9ecafc892cd4
7
- data.tar.gz: 07518a4b60a7117efd0198fbd0b7eb69bd851547b57d8547d36d681ed273e79be5ced13d0972df8d6aabeb4ebc3d23e035761ad4169018af7f2c6c038ad30036
6
+ metadata.gz: 2ebf367c04a9891233895191a5f219fa0613c41f2811d5b7acf67448101be0dfe279d5e8bb909b4df0ce83dbc6fa9d3d9f3b13f8f87e31038a428c43825d30e9
7
+ data.tar.gz: 1c9635966cd20a750531bf3b372e787e457b98c05c8fc7b8a79d04a7456b3c9efcaa7e525a2a4bb5c7e61de938eb243327a03cb9b4c39f6a26719470059f4b4d
@@ -1,6 +1,7 @@
1
1
  var KT = KT ? KT : {};
2
2
 
3
3
  KT.container = (function(){
4
+ var pre_selection = {};
4
5
  var setup = function() {
5
6
  var orgDropdown = $('#organization_id'),
6
7
  envDropdown = $('#kt_environment_id'),
@@ -136,6 +137,7 @@ KT.container = (function(){
136
137
  $('<option></option>').val(cv["id"]).html(cv["name"]));
137
138
  });
138
139
  enableContentViews(true);
140
+ contentViewDropdown.val(pre_selection.content_view_id).trigger('change')
139
141
  } else {
140
142
  noCV.removeClass("hide");
141
143
  }
@@ -173,6 +175,7 @@ KT.container = (function(){
173
175
  $('<option></option>').val(repo["id"]).html(repo["name"]));
174
176
  });
175
177
  enableRepositories(true);
178
+ reposDropdown.val(pre_selection.repository_id).trigger('change');
176
179
  } else {
177
180
  noRepos.removeClass("hide");
178
181
  }
@@ -204,6 +207,7 @@ KT.container = (function(){
204
207
  $('<option></option>').val(tag["id"]).html(tag["name"]));
205
208
  });
206
209
  enableTags(true);
210
+ tagsDropdown.val(pre_selection.tag_id).trigger('change')
207
211
  })
208
212
  .fail(function(resp) {
209
213
  $("#error_tags").removeClass("hide")
@@ -278,9 +282,14 @@ KT.container = (function(){
278
282
  spinner.addClass("hide")
279
283
  }
280
284
  };
281
-
285
+ setSelection = function(selection) {
286
+ pre_selection = selection;
287
+ $('#kt_environment_id').val(selection.environment_id)
288
+ .trigger('change')
289
+ }
282
290
  return {
283
291
  setup: setup,
292
+ setSelection: setSelection,
284
293
  enableNext: enableNext
285
294
  };
286
295
  })();
@@ -119,7 +119,7 @@ KT.hosts.getSelectedEnvironment = function () {
119
119
 
120
120
  KT.hosts.onKatelloHostEditLoad = function(){
121
121
  var prefxies = ['host', 'hostgroup'],
122
- attributes = ['lifecycle_environment_id', 'content_view_id', 'environment_id', 'content_source_id', 'architecture_id'];
122
+ attributes = ['lifecycle_environment_id', 'content_view_id', 'environment_id', 'architecture_id'];
123
123
 
124
124
  $.each(prefxies, function(index, prefix) {
125
125
  $.each(attributes, function(attrIndex, attribute) {
@@ -128,6 +128,10 @@ KT.hosts.onKatelloHostEditLoad = function(){
128
128
  });
129
129
  });
130
130
  });
131
+
132
+ $('body').on('change', '#content_source_id', function () {
133
+ KT.hosts.toggle_installation_medium();
134
+ });
131
135
  };
132
136
 
133
137
  KT.hosts.toggle_installation_medium = function() {
@@ -136,13 +140,13 @@ KT.hosts.toggle_installation_medium = function() {
136
140
  if ($('#hostgroup_parent_id').length > 0) {
137
141
  lifecycle_environment_id = KT.hosts.getSelectedEnvironment();
138
142
  content_view_id = KT.hosts.getSelectedContentView();
139
- content_source_id = $('#hostgroup_content_source_id').val();
143
+ content_source_id = $('#content_source_id').val();
140
144
  architecture_id = $('#hostgroup_architecture_id').val();
141
145
  operatingsystem_id = $('#hostgroup_operatingsystem_id').val();
142
146
  } else {
143
147
  lifecycle_environment_id = KT.hosts.getSelectedEnvironment();
144
148
  content_view_id = KT.hosts.getSelectedContentView();
145
- content_source_id = $('#host_content_source_id').val();
149
+ content_source_id = $('#content_source_id').val();
146
150
  architecture_id = $('#host_architecture_id').val();
147
151
  operatingsystem_id = $('#host_operatingsystem_id').val();
148
152
  }
@@ -57,6 +57,16 @@ module Katello
57
57
  includes = options.fetch(:includes, [])
58
58
  group = options.fetch(:group, nil)
59
59
 
60
+ if params[:order]
61
+ (params[:sort_by], params[:sort_order]) = params[:order].split(' ')
62
+ end
63
+
64
+ sort_attr = (params[:sort_by] || default_sort_by).to_s.downcase
65
+
66
+ if sort_attr.present? && !resource.column_names.include?(sort_attr)
67
+ fail ScopedSearch::QueryNotSupported, _("the field (%s) in the order statement is not valid field for search") % sort_attr
68
+ end
69
+
60
70
  total = scoped_search_total(query, group)
61
71
 
62
72
  unless empty_search_query?
@@ -67,13 +77,7 @@ module Katello
67
77
  query = query.select(group).group(group) if group
68
78
  sub_total = total.zero? ? 0 : scoped_search_total(query, group)
69
79
 
70
- if params[:order]
71
- (params[:sort_by], params[:sort_order]) = params[:order].split(' ')
72
- end
73
-
74
- sort_attr = params[:sort_by] || default_sort_by
75
-
76
- if sort_attr
80
+ if sort_attr.present?
77
81
  sort_order = (params[:sort_order] || default_sort_order).to_s.downcase
78
82
  sort_order = default_sort_order unless ['desc', 'asc'].include?(sort_order)
79
83
  query = query.order(sort_attr => sort_order.to_sym)
@@ -27,7 +27,7 @@ module Katello
27
27
  api :GET, "/organizations/:organization_id/host_collections", N_("List host collections within an organization")
28
28
  api :GET, "/activation_keys/:activation_key_id/host_collections", N_("List host collections in an activation key")
29
29
  param_group :search, Api::V2::ApiController
30
- param :organization_id, :number, :desc => N_("organization identifier"), :required => true
30
+ param :organization_id, :number, :desc => N_("organization identifier")
31
31
  param :name, String, :desc => N_("host collection name to filter by")
32
32
  param :activation_key_id, :identifier, :desc => N_("activation key identifier")
33
33
  param :host_id, :number, :desc => N_("Filter products by host id")
@@ -202,7 +202,7 @@ module Katello
202
202
  _("Puppet Module")
203
203
  when "Katello::DockerManifest"
204
204
  _("Docker Manifest")
205
- when "Katello::DockerTag"
205
+ when "Katello::DockerMetaTag"
206
206
  _("Docker Tag")
207
207
  when "Katello::OstreeBranch"
208
208
  _("OSTree Branch")
@@ -26,15 +26,23 @@ module Katello
26
26
  end
27
27
 
28
28
  if params[:tag] && params[:tag][:id]
29
- tag = DockerTag.where(:id => params[:tag][:id]).first
29
+ tag = DockerMetaTag.where(:id => params[:tag][:id]).first
30
30
  end
31
31
  if params[:capsule] && params[:capsule][:id]
32
32
  capsule_id = params[:capsule][:id]
33
33
  end
34
- @docker_container_wizard_states_image = @state.build_image(:repository_name => repo.try(:pulp_id),
34
+
35
+ katello_content = {
36
+ organization_id: params[:organization_id],
37
+ environment_id: params.fetch(:kt_environment, {})[:id],
38
+ content_view_id: params.fetch(:content_view, {})[:id],
39
+ repository_id: repo.try(:id),
40
+ tag_id: tag.try(:id)
41
+ }
42
+ @docker_container_wizard_states_image = @state.build_image(:repository_name => repo.try(:container_repository_name),
35
43
  :tag => tag.try(:name),
36
44
  :capsule_id => capsule_id,
37
- :katello => true)
45
+ :katello => true, :katello_content => katello_content)
38
46
  else
39
47
  build_state_without_katello
40
48
  end
@@ -44,6 +44,7 @@ module Actions
44
44
  path: relative_path,
45
45
  with_importer: true,
46
46
  docker_upstream_name: repository.docker? ? repository.container_repository_name : nil,
47
+ repo_registry_id: repository.docker? ? repository.container_repository_name : nil,
47
48
  download_policy: repository.capsule_download_policy(capsule_content.capsule),
48
49
  capsule_id: capsule_content.capsule.id)
49
50
  end
@@ -14,7 +14,7 @@ module Actions
14
14
  users = ::User.select { |user| user.receives?(:promote_errata) && user.organization_ids.include?(content_view.organization_id) && user.can?(:view_content_views, content_view) }
15
15
 
16
16
  begin
17
- MailNotification[:promote_errata].deliver_now(:users => users, :content_view => content_view, :environment => environment) unless users.blank?
17
+ MailNotification[:promote_errata].deliver(:users => users, :content_view => content_view, :environment => environment) unless users.blank?
18
18
  rescue => e
19
19
  message = _('Unable to send errata e-mail notification: %{error}' % {:error => e})
20
20
  Rails.logger.error(message)
@@ -45,8 +45,7 @@ module Actions
45
45
  end
46
46
 
47
47
  def create_host_for_hypervisor(name, organization, location = nil)
48
- location ||= Location.unscoped.find_by_title(
49
- Setting[:default_location_subscribed_hosts])
48
+ location ||= Location.default_host_subscribe_location!
50
49
  host = ::Host::Managed.new(:name => name, :organization => organization,
51
50
  :location => location, :managed => false, :enabled => false)
52
51
  host.save!
@@ -28,7 +28,7 @@ module Actions
28
28
  def run
29
29
  User.as_anonymous_admin do
30
30
  host = ::Host.find(input[:host_id])
31
- unless input[:consumer_params][:facts].blank?
31
+ if input[:consumer_params].try(:[], :facts)
32
32
  ::Katello::Host::SubscriptionFacet.update_facts(host, input[:consumer_params][:facts])
33
33
  end
34
34
  end
@@ -40,7 +40,7 @@ module Actions
40
40
  host = ::Host.find(input[:host_id])
41
41
  host.subscription_facet.update_from_consumer_attributes(input[:consumer_params])
42
42
  host.subscription_facet.save!
43
- input[:consumer_params][:facts] = 'TRIMMED' unless input[:consumer_params][:facts].blank?
43
+ input[:consumer_params][:facts] = 'TRIMMED' if input[:consumer_params].try(:[], :facts)
44
44
  end
45
45
  end
46
46
  end
@@ -17,7 +17,7 @@ module Actions
17
17
  errata = ::Katello::Erratum.where(:id => repo.repository_errata.where('katello_repository_errata.updated_at > ?', input[:last_updated].to_datetime).pluck(:erratum_id))
18
18
 
19
19
  begin
20
- MailNotification[:sync_errata].deliver_now(:users => users, :repo => repo, :errata => errata) unless (users.blank? || errata.blank?)
20
+ MailNotification[:sync_errata].deliver(:users => users, :repo => repo, :errata => errata) unless (users.blank? || errata.blank?)
21
21
  rescue => e
22
22
  message = _('Unable to send errata e-mail notification: %{error}' % {:error => e})
23
23
  Rails.logger.error(message)
@@ -21,7 +21,7 @@ module Actions
21
21
  optional[:override_config] = input[:override_config] if input[:override_config]
22
22
  content_extension.copy(input[:source_pulp_id],
23
23
  input[:target_pulp_id],
24
- criteria)
24
+ optional)
25
25
  end
26
26
 
27
27
  def criteria
@@ -90,6 +90,21 @@ module Katello
90
90
  def self.included_list(included)
91
91
  included.map { |value| "include=#{value}" }.join('&')
92
92
  end
93
+
94
+ def self.fetch_paged(page_size = -1)
95
+ if page_size == -1
96
+ page_size = SETTINGS[:katello][:candlepin][:bulk_load_size]
97
+ end
98
+ page = 0
99
+ content = []
100
+ loop do
101
+ page += 1
102
+ data = yield("per_page=#{page_size}&page=#{page}")
103
+ content.concat(data)
104
+ break if data.size < page_size
105
+ end
106
+ content
107
+ end
93
108
  end
94
109
 
95
110
  class CandlepinPing < CandlepinResource
@@ -112,12 +127,23 @@ module Katello
112
127
  "/candlepin/consumers/#{id}"
113
128
  end
114
129
 
130
+ def all_uuids
131
+ cp_consumers = Organization.all.map do |org|
132
+ ::Katello::Resources::Candlepin::Consumer.get('owner' => org.label, :include_only => [:uuid])
133
+ end
134
+ cp_consumers.flatten!
135
+ cp_consumers.map { |consumer| consumer["uuid"] }
136
+ end
137
+
115
138
  def get(params)
116
139
  if params.is_a?(String)
117
140
  JSON.parse(super(path(params), self.default_headers).body).with_indifferent_access
118
141
  else
119
- response = super(path + hash_to_query(params), self.default_headers).body
120
- JSON.parse(response)
142
+ includes = params.key?(:include_only) ? "&" + included_list(params.delete(:include_only)) : ""
143
+ fetch_paged do |page_add|
144
+ response = super(path + hash_to_query(params) + includes + "&#{page_add}", self.default_headers).body
145
+ JSON.parse(response)
146
+ end
121
147
  end
122
148
  end
123
149
 
@@ -88,7 +88,7 @@ module Katello
88
88
  added_pools = self.pools.pluck(:cp_id)
89
89
  available_pools = all_pools - added_pools
90
90
  Pool.where(:cp_id => available_pools,
91
- :subscription_id => Subscription.with_subscribable_content)
91
+ :subscription_id => Subscription.subscribable)
92
92
  end
93
93
 
94
94
  def products
@@ -12,7 +12,7 @@ module Katello
12
12
 
13
13
  def repository_pull_url_with_katello
14
14
  repo_url = repository_pull_url_without_katello
15
- if Repository.where(:pulp_id => repository_name).count > 0
15
+ if Repository.where(:container_repository_name => repository_name).count > 0
16
16
  manifest_capsule = self.capsule || CapsuleContent.default_capsule.capsule
17
17
  "#{URI(manifest_capsule.url).hostname}:#{Setting['pulp_docker_registry_port']}/#{repo_url}"
18
18
  else
@@ -0,0 +1,39 @@
1
+ module Katello
2
+ module Concerns
3
+ module DockerContainerWizardStateImageExtensions
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ alias_method_chain :image_exists, :katello
8
+
9
+ serialize :katello_content, Hash
10
+ validate :katello_content_completed, :if => :katello?
11
+ end
12
+
13
+ def image_exists_with_katello
14
+ return true if katello?
15
+ image_exists_without_katello
16
+ end
17
+
18
+ def katello_content_completed
19
+ empty_values = katello_content.map do |key, value|
20
+ key if value.blank?
21
+ end
22
+ empty_values.compact!
23
+
24
+ return true if empty_values.empty?
25
+
26
+ message_mapping = {
27
+ organization_id: _("Organization not set"),
28
+ environment_id: _("Lifecycle Environment not set"),
29
+ content_view_id: _("Content View not set"),
30
+ repository_id: _("Repository not set"),
31
+ tag_id: _("Tag not set")
32
+ }
33
+ empty_values.each do |key|
34
+ errors.add(:katello_content, message_mapping[key])
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -38,7 +38,7 @@ module Katello
38
38
  def build_by_katello_id(org, env, content_view)
39
39
  env_name = Environment.construct_name(org, env, content_view)
40
40
  katello_id = Environment.construct_katello_id(org, env, content_view)
41
- default_location_id = ::Location.find_by_title(::Setting[:default_location_puppet_content]).id
41
+ default_location_id = ::Location.default_puppet_content_location!.id
42
42
  environment = Environment.new(:name => env_name,
43
43
  :organization_ids => [org.id],
44
44
  :location_ids => [default_location_id])
@@ -5,6 +5,7 @@ module Katello
5
5
 
6
6
  included do
7
7
  after_initialize :set_default_overrides, :if => :new_record?
8
+ after_save :reset_settings
8
9
  before_destroy :deletable?
9
10
  end
10
11
 
@@ -13,6 +14,17 @@ module Katello
13
14
  self.ignore_types << ::Hostgroup.name
14
15
  end
15
16
 
17
+ def reset_settings
18
+ if self.title_changed?
19
+ if ::Setting[:default_location_subscribed_hosts] == self.title_was
20
+ ::Setting[:default_location_subscribed_hosts] = self.title
21
+ end
22
+ if ::Setting[:default_location_puppet_content] == self.title_was
23
+ ::Setting[:default_location_puppet_content] = self.title
24
+ end
25
+ end
26
+ end
27
+
16
28
  def deletable?
17
29
  if ::Location.unscoped.count == 1
18
30
  errors.add(
@@ -43,15 +55,28 @@ module Katello
43
55
  end
44
56
 
45
57
  module ClassMethods
58
+ def default_puppet_content_location
59
+ ::Location.unscoped.find_by_title(::Setting[:default_location_puppet_content]) if ::Setting[:default_location_puppet_content].present?
60
+ end
61
+
62
+ def default_puppet_content_location!
63
+ location = default_puppet_content_location
64
+ fail _("Setting 'default_location_puppet_content' is not set to a valid location.") if location.nil?
65
+ location
66
+ end
67
+
68
+ def default_host_subscribe_location
69
+ ::Location.unscoped.find_by_title(::Setting[:default_location_subscribed_hosts]) if ::Setting[:default_location_subscribed_hosts].present?
70
+ end
71
+
72
+ def default_host_subscribe_location!
73
+ location = default_host_subscribe_location
74
+ fail _("Setting 'default_location_subscribed_hosts' is not set to a valid location.") if location.nil?
75
+ location
76
+ end
77
+
46
78
  def default_location_ids
47
- ids = []
48
- if ::Setting[:default_location_puppet_content].present?
49
- ids << ::Location.find_by_title(::Setting[:default_location_puppet_content]).id
50
- end
51
- if ::Setting[:default_location_subscribed_hosts].present?
52
- ids << ::Location.find_by_title(::Setting[:default_location_subscribed_hosts]).id
53
- end
54
- ids.uniq
79
+ [default_host_subscribe_location, default_puppet_content_location].compact.map(&:id).uniq
55
80
  end
56
81
  end
57
82
  end
@@ -38,6 +38,10 @@ module Katello
38
38
  false
39
39
  end
40
40
 
41
+ def mirror_on_sync?
42
+ true
43
+ end
44
+
41
45
  def node_syncable?
42
46
  environment
43
47
  end
@@ -9,6 +9,8 @@ module Katello
9
9
  CONTENT_TYPE = Pulp::DockerManifest::CONTENT_TYPE
10
10
  scoped_search :on => :name, :complete_value => true
11
11
  scoped_search :relation => :docker_tags, :on => :name, :rename => :tag, :complete_value => true, :only_explicit => true
12
+ scoped_search :on => :digest, :rename => :digest, :complete_value => true, :only_explicit => true
13
+ scoped_search :on => :schema_version, :rename => :schema_version, :complete_value => true, :only_explicit => true
12
14
 
13
15
  def self.repository_association_class
14
16
  RepositoryDockerManifest
@@ -9,6 +9,31 @@ module Katello
9
9
  belongs_to :schema2, :class_name => "Katello::DockerTag",
10
10
  :inverse_of => :schema2_meta_tag
11
11
 
12
+ scoped_search :on => :name, :complete_value => true, :rename => :tag
13
+ scoped_search :on => :schema_version, :rename => :schema_version, :complete_value => { "1" => "1", "2" => "2"},
14
+ :only_explicit => true, :ext_method => :find_by_schema_version, :operators => ["="]
15
+ scoped_search :relation => :repository, :on => :name, :rename => :repository,
16
+ :complete_value => true, :only_explicit => true
17
+
18
+ def self.find_by_schema_version(_key, operator, value)
19
+ conditions = ""
20
+ if operator == '='
21
+ if ["1", "2"].include?(value)
22
+ column = if value == "1"
23
+ "schema1_id"
24
+ else
25
+ "schema2_id"
26
+ end
27
+ docker_meta_tag_arel_table = ::Katello::DockerMetaTag.arel_table
28
+ conditions = docker_meta_tag_arel_table[column].not_eq(nil).to_sql
29
+ else
30
+ #failure condition. No such value so must return 0
31
+ conditions = "1=0"
32
+ end
33
+ end
34
+ { :conditions => conditions }
35
+ end
36
+
12
37
  def self.delegate_to_tags(*names)
13
38
  names.each do |name|
14
39
  define_method(name) do
@@ -28,6 +53,10 @@ module Katello
28
53
  [self.repository]
29
54
  end
30
55
 
56
+ def related_tags
57
+ self.class.where(:repository_id => repository.group, :name => name)
58
+ end
59
+
31
60
  def self.in_repositories(repos, grouped = false)
32
61
  if grouped
33
62
  search_in_tags(DockerTag.in_repositories(repos).grouped)
@@ -49,6 +78,10 @@ module Katello
49
78
  schema2.try(:docker_manifest)
50
79
  end
51
80
 
81
+ def self.with_uuid(ids)
82
+ self.with_identifiers(ids)
83
+ end
84
+
52
85
  def self.with_identifiers(ids)
53
86
  self.where(:id => ids)
54
87
  end
@@ -11,20 +11,20 @@ module Katello
11
11
  has_one :schema2_meta_tag, :class_name => "Katello::DockerMetaTag", :foreign_key => "schema2_id",
12
12
  :inverse_of => :schema2, :dependent => :nullify
13
13
 
14
- scoped_search :on => :name, :complete_value => true, :rename => :tag
15
- scoped_search :relation => :docker_manifest, :on => :name, :rename => :manifest,
16
- :complete_value => true, :only_explicit => false
17
- scoped_search :relation => :docker_manifest, :on => :digest, :rename => :digest,
18
- :complete_value => false, :only_explicit => true
19
- scoped_search :relation => :docker_manifest, :on => :schema_version, :rename => :schema_version,
20
- :complete_value => false, :only_explicit => true
21
- scoped_search :relation => :repository, :on => :name, :rename => :repository,
22
- :complete_value => true, :only_explicit => true
14
+ before_destroy :cleanup_meta_tags
23
15
 
24
16
  scope :in_repositories, ->(repos) { where(:repository_id => repos) }
25
17
 
26
18
  delegate :relative_path, :environment, :content_view_version, :product, :to => :repository
27
19
 
20
+ def associated_meta_tag
21
+ schema1_meta_tag || schema2_meta_tag
22
+ end
23
+
24
+ def associated_meta_tag_identifier
25
+ associated_meta_tag.id
26
+ end
27
+
28
28
  def self.grouped
29
29
  grouped_fields = "#{table_name}.name, #{Repository.table_name}.name, #{Product.table_name}.name"
30
30
  ids = uniq.select("ON (#{grouped_fields}) #{table_name}.id").joins(:repository => :product)
@@ -73,5 +73,15 @@ module Katello
73
73
  def self.completer_scope_options
74
74
  {"#{Katello::Repository.table_name}" => lambda { |repo_class| repo_class.docker_type } }
75
75
  end
76
+
77
+ def cleanup_meta_tags
78
+ if schema1_meta_tag && schema1_meta_tag.schema2.blank?
79
+ schema1_meta_tag.destroy
80
+ end
81
+
82
+ if schema2_meta_tag && schema2_meta_tag.schema1.blank?
83
+ schema2_meta_tag.destroy
84
+ end
85
+ end
76
86
  end
77
87
  end
@@ -146,13 +146,11 @@ module Katello
146
146
 
147
147
  def self.find_or_create_host(organization, rhsm_params)
148
148
  host = find_host(rhsm_params[:facts], organization)
149
- unless host
150
- host = Katello::Host::SubscriptionFacet.new_host_from_facts(
151
- rhsm_params[:facts],
152
- organization,
153
- Location.unscoped.find_by_title(::Setting[:default_location_subscribed_hosts])
154
- )
155
- end
149
+ host ||= Katello::Host::SubscriptionFacet.new_host_from_facts(
150
+ rhsm_params[:facts],
151
+ organization,
152
+ Location.default_host_subscribe_location!
153
+ )
156
154
  host.organization = organization unless host.organization
157
155
  host
158
156
  end
@@ -55,10 +55,10 @@ module Katello
55
55
  scope :redhat, -> { joins(:provider).where("#{Provider.table_name}.provider_type" => Provider::REDHAT) }
56
56
  scope :custom, -> { joins(:provider).where("#{Provider.table_name}.provider_type" => [Provider::CUSTOM, Provider::ANONYMOUS]) }
57
57
 
58
- def self.with_subscribable_content
59
- joins(:repositories).uniq.
60
- where("#{Katello::Repository.table_name}.content_type IN (?)",
61
- Repository::SUBSCRIBABLE_TYPES)
58
+ def self.subscribable
59
+ joins("LEFT OUTER JOIN #{Katello::Repository.table_name} repo ON repo.product_id = #{self.table_name}.id")
60
+ .where("repo.content_type IN (?) OR repo IS NULL", Repository::SUBSCRIBABLE_TYPES)
61
+ .group("#{self.table_name}.id, repo.product_id")
62
62
  end
63
63
 
64
64
  def self.enabled
@@ -12,9 +12,10 @@ 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)
15
+ def self.subscribable
16
+ joins("LEFT OUTER JOIN #{Katello::SubscriptionProduct.table_name} subprod ON #{self.table_name}.id = subprod.subscription_id")
17
+ .where("subprod.product_id" => Product.subscribable << nil)
18
+ .group("#{self.table_name}.id")
18
19
  end
19
20
 
20
21
  def self.using_virt_who
@@ -122,20 +122,6 @@ module Katello
122
122
  end
123
123
  end
124
124
 
125
- def self.orphaned_consumer_ids
126
- #returns consumer ids in candlepin with no matching katello entry
127
- orphaned_ids = []
128
- User.as_anonymous_admin do
129
- cp_consumers = Organization.all.collect { |org| ::Katello::Resources::Candlepin::Consumer.get('owner' => org.label) }
130
- cp_consumers.flatten!
131
- cp_consumers.reject! { |consumer| consumer['type']['label'] == 'uebercert' }
132
- cp_consumer_ids = cp_consumers.map { |consumer| consumer["uuid"] }
133
- katello_consumer_ids = ::Katello::Host::SubscriptionFacet.pluck(:uuid)
134
- orphaned_ids = cp_consumer_ids - katello_consumer_ids
135
- end
136
- orphaned_ids
137
- end
138
-
139
125
  def self.distribution_to_puppet_os(name)
140
126
  return ::Operatingsystem::REDHAT_ATOMIC_HOST_OS if name == ::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME
141
127
 
@@ -1,7 +1,7 @@
1
1
  module Katello
2
2
  module Pulp
3
3
  class Erratum < PulpContentUnit
4
- PULP_SELECT_FIELDS = %w(id).freeze
4
+ PULP_SELECT_FIELDS = %w(errata_id).freeze
5
5
  CONTENT_TYPE = "erratum".freeze
6
6
 
7
7
  def self.unit_handler
@@ -21,7 +21,7 @@
21
21
  <% histories.each do |history| %>
22
22
  <tr>
23
23
  <td class='ellipsis'>
24
- <a href="/content_views/<%= history.content_view_version.content_view.id %>/versions/<%= history.content_view_version.id %>/details">
24
+ <a href="/content_views/<%= history.content_view_version.content_view.id %>/versions/<%= history.content_view_version.id %>">
25
25
  <%= history.content_view_version.content_view.name %> <%= history.content_view_version.version %>
26
26
  </a>
27
27
  </td>