katello 3.4.5 → 3.5.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/app/assets/stylesheets/katello/katello.scss +7 -5
- data/app/controllers/katello/api/v2/activation_keys_controller.rb +3 -3
- data/app/controllers/katello/api/v2/api_controller.rb +8 -0
- data/app/controllers/katello/api/v2/capsule_content_controller.rb +6 -1
- data/app/controllers/katello/api/v2/content_view_filter_rules_controller.rb +2 -1
- data/app/controllers/katello/api/v2/content_view_versions_controller.rb +1 -1
- data/app/controllers/katello/api/v2/content_views_controller.rb +1 -1
- data/app/controllers/katello/api/v2/host_collections_controller.rb +1 -1
- data/app/controllers/katello/api/v2/host_subscriptions_controller.rb +2 -2
- data/app/controllers/katello/api/v2/host_tracer_controller.rb +1 -1
- data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +6 -6
- data/app/controllers/katello/api/v2/repositories_controller.rb +6 -7
- data/app/controllers/katello/api/v2/repository_sets_controller.rb +25 -4
- data/app/controllers/katello/concerns/api/v2/content_overrides_controller.rb +2 -4
- data/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb +10 -27
- data/app/controllers/katello/concerns/api/v2/smart_proxies_controller_extensions.rb +10 -14
- data/app/controllers/katello/concerns/hosts_controller_extensions.rb +33 -0
- data/app/helpers/katello/hosts_and_hostgroups_helper.rb +2 -1
- data/app/helpers/katello/organizations_helper.rb +1 -1
- data/app/helpers/katello/providers_helper.rb +1 -1
- data/app/lib/actions/candlepin/abstract_async_task.rb +1 -1
- data/app/lib/actions/candlepin/candlepin_listening_service.rb +17 -6
- data/app/lib/actions/candlepin/import_pool_handler.rb +21 -56
- data/app/lib/actions/candlepin/listen_on_candlepin_events.rb +1 -0
- data/app/lib/actions/candlepin/owner/import_products.rb +1 -3
- data/app/lib/actions/candlepin/product/content_create.rb +2 -0
- data/app/lib/actions/candlepin/product/content_update.rb +2 -0
- data/app/lib/actions/candlepin/product/create.rb +2 -10
- data/app/lib/actions/candlepin/product/create_unlimited_subscription.rb +8 -1
- data/app/lib/actions/katello/capsule_content/sync.rb +12 -3
- data/app/lib/actions/katello/host/attach_subscriptions.rb +1 -1
- data/app/lib/actions/katello/host/hypervisors_update.rb +2 -4
- data/app/lib/actions/katello/host/remove_subscriptions.rb +1 -1
- data/app/lib/actions/katello/organization/create.rb +2 -2
- data/app/lib/actions/katello/organization/manifest_refresh.rb +1 -2
- data/app/lib/actions/katello/product/content_create.rb +4 -4
- data/app/lib/actions/katello/product/create.rb +13 -11
- data/app/lib/actions/katello/repository/sync.rb +0 -1
- data/app/lib/actions/katello/repository/update.rb +2 -1
- data/app/lib/actions/pulp/consumer/generate_applicability.rb +5 -1
- data/app/lib/actions/pulp/repository/create.rb +1 -0
- data/app/lib/actions/pulp/repository/create_in_plan.rb +4 -4
- data/app/lib/actions/pulp/repository/sync.rb +1 -1
- data/app/lib/katello/http_resource.rb +1 -1
- data/app/lib/katello/lazy_accessor.rb +1 -1
- data/app/lib/katello/resources/candlepin.rb +2 -2
- data/app/lib/katello/util/data.rb +6 -0
- data/app/lib/katello/util/support.rb +1 -1
- data/app/models/katello/activation_key.rb +25 -7
- data/app/models/katello/concerns/host_managed_extensions.rb +60 -17
- data/app/models/katello/concerns/subscription_facet_host_extensions.rb +31 -10
- data/app/models/katello/content_facet_applicable_rpm.rb +0 -2
- data/app/models/katello/content_facet_erratum.rb +0 -2
- data/app/models/katello/content_facet_repository.rb +0 -2
- data/app/models/katello/content_view.rb +3 -4
- data/app/models/katello/content_view_component.rb +1 -3
- data/app/models/katello/content_view_docker_filter_rule.rb +0 -2
- data/app/models/katello/content_view_environment.rb +2 -4
- data/app/models/katello/content_view_erratum_filter_rule.rb +0 -2
- data/app/models/katello/content_view_filter.rb +0 -2
- data/app/models/katello/content_view_package_filter_rule.rb +0 -2
- data/app/models/katello/content_view_package_group_filter_rule.rb +0 -2
- data/app/models/katello/content_view_puppet_environment.rb +0 -2
- data/app/models/katello/content_view_puppet_environment_puppet_module.rb +0 -2
- data/app/models/katello/content_view_puppet_module.rb +0 -2
- data/app/models/katello/content_view_repository.rb +0 -2
- data/app/models/katello/content_view_version.rb +0 -2
- data/app/models/katello/erratum_bugzilla.rb +0 -2
- data/app/models/katello/erratum_cve.rb +0 -2
- data/app/models/katello/erratum_package.rb +0 -2
- data/app/models/katello/ext/label_from_name.rb +1 -1
- data/app/models/katello/glue/candlepin/pool.rb +18 -11
- data/app/models/katello/glue/candlepin/product.rb +1 -2
- data/app/models/katello/glue/pulp/repo.rb +13 -6
- data/app/models/katello/glue/pulp/repos.rb +16 -16
- data/app/models/katello/gpg_key.rb +0 -2
- data/app/models/katello/host/content_facet.rb +21 -0
- data/app/models/katello/host/info_provider.rb +56 -0
- data/app/models/katello/host/subscription_facet.rb +5 -3
- data/app/models/katello/host_collection.rb +0 -2
- data/app/models/katello/host_collection_hosts.rb +0 -2
- data/app/models/katello/host_installed_package.rb +0 -2
- data/app/models/katello/host_tracer.rb +0 -2
- data/app/models/katello/key_host_collection.rb +0 -2
- data/app/models/katello/kt_environment.rb +0 -2
- data/app/models/katello/model.rb +1 -1
- data/app/models/katello/pool.rb +3 -3
- data/app/models/katello/product.rb +10 -3
- data/app/models/katello/provider.rb +0 -2
- data/app/models/katello/repository.rb +0 -2
- data/app/models/katello/repository_docker_manifest.rb +0 -2
- data/app/models/katello/repository_erratum.rb +0 -2
- data/app/models/katello/repository_file.rb +0 -2
- data/app/models/katello/repository_ostree_branch.rb +0 -2
- data/app/models/katello/repository_package_group.rb +0 -1
- data/app/models/katello/repository_puppet_module.rb +0 -2
- data/app/models/katello/repository_rpm.rb +0 -2
- data/app/models/katello/rpm.rb +2 -2
- data/app/models/katello/subscription_facet_activation_key.rb +0 -2
- data/app/models/katello/subscription_facet_pool.rb +6 -0
- data/app/models/katello/subscription_product.rb +0 -1
- data/app/models/katello/sync_plan.rb +0 -2
- data/app/models/katello/task_status.rb +2 -4
- data/app/models/setting/content.rb +2 -0
- data/app/services/katello/candlepin/consumer.rb +1 -2
- data/app/services/katello/candlepin/message_handler.rb +88 -0
- data/app/services/katello/repository_type_manager.rb +1 -1
- data/app/views/dashboard/_content_views_widget.html.erb +2 -2
- data/app/views/dashboard/_errata_widget.html.erb +3 -3
- data/app/views/foreman/smart_proxies/_content_sync.html.erb +25 -8
- data/app/views/foreman/unattended/kickstart-katello-atomic.erb +1 -1
- data/app/views/foreman/unattended/kickstart-katello.erb +1 -1
- data/app/views/katello/api/v2/common/_org_reference.json.rabl +1 -0
- data/app/views/katello/api/v2/content_facet/base.json.rabl +3 -14
- data/app/views/katello/api/v2/products/base.json.rabl +1 -1
- data/app/views/katello/api/v2/repositories/base.json.rabl +1 -1
- data/app/views/katello/api/v2/repository_sets/show.json.rabl +8 -1
- data/app/views/katello/api/v2/subscriptions/base.json.rabl +0 -7
- data/app/views/katello/api/v2/subscriptions/show.json.rabl +4 -37
- data/config/routes/overrides.rb +1 -0
- data/db/migrate/20140422000001_update_products_add_organization.rb +1 -1
- data/db/migrate/20140610154745_content_view_puppet_environment_id.rb +1 -1
- data/db/migrate/20140626204657_add_unlimited_to_activation_keys.rb +1 -1
- data/db/migrate/20140626204902_add_unlimited_to_host_collection.rb +1 -1
- data/db/migrate/20141209103005_disown_foreman_templates.rb +1 -1
- data/db/migrate/20150901213759_remove_distributors.rb +1 -1
- data/db/migrate/20150908222711_drop_marketing_engineering_products.rb +1 -1
- data/db/migrate/20150930183738_migrate_content_hosts.rb +20 -20
- data/db/migrate/20151014144004_host_collection_to_hosts.rb +5 -5
- data/db/migrate/20160114200145_add_mirror_on_sync_to_repositories.rb +1 -1
- data/db/migrate/20160131182301_add_download_policy_to_katello_repositories.rb +1 -1
- data/db/migrate/20160222143432_move_system_description_to_host.rb +2 -2
- data/db/migrate/20160404132250_remove_katello_from_notification_name.rb +1 -1
- data/db/migrate/20160426145517_move_host_description_to_host_comment.rb +1 -1
- data/db/migrate/20160617124149_remove_duplicate_view_filters.rb +4 -4
- data/db/migrate/20160619223332_fix_viewer_role.rb +4 -4
- data/db/migrate/20160701180402_add_sortable_version_to_puppet_modules.rb +1 -1
- data/db/migrate/20160924213020_change_katello_widget_names.rb +1 -1
- data/db/migrate/20161014133811_move_content_view_version_description_to_histories.rb +2 -2
- data/db/migrate/20161026191118_fix_invalid_interfaces.rb +1 -1
- data/db/migrate/20170321012632_fill_in_content_view_components.rb +3 -3
- data/db/migrate/20170718142148_create_katello_subscription_facet_pools.rb +15 -0
- data/db/migrate/20170821170915_add_index_to_installed_packages.rb +5 -0
- data/db/migrate/20170821170916_add_nvra_index_to_installed_packages.rb +5 -0
- data/db/migrate/20170913183848_add_errata_counts.rb +23 -0
- data/db/seeds.d/101-locations.rb +2 -2
- data/db/seeds.d/102-organizations.rb +3 -3
- data/db/seeds.d/103-provisioning_templates.rb +29 -31
- data/db/seeds.d/104-proxy.rb +10 -12
- data/db/seeds.d/106-mail_notifications.rb +30 -32
- data/db/seeds.d/107-enable_dynflow.rb +3 -4
- data/db/seeds.d/108-subcription-bookmarks.rb +12 -10
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/activation-keys.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/new/views/activation-key-new.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/architectures/architecture.factory.js +15 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/architectures/architectures.module.js +14 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion-katello-bootstrap.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/bastion_katello.js +3 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-repository-sets-modal.controller.js +107 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-repository-sets-modal.html +113 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts-helper.service.js +13 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +25 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details-info.controller.js +4 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +15 -12
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-repository-sets.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/views/content-hosts.html +11 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/views/version-deletion-activation-keys.html +15 -12
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/deletion/views/version-deletion-content-hosts.html +16 -12
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +9 -6
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/errata-counts.html +6 -12
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/errata.html +4 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/hosts/host-bulk-action.factory.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/packages/views/packages.html +5 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +20 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +9 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +22 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +17 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/products.module.js +1 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/repository-sets/repository-set.factory.js +16 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-details.controller.js +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-details.html +0 -19
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-info.html +31 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/subscriptions.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/views/tasks-table.html +6 -3
- data/lib/katello/permissions/host_permissions.rb +1 -0
- data/lib/katello/plugin.rb +7 -5
- data/lib/katello/tasks/clean_installed_packages.rake +54 -0
- data/lib/katello/tasks/import_subscriptions.rake +8 -0
- data/lib/katello/tasks/{setup.rake → reset.rake} +10 -0
- data/lib/katello/tasks/test.rake +18 -0
- data/lib/katello/version.rb +1 -1
- data/vendor/assets/stylesheets/katello/{jquery-ui-1.8.11.custom.css → jquery-ui-1.8.11.custom.css.scss} +0 -0
- data/vendor/assets/stylesheets/katello/{jquery.loadmask.css → jquery.loadmask.css.scss} +0 -0
- data/vendor/assets/stylesheets/katello/{jquery.treeTable.scss → jquery.treeTable.css.scss} +0 -0
- data/vendor/assets/stylesheets/katello/{ui.spinner.css → ui.spinner.css.scss} +0 -0
- metadata +43 -21
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-activation-keys.controller.js +0 -30
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-content-hosts.controller.js +0 -45
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-activation-keys.html +0 -48
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-content-hosts.html +0 -62
- data/lib/katello/tasks/upgrades/2.4/import_subscriptions.rake +0 -12
- data/lib/katello/tasks/upgrades/3.3/import_subscriptions.rake +0 -12
|
@@ -11,11 +11,11 @@ module Actions
|
|
|
11
11
|
owner: repository.product.organization.label,
|
|
12
12
|
name: repository.name,
|
|
13
13
|
type: repository.content_type,
|
|
14
|
+
arches: repository.arch == "noarch" ? nil : repository.arch,
|
|
14
15
|
label: repository.custom_content_label,
|
|
15
16
|
content_url: content_url(repository))
|
|
16
17
|
content_id = content_create.output[:response][:id]
|
|
17
|
-
plan_action(Candlepin::Product::ContentAdd,
|
|
18
|
-
owner: repository.product.organization.label,
|
|
18
|
+
plan_action(Candlepin::Product::ContentAdd, owner: repository.product.organization.label,
|
|
19
19
|
product_id: repository.product.cp_id,
|
|
20
20
|
content_id: content_id)
|
|
21
21
|
|
|
@@ -29,13 +29,13 @@ module Actions
|
|
|
29
29
|
content_id: content_id,
|
|
30
30
|
name: repository.name,
|
|
31
31
|
type: repository.content_type,
|
|
32
|
+
arches: repository.arch == "noarch" ? "" : repository.arch,
|
|
32
33
|
label: repository.custom_content_label,
|
|
33
34
|
content_url: content_url(repository),
|
|
34
35
|
gpg_key_url: repository.yum_gpg_key_url)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
plan_self(repository_id: repository.id,
|
|
38
|
-
content_id: content_id)
|
|
38
|
+
plan_self(repository_id: repository.id, content_id: content_id)
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -2,27 +2,29 @@ module Actions
|
|
|
2
2
|
module Katello
|
|
3
3
|
module Product
|
|
4
4
|
class Create < Actions::EntryAction
|
|
5
|
-
def plan(product, organization)
|
|
5
|
+
def plan(product, organization, subscription_start = nil)
|
|
6
6
|
sequence do
|
|
7
7
|
product.provider = organization.anonymous_provider
|
|
8
8
|
product.organization = organization
|
|
9
|
+
product.setup_label_from_name
|
|
10
|
+
product.cp_id = ::Katello::Product.unused_product_id
|
|
11
|
+
product.save!
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cp_id = cp_create.output[:response][:id]
|
|
13
|
+
plan_action(::Actions::Candlepin::Product::Create,
|
|
14
|
+
:owner => product.organization.label,
|
|
15
|
+
:name => product.name,
|
|
16
|
+
:id => product.cp_id,
|
|
17
|
+
:multiplier => 1,
|
|
18
|
+
:attributes => [{:name => "arch", :value => "ALL"}])
|
|
17
19
|
|
|
18
20
|
sub_create = plan_action(::Actions::Candlepin::Product::CreateUnlimitedSubscription,
|
|
19
21
|
:owner_key => organization.label,
|
|
20
|
-
:product_id => cp_id
|
|
22
|
+
:product_id => product.cp_id,
|
|
23
|
+
:start_time => subscription_start)
|
|
21
24
|
|
|
22
25
|
subscription_id = sub_create.output[:response][:id]
|
|
23
26
|
|
|
24
|
-
product.
|
|
25
|
-
action_subject product, :cp_id => cp_id
|
|
27
|
+
action_subject product, :cp_id => product.cp_id
|
|
26
28
|
|
|
27
29
|
plan_self
|
|
28
30
|
plan_action Katello::Product::ReindexSubscriptions, product, subscription_id
|
|
@@ -26,7 +26,6 @@ module Actions
|
|
|
26
26
|
pulp_sync_options = {}
|
|
27
27
|
pulp_sync_options[:download_policy] = ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND if validate_contents
|
|
28
28
|
pulp_sync_options[:force_full] = true if skip_metadata_check
|
|
29
|
-
pulp_sync_options[:auto_publish] = false if skip_metadata_check #skip auto publish, and force it later
|
|
30
29
|
pulp_sync_options[:remove_missing] = false if incremental
|
|
31
30
|
|
|
32
31
|
fail ::Katello::Errors::InvalidActionOptionError, _("Unable to sync repo. This repository does not have a feed url.") if repo.url.blank? && source_url.blank?
|
|
@@ -18,7 +18,8 @@ module Actions
|
|
|
18
18
|
:content_url => ::Katello::Glue::Pulp::Repos.custom_content_path(repository.product, repository.label),
|
|
19
19
|
:gpg_key_url => repository.yum_gpg_key_url,
|
|
20
20
|
:label => repository.content.label,
|
|
21
|
-
:type => repository.content_type
|
|
21
|
+
:type => repository.content_type,
|
|
22
|
+
:arches => repository.arch == "noarch" ? nil : repository.arch)
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
if SETTINGS[:katello][:use_pulp] && repository.pulp_update_needed?
|
|
@@ -7,7 +7,11 @@ module Actions
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def invoke_external_task
|
|
10
|
-
|
|
10
|
+
if input[:uuids].length == 1
|
|
11
|
+
pulp_resources.consumer.regenerate_applicability_by_id(input[:uuids].first)
|
|
12
|
+
else
|
|
13
|
+
pulp_extensions.consumer.regenerate_applicability_by_ids(input[:uuids])
|
|
14
|
+
end
|
|
11
15
|
end
|
|
12
16
|
end
|
|
13
17
|
end
|
|
@@ -92,6 +92,7 @@ module Actions
|
|
|
92
92
|
importer.ssl_client_cert = input[:ssl_client_cert]
|
|
93
93
|
importer.ssl_client_key = input[:ssl_client_key]
|
|
94
94
|
importer.ssl_validation = input[:ssl_validation]
|
|
95
|
+
importer.remove_missing = input[:mirror_on_sync]
|
|
95
96
|
importer.basic_auth_username = input[:upstream_username] if input[:upstream_username].present?
|
|
96
97
|
importer.basic_auth_password = input[:upstream_password] if input[:upstream_password].present?
|
|
97
98
|
importer
|
|
@@ -7,11 +7,11 @@ module Actions
|
|
|
7
7
|
def plan(input)
|
|
8
8
|
plan_self(input)
|
|
9
9
|
pulp_extensions.repository.create_with_importer_and_distributors(input[:pulp_id],
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
importer,
|
|
11
|
+
distributors,
|
|
12
|
+
display_name: input[:name])
|
|
13
13
|
rescue => e
|
|
14
|
-
raise error_message(e.http_body) || e
|
|
14
|
+
raise e.try(:http_body) ? error_message(e.http_body) || e : e
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def error_message(body)
|
|
@@ -33,7 +33,7 @@ module Actions
|
|
|
33
33
|
sync_options.merge!(input[:options]) if input[:options]
|
|
34
34
|
|
|
35
35
|
output[:pulp_tasks] = pulp_tasks =
|
|
36
|
-
|
|
36
|
+
[pulp_resources.repository.sync(input[:pulp_id], override_config: sync_options)]
|
|
37
37
|
|
|
38
38
|
pulp_tasks
|
|
39
39
|
end
|
|
@@ -55,7 +55,7 @@ module Katello
|
|
|
55
55
|
logger.error "Remote server status code " << resp.code.to_s
|
|
56
56
|
raise RestClientException, {:message => error.to_s, :service_code => service_code, :code => status_code}, caller
|
|
57
57
|
else
|
|
58
|
-
raise NetworkException, [resp.code.to_s, resp.body].reject { |s| s.
|
|
58
|
+
raise NetworkException, [resp.code.to_s, resp.body].reject { |s| s.blank? }.join(' ')
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
fail RestClientException, {:message => message, :service_code => service_code, :code => status_code}, caller
|
|
@@ -105,7 +105,7 @@ module Katello
|
|
|
105
105
|
|
|
106
106
|
def lazy_attribute_will_change!(attr)
|
|
107
107
|
changed_remote_attributes[attr.to_s] ||=
|
|
108
|
-
|
|
108
|
+
instance_variable_get("@#{attr}").nil? ? remote_attribute_value(attr) : instance_variable_get("@#{attr}")
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def lazy_attribute_change(attr)
|
|
@@ -158,7 +158,7 @@ module Katello
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
def available_pools(owner_label, uuid, listall = false)
|
|
161
|
-
url = Pool.path(nil, owner_label) + "?consumer=#{uuid}&listall=#{listall}"
|
|
161
|
+
url = Pool.path(nil, owner_label) + "?consumer=#{uuid}&listall=#{listall}&add_future=true"
|
|
162
162
|
response = Candlepin::CandlepinResource.get(url, self.default_headers).body
|
|
163
163
|
JSON.parse(response)
|
|
164
164
|
end
|
|
@@ -707,7 +707,7 @@ module Katello
|
|
|
707
707
|
self.delete(join_path(path(owner_label, product_id), "content/#{content_id}"), self.default_headers).code.to_i
|
|
708
708
|
end
|
|
709
709
|
|
|
710
|
-
def create_unlimited_subscription(owner_key, product_id)
|
|
710
|
+
def create_unlimited_subscription(owner_key, product_id, start_date)
|
|
711
711
|
start_date ||= Time.now
|
|
712
712
|
# End it 100 years from now
|
|
713
713
|
end_date ||= start_date + 10_950.days
|
|
@@ -5,6 +5,12 @@ module Katello
|
|
|
5
5
|
variable.map { |x| x.with_indifferent_access }
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
def self.md5hash(string)
|
|
9
|
+
md5 = Digest::MD5.new
|
|
10
|
+
md5.update(string)
|
|
11
|
+
md5.hexdigest
|
|
12
|
+
end
|
|
13
|
+
|
|
8
14
|
def self.ostructize(obj, options = {})
|
|
9
15
|
options[:prefix_keys] ||= []
|
|
10
16
|
options[:prefix] ||= '_'
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
module Katello
|
|
2
2
|
class ActivationKey < Katello::Model
|
|
3
|
-
self.include_root_in_json = false
|
|
4
|
-
|
|
5
3
|
include Glue::Candlepin::ActivationKey if SETTINGS[:katello][:use_cp]
|
|
6
4
|
include Glue if SETTINGS[:katello][:use_cp]
|
|
7
5
|
include Katello::Authorization::ActivationKey
|
|
8
6
|
include ForemanTasks::Concerns::ActionSubject
|
|
7
|
+
include ScopedSearchExtensions
|
|
9
8
|
|
|
10
9
|
belongs_to :organization, :inverse_of => :activation_keys
|
|
11
10
|
belongs_to :environment, :class_name => "KTEnvironment", :inverse_of => :activation_keys
|
|
@@ -16,6 +15,7 @@ module Katello
|
|
|
16
15
|
has_many :host_collections, :through => :key_host_collections
|
|
17
16
|
|
|
18
17
|
has_many :pools, :through => :pool_activation_keys, :class_name => "Katello::Pool"
|
|
18
|
+
has_many :subscriptions, :through => :pools
|
|
19
19
|
has_many :pool_activation_keys, :class_name => "Katello::PoolActivationKey", :dependent => :destroy, :inverse_of => :activation_key
|
|
20
20
|
has_many :subscription_facet_activation_keys, :class_name => "Katello::SubscriptionFacetActivationKey", :dependent => :destroy
|
|
21
21
|
has_many :subscription_facets, :through => :subscription_facet_activation_keys
|
|
@@ -54,6 +54,8 @@ module Katello
|
|
|
54
54
|
scoped_search :rename => :content_view, :on => :name, :relation => :content_view, :complete_value => true
|
|
55
55
|
scoped_search :on => :content_view_id, :complete_value => true, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
|
|
56
56
|
scoped_search :on => :description, :complete_value => true
|
|
57
|
+
scoped_search :on => :name, :relation => :subscriptions, :rename => :subscription_name, :complete_value => true, :ext_method => :find_by_subscription_name
|
|
58
|
+
scoped_search :on => :id, :relation => :subscriptions, :rename => :subscription_id, :complete_value => true, :ext_method => :find_by_subscription_id
|
|
57
59
|
|
|
58
60
|
def environment_exists
|
|
59
61
|
if environment_id && environment.nil?
|
|
@@ -79,10 +81,6 @@ module Katello
|
|
|
79
81
|
end
|
|
80
82
|
end
|
|
81
83
|
|
|
82
|
-
def subscriptions
|
|
83
|
-
self.pools
|
|
84
|
-
end
|
|
85
|
-
|
|
86
84
|
def available_subscriptions
|
|
87
85
|
all_pools = self.get_pools.map { |pool| pool["id"] }
|
|
88
86
|
added_pools = self.pools.pluck(:cp_id)
|
|
@@ -105,7 +103,7 @@ module Katello
|
|
|
105
103
|
end
|
|
106
104
|
|
|
107
105
|
def all_products
|
|
108
|
-
|
|
106
|
+
organization.products.enabled.uniq
|
|
109
107
|
end
|
|
110
108
|
|
|
111
109
|
def available_content(content_access_mode_all = false, content_access_mode_env = false)
|
|
@@ -170,6 +168,26 @@ module Katello
|
|
|
170
168
|
_("Activation Keys")
|
|
171
169
|
end
|
|
172
170
|
|
|
171
|
+
def self.find_by_subscription_name(_key, operator, value)
|
|
172
|
+
conditions = sanitize_sql_for_conditions(["#{Katello::Subscription.table_name}.name #{operator} ?", value_to_sql(operator, value)])
|
|
173
|
+
activation_keys = ::Katello::ActivationKey.joins(pools: :subscription).where(conditions)
|
|
174
|
+
return_activation_keys_by_id(activation_keys.pluck(:id))
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def self.find_by_subscription_id(_key, operator, value)
|
|
178
|
+
conditions = sanitize_sql_for_conditions(["#{Katello::Subscription.table_name}.id #{operator} ?", value_to_sql(operator, value)])
|
|
179
|
+
activation_keys = ::Katello::ActivationKey.joins(pools: :subscription).where(conditions)
|
|
180
|
+
return_activation_keys_by_id(activation_keys.pluck(:id))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def self.return_activation_keys_by_id(activation_key_ids)
|
|
184
|
+
if activation_key_ids.empty?
|
|
185
|
+
{:conditions => "1=0"}
|
|
186
|
+
else
|
|
187
|
+
{:conditions => "#{Katello::ActivationKey.table_name}.id IN (#{activation_key_ids.join(',')})"}
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
173
191
|
private
|
|
174
192
|
|
|
175
193
|
def set_default_content_view
|
|
@@ -7,7 +7,6 @@ module Katello
|
|
|
7
7
|
|
|
8
8
|
included do
|
|
9
9
|
alias_method_chain :validate_media?, :capsule
|
|
10
|
-
alias_method_chain :info, :katello
|
|
11
10
|
alias_method_chain :smart_proxy_ids, :katello
|
|
12
11
|
|
|
13
12
|
has_many :host_installed_packages, :class_name => "::Katello::HostInstalledPackage", :foreign_key => :host_id, :dependent => :destroy
|
|
@@ -46,19 +45,6 @@ module Katello
|
|
|
46
45
|
ids.uniq.compact
|
|
47
46
|
end
|
|
48
47
|
|
|
49
|
-
def info_with_katello
|
|
50
|
-
info = info_without_katello
|
|
51
|
-
info['parameters']['kt_env'] = self.lifecycle_environment.try(:label) #deprecated
|
|
52
|
-
info['parameters']['kt_cv'] = self.content_view.try(:label) #deprecated
|
|
53
|
-
info['parameters']['lifecycle_environment'] = self.lifecycle_environment.try(:label)
|
|
54
|
-
info['parameters']['content_view'] = self.content_view.try(:label)
|
|
55
|
-
info['parameters']['foreman_host_collections'] = self.host_collections.map(&:name)
|
|
56
|
-
if self.content_facet.present?
|
|
57
|
-
info['parameters']['kickstart_repository'] = self.content_facet.kickstart_repository.try(:label)
|
|
58
|
-
end
|
|
59
|
-
info
|
|
60
|
-
end
|
|
61
|
-
|
|
62
48
|
def correct_puppet_environment
|
|
63
49
|
if content_and_puppet_matched?
|
|
64
50
|
new_environment = content_facet.content_view.puppet_env(content_facet.lifecycle_environment).try(:puppet_environment)
|
|
@@ -77,10 +63,67 @@ module Katello
|
|
|
77
63
|
end
|
|
78
64
|
|
|
79
65
|
def import_package_profile(simple_packages)
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
if Setting[:bulk_query_installed_packages]
|
|
67
|
+
#this method is slow if the clean_installed_packages rake task has not been run, but faster if it has
|
|
68
|
+
found = import_package_profile_in_bulk(simple_packages)
|
|
69
|
+
else
|
|
70
|
+
found = import_package_profile_individually(simple_packages)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
sync_package_associations(found.map(&:id))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def import_package_profile_in_bulk(simple_packages)
|
|
77
|
+
nvras = simple_packages.map { |sp| sp.nvra }
|
|
78
|
+
found = InstalledPackage.where(:nvra => nvras).select(:id, :nvra)
|
|
79
|
+
found_nvras = found.map(&:nvra)
|
|
80
|
+
new_packages = simple_packages.select { |sp| !found_nvras.include?(sp.nvra) }
|
|
81
|
+
|
|
82
|
+
new_packages.each do |simple_package|
|
|
83
|
+
::Katello::Util::Support.active_record_retry do
|
|
84
|
+
found << InstalledPackage.where(:nvra => simple_package.nvra, :name => simple_package.name).first_or_create!
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
found
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def import_package_profile_individually(simple_packages)
|
|
91
|
+
found = []
|
|
82
92
|
simple_packages.each do |simple_package|
|
|
83
|
-
|
|
93
|
+
::Katello::Util::Support.active_record_retry do
|
|
94
|
+
#use limit(1)[0] here to avoid a sort by id
|
|
95
|
+
pkg = InstalledPackage.where(:nvra => simple_package.nvra, :name => simple_package.name).limit(1)[0]
|
|
96
|
+
if pkg.nil?
|
|
97
|
+
pkg = InstalledPackage.create!(:nvra => simple_package.nvra, :name => simple_package.name)
|
|
98
|
+
end
|
|
99
|
+
found << pkg
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
found
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def sync_package_associations(new_installed_package_ids)
|
|
106
|
+
old_associated_ids = self.installed_package_ids
|
|
107
|
+
table_name = self.host_installed_packages.table_name
|
|
108
|
+
|
|
109
|
+
new_ids = new_installed_package_ids - old_associated_ids
|
|
110
|
+
delete_ids = old_associated_ids - new_installed_package_ids
|
|
111
|
+
|
|
112
|
+
queries = []
|
|
113
|
+
|
|
114
|
+
if delete_ids.any?
|
|
115
|
+
queries << "DELETE FROM #{table_name} WHERE host_id=#{self.id} AND installed_package_id IN (#{delete_ids.join(', ')})"
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
unless new_ids.empty?
|
|
119
|
+
inserts = new_ids.map { |unit_id| "(#{unit_id.to_i}, #{self.id.to_i})" }
|
|
120
|
+
queries << "INSERT INTO #{table_name} (installed_package_id, host_id) VALUES #{inserts.join(', ')}"
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
ActiveRecord::Base.transaction do
|
|
124
|
+
queries.each do |query|
|
|
125
|
+
ActiveRecord::Base.connection.execute(query)
|
|
126
|
+
end
|
|
84
127
|
end
|
|
85
128
|
end
|
|
86
129
|
|
|
@@ -15,6 +15,8 @@ module Katello
|
|
|
15
15
|
accepts_nested_attributes_for :subscription_facet, :update_only => true, :reject_if => lambda { |attrs| attrs.values.compact.empty? }
|
|
16
16
|
|
|
17
17
|
has_many :activation_keys, :through => :subscription_facet
|
|
18
|
+
has_many :pools, :through => :subscription_facet
|
|
19
|
+
has_many :subscriptions, :through => :pools
|
|
18
20
|
has_one :subscription_status_object, :class_name => 'Katello::SubscriptionStatus', :foreign_key => 'host_id'
|
|
19
21
|
has_one :hypervisor_host, :through => :subscription_facet
|
|
20
22
|
|
|
@@ -33,6 +35,8 @@ module Katello
|
|
|
33
35
|
:only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
|
|
34
36
|
scoped_search :on => :hypervisor, :relation => :subscription_facet, :complete_value => true
|
|
35
37
|
scoped_search :on => :name, :relation => :hypervisor_host, :complete_value => true, :rename => :hypervisor_host, :ext_method => :find_by_hypervisor_host
|
|
38
|
+
scoped_search :on => :name, :relation => :subscriptions, :rename => :subscription_name, :complete_value => true, :ext_method => :find_by_subscription_name
|
|
39
|
+
scoped_search :on => :id, :relation => :pools, :rename => :subscription_id, :complete_value => true, :ext_method => :find_by_subscription_id
|
|
36
40
|
end
|
|
37
41
|
|
|
38
42
|
def update_action
|
|
@@ -45,28 +49,45 @@ module Katello
|
|
|
45
49
|
def find_by_activation_key(_key, operator, value)
|
|
46
50
|
conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.name #{operator} ?", value_to_sql(operator, value)])
|
|
47
51
|
hosts = ::Host::Managed.joins(:activation_keys).where(conditions)
|
|
48
|
-
|
|
49
|
-
{ :conditions => "1=0" }
|
|
50
|
-
else
|
|
51
|
-
{ :conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.pluck(:id).join(',')})" }
|
|
52
|
-
end
|
|
52
|
+
return_hosts(hosts)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def find_by_activation_key_id(_key, operator, value)
|
|
56
56
|
conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.id #{operator} ?", value_to_sql(operator, value)])
|
|
57
57
|
hosts = ::Host::Managed.joins(:activation_keys).where(conditions)
|
|
58
|
-
|
|
59
|
-
{ :conditions => "1=0" }
|
|
60
|
-
else
|
|
61
|
-
{ :conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.pluck(:id).join(',')})" }
|
|
62
|
-
end
|
|
58
|
+
return_hosts(hosts)
|
|
63
59
|
end
|
|
64
60
|
|
|
65
61
|
def find_by_hypervisor_host(_key, operator, value)
|
|
66
62
|
conditions = sanitize_sql_for_conditions(["#{::Host.table_name}.name #{operator} ?", value_to_sql(operator, value)])
|
|
67
63
|
hosts = ::Host.where(conditions)
|
|
68
64
|
hosts = ::Host.joins(:subscription_facet).where("#{Katello::Host::SubscriptionFacet.table_name}.hypervisor_host_id" => hosts)
|
|
65
|
+
return_hosts(hosts)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def find_by_subscription_name(_key, operator, value)
|
|
69
|
+
conditions = sanitize_sql_for_conditions(["#{Katello::Subscription.table_name}.name #{operator} ?", value_to_sql(operator, value)])
|
|
70
|
+
sub_facets = ::Katello::Host::SubscriptionFacet.joins(pools: :subscription).where(conditions)
|
|
71
|
+
host_ids = sub_facets.select(:host_id)
|
|
72
|
+
return_hosts_by_id(host_ids)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def find_by_subscription_id(_key, operator, value)
|
|
76
|
+
conditions = sanitize_sql_for_conditions(["#{Katello::Pool.table_name}.id #{operator} ?", value_to_sql(operator, value)])
|
|
77
|
+
sub_facets = ::Katello::Host::SubscriptionFacet.joins(:pools).where(conditions)
|
|
78
|
+
host_ids = sub_facets.select(:host_id)
|
|
79
|
+
return_hosts_by_id(host_ids)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def return_hosts_by_id(host_ids)
|
|
83
|
+
if host_ids.empty?
|
|
84
|
+
{:conditions => "1=0"}
|
|
85
|
+
else
|
|
86
|
+
{:conditions => "#{::Host::Managed.table_name}.id IN (#{host_ids.to_sql})"}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
69
89
|
|
|
90
|
+
def return_hosts(hosts)
|
|
70
91
|
if hosts.empty?
|
|
71
92
|
{:conditions => "1=0"}
|
|
72
93
|
else
|