katello 4.1.4 → 4.2.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of katello might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb +2 -2
- data/app/controllers/katello/api/v2/content_credentials_controller.rb +3 -3
- data/app/controllers/katello/api/v2/content_uploads_controller.rb +3 -1
- data/app/controllers/katello/api/v2/content_view_components_controller.rb +33 -1
- data/app/controllers/katello/api/v2/content_views_controller.rb +12 -0
- data/app/controllers/katello/api/v2/host_errata_controller.rb +1 -1
- data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +1 -2
- data/app/controllers/katello/api/v2/products_controller.rb +4 -4
- data/app/controllers/katello/api/v2/repositories_bulk_actions_controller.rb +3 -11
- data/app/controllers/katello/api/v2/repositories_controller.rb +68 -47
- data/app/controllers/katello/api/v2/upstream_subscriptions_controller.rb +0 -28
- data/app/controllers/katello/concerns/api/v2/registration_commands_controller_extensions.rb +26 -5
- data/app/controllers/katello/concerns/api/v2/registration_controller_extensions.rb +26 -1
- data/app/lib/actions/candlepin/environment/destroy.rb +2 -0
- data/app/lib/actions/katello/agent_action.rb +2 -2
- data/app/lib/actions/katello/capsule_content/sync_capsule.rb +3 -2
- data/app/lib/actions/katello/{gpg_key → content_credential}/update.rb +1 -1
- data/app/lib/actions/katello/content_view/publish.rb +6 -1
- data/app/lib/actions/katello/content_view_version/create_repos.rb +1 -1
- data/app/lib/actions/katello/content_view_version/incremental_update.rb +0 -47
- data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +1 -1
- data/app/lib/actions/katello/repository/clone_contents.rb +1 -7
- data/app/lib/actions/katello/repository/clone_to_environment.rb +1 -7
- data/app/lib/actions/katello/repository/create.rb +4 -8
- data/app/lib/actions/katello/repository/create_root.rb +1 -1
- data/app/lib/actions/katello/repository/destroy.rb +1 -3
- data/app/lib/actions/katello/repository/import_upload.rb +3 -2
- data/app/lib/actions/katello/repository/instance_update.rb +1 -1
- data/app/lib/actions/katello/repository/metadata_generate.rb +2 -8
- data/app/lib/actions/katello/repository/multi_clone_contents.rb +0 -1
- data/app/lib/actions/katello/repository/refresh_repository.rb +1 -4
- data/app/lib/actions/katello/repository/remove_content.rb +6 -4
- data/app/lib/actions/katello/repository/sync.rb +5 -25
- data/app/lib/actions/katello/repository/update.rb +1 -2
- data/app/lib/actions/katello/repository/update_http_proxy_details.rb +2 -5
- data/app/lib/actions/katello/repository/update_redhat_repository.rb +1 -1
- data/app/lib/actions/katello/repository/upload_files.rb +8 -3
- data/app/lib/actions/katello/repository/upload_package_group.rb +2 -11
- data/app/lib/actions/katello/repository/verify_checksum.rb +0 -1
- data/app/lib/actions/katello/repository_set/enable_repository.rb +1 -1
- data/app/lib/actions/pulp3/orchestration/repository/create.rb +2 -2
- data/app/lib/actions/pulp3/repository/create.rb +3 -4
- data/app/lib/actions/pulp3/repository/create_remote.rb +1 -6
- data/app/lib/actions/pulp3/repository/repair.rb +4 -0
- data/app/lib/katello/errors.rb +1 -0
- data/app/lib/katello/http_resource.rb +26 -73
- data/app/lib/katello/qpid/connection.rb +1 -3
- data/app/lib/katello/resources/candlepin/consumer.rb +1 -1
- data/app/lib/katello/resources/candlepin/environment.rb +2 -0
- data/app/lib/katello/resources/registry.rb +7 -20
- data/app/lib/katello/util/http_proxy.rb +0 -3
- data/app/lib/katello/validators/gpg_key_content_validator.rb +1 -1
- data/app/models/katello/authorization/{gpg_key.rb → content_credential.rb} +1 -1
- data/app/models/katello/authorization/product.rb +0 -4
- data/app/models/katello/concerns/host_managed_extensions.rb +2 -16
- data/app/models/katello/concerns/organization_extensions.rb +1 -1
- data/app/models/katello/concerns/pulp_database_unit.rb +13 -5
- data/app/models/katello/concerns/smart_proxy_extensions.rb +45 -41
- data/app/models/katello/{gpg_key.rb → content_credential.rb} +4 -4
- data/app/models/katello/content_view.rb +6 -1
- data/app/models/katello/generic_content_unit.rb +16 -0
- data/app/models/katello/glue/pulp/repos.rb +9 -25
- data/app/models/katello/kt_environment.rb +1 -1
- data/app/models/katello/product.rb +4 -4
- data/app/models/katello/repository.rb +13 -7
- data/app/models/katello/repository_generic_content_unit.rb +7 -0
- data/app/models/katello/root_repository.rb +38 -7
- data/app/models/setting/content.rb +5 -0
- data/app/services/cert/certs.rb +16 -8
- data/app/services/katello/applicability/applicable_content_helper.rb +1 -2
- data/app/services/katello/candlepin/consumer.rb +6 -0
- data/app/services/katello/component_view_presenter.rb +27 -0
- data/app/services/katello/pulp/repository.rb +1 -1
- data/app/services/katello/pulp/server.rb +2 -2
- data/app/services/katello/pulp3/api/core.rb +4 -0
- data/app/services/katello/pulp3/api/generic.rb +68 -0
- data/app/services/katello/pulp3/generic_content_unit.rb +29 -0
- data/app/services/katello/pulp3/pulp_content_unit.rb +5 -1
- data/app/services/katello/pulp3/repository/generic.rb +94 -0
- data/app/services/katello/pulp3/repository/yum.rb +4 -5
- data/app/services/katello/pulp3/repository.rb +27 -12
- data/app/services/katello/pulp3/repository_mirror.rb +2 -2
- data/app/services/katello/pulp3/smart_proxy_repository.rb +4 -4
- data/app/services/katello/registration_manager.rb +18 -7
- data/app/services/katello/repository_type.rb +59 -1
- data/app/services/katello/repository_type_manager.rb +116 -24
- data/app/views/katello/api/v2/content_views/base.json.rabl +4 -4
- data/app/views/katello/api/v2/repositories/show.json.rabl +1 -0
- data/app/views/smart_proxies/plugins/_pulpcore.html.erb +2 -5
- data/app/views/smart_proxies/pulp_status.html.erb +0 -7
- data/config/katello.yaml.example +0 -21
- data/config/routes/api/v2.rb +2 -1
- data/db/functions/deb_version_cmp_v01.sql +200 -0
- data/db/migrate/20171110082124_add_ssl_certs_to_products_and_repos.rb +5 -1
- data/db/migrate/20200402130013_add_repsoitory_docker_meta_tag_f_key.rb +3 -1
- data/db/migrate/20210624221630_katello_generic_content.rb +22 -0
- data/db/migrate/20210625095042_add_retain_package_versions_count.rb +9 -0
- data/db/migrate/20210628182553_add_generic_remote_options_to_root_repository.rb +5 -0
- data/db/migrate/20210714140440_remove_repo_export_permission.rb +5 -0
- data/db/migrate/20210721163730_change_gpg_keys_to_content_credentials.rb +8 -0
- data/db/migrate/20210728130748_create_function_deb_version_cmp.rb +12 -0
- data/db/seeds.d/111-upgrade_tasks.rb +1 -2
- data/engines/bastion/app/views/bastion/layouts/assets.html.erb +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/capsule-content/capsule-content.controller.js +7 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-errata-modal.html +4 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/apply-errata.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/apply-errata-confirm.html +2 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +25 -33
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/bulk/views/products-bulk-advanced-sync-modal.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/product-repositories.controller.js +1 -6
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.controller.js +10 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details-info.filter.js +9 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/repository-details.controller.js +0 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-advanced-sync-options.html +1 -25
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-details.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-info.html +31 -13
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/views/new-repository.html +11 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/views/product-repositories.html +0 -6
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/aggregate-task.factory.js +3 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/tasks/task.factory.js +1 -1
- data/lib/katello/engine.rb +2 -4
- data/lib/katello/permission_creator.rb +6 -12
- data/lib/katello/plugin.rb +76 -80
- data/lib/katello/repository_types/python.rb +37 -0
- data/lib/katello/tasks/reimport.rake +0 -9
- data/lib/katello/tasks/repository.rake +3 -4
- data/lib/katello/version.rb +1 -1
- data/locale/action_names.rb +28 -29
- data/locale/bn/katello.po +699 -221
- data/locale/cs/katello.po +167 -59
- data/locale/de/katello.po +585 -352
- data/locale/en/katello.po +167 -59
- data/locale/es/katello.po +1388 -1189
- data/locale/fr/katello.po +1740 -1494
- data/locale/gu/katello.po +896 -416
- data/locale/hi/katello.po +892 -415
- data/locale/it/katello.po +371 -170
- data/locale/ja/katello.po +1657 -1439
- data/locale/katello.pot +933 -736
- data/locale/kn/katello.po +894 -416
- data/locale/ko/katello.po +515 -317
- data/locale/mr/katello.po +857 -415
- data/locale/or/katello.po +894 -416
- data/locale/pa/katello.po +874 -411
- data/locale/pt/katello.po +347 -154
- data/locale/pt_BR/katello.po +1398 -1215
- data/locale/ru/katello.po +671 -463
- data/locale/ta/katello.po +697 -221
- data/locale/te/katello.po +891 -415
- data/locale/zh_CN/katello.po +2029 -1845
- data/locale/zh_TW/katello.po +735 -407
- data/package.json +3 -1
- data/webpack/components/EditableTextInput/EditableTextInput.js +3 -3
- data/webpack/components/RoutedTabs/RoutedTabs.js +7 -8
- data/webpack/components/Table/TableWrapper.js +19 -11
- data/webpack/components/Table/helpers.js +1 -1
- data/webpack/components/extensions/HostDetails/Tabs/ContentTab.js +42 -0
- data/webpack/components/extensions/HostDetails/Tabs/SubscriptionTab.js +12 -0
- data/webpack/components/extensions/RegistrationCommands/__tests__/__snapshots__/ActivationKeys.test.js.snap +4 -0
- data/webpack/components/extensions/RegistrationCommands/fields/ActivationKeys.js +1 -1
- data/webpack/components/extensions/RegistrationCommands/index.js +1 -2
- data/webpack/components/pf3Table/formatters/selectionHeaderCellFormatter.js +2 -1
- data/webpack/fills_index.js +4 -1
- data/webpack/redux/actions/RedHatRepositories/helpers.js +2 -4
- data/webpack/redux/reducers/RedHatRepositories/enabled.js +4 -1
- data/webpack/scenes/ContentViews/ContentViewsActions.js +16 -1
- data/webpack/scenes/ContentViews/ContentViewsConstants.js +15 -0
- data/webpack/scenes/ContentViews/ContentViewsPage.js +12 -22
- data/webpack/scenes/ContentViews/Copy/CopyContentViewForm.js +4 -3
- data/webpack/scenes/ContentViews/Create/CreateContentViewForm.js +25 -14
- data/webpack/scenes/ContentViews/Create/CreateContentViewModal.js +4 -2
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentContentViewAddModal.js +153 -0
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/ComponentVersion.js +21 -10
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/ContentViewComponents.js +157 -19
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.fixtures.json +100 -108
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/contentViewComponents.test.js +140 -16
- data/webpack/scenes/ContentViews/Details/ComponentContentViews/__tests__/publishedContentViewDetails.fixtures.json +367 -0
- data/webpack/scenes/ContentViews/Details/ContentViewDetailActions.js +59 -6
- data/webpack/scenes/ContentViews/Details/ContentViewDetailSelectors.js +43 -0
- data/webpack/scenes/ContentViews/Details/ContentViewDetails.js +44 -13
- data/webpack/scenes/ContentViews/Details/Filters/Add/CVFilterAddModal.js +161 -0
- data/webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterAdd.test.js +54 -0
- data/webpack/scenes/ContentViews/Details/Filters/Add/__tests__/cvFilterCreateResult.fixtures.json +124 -0
- data/webpack/scenes/ContentViews/Details/Filters/CVPackageGroupFilterContent.js +8 -6
- data/webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js +7 -6
- data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilterDetails.js +4 -3
- data/webpack/scenes/ContentViews/Details/Filters/ContentViewFilters.js +71 -12
- data/webpack/scenes/ContentViews/Details/Filters/__tests__/contentViewFilters.test.js +77 -0
- data/webpack/scenes/ContentViews/Details/Histories/ContentViewHistories.js +13 -12
- data/webpack/scenes/ContentViews/Details/Histories/__tests__/contentViewHistory.test.js +2 -2
- data/webpack/scenes/ContentViews/Details/Repositories/ContentViewRepositories.js +17 -14
- data/webpack/scenes/ContentViews/Details/Repositories/LastSync.js +3 -3
- data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewAddRemove.test.js +2 -2
- data/webpack/scenes/ContentViews/Details/Repositories/__tests__/contentViewDetailRepos.test.js +6 -2
- data/webpack/scenes/ContentViews/Details/Versions/ContentViewVersions.js +61 -20
- data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewTaskInProgressResponse.fixtures.json +71 -0
- data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewTaskResponse.fixtures.json +75 -0
- data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersions.test.js +86 -1
- data/webpack/scenes/ContentViews/Details/Versions/__tests__/contentViewVersionsWithTask.fixtures.json +713 -0
- data/webpack/scenes/ContentViews/Details/__tests__/contentViewDetail.test.js +3 -0
- data/webpack/scenes/ContentViews/Publish/CVPublishFinish.js +184 -0
- data/webpack/scenes/ContentViews/Publish/CVPublishForm.js +104 -0
- data/webpack/scenes/ContentViews/Publish/CVPublishReview.js +71 -0
- data/webpack/scenes/ContentViews/Publish/ContentViewPublishSelectors.js +17 -0
- data/webpack/scenes/ContentViews/Publish/PublishContentViewWizard.js +145 -0
- data/webpack/scenes/ContentViews/Publish/__tests__/environmentPaths.fixtures.json +352 -0
- data/webpack/scenes/ContentViews/Publish/__tests__/publishContentView.test.js +184 -0
- data/webpack/scenes/ContentViews/Publish/__tests__/publishResponse.fixture.json +69 -0
- data/webpack/scenes/ContentViews/Publish/cvPublishForm.scss +3 -0
- data/webpack/scenes/ContentViews/Table/ContentViewsTable.js +75 -48
- data/webpack/scenes/ContentViews/Table/tableDataGenerator.js +15 -2
- data/webpack/scenes/ContentViews/__tests__/contentViewPage.test.js +6 -10
- data/webpack/scenes/ContentViews/components/EnvironmentLabels.js +22 -10
- data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathActions.js +12 -0
- data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathConstants.js +2 -0
- data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPathSelectors.js +16 -0
- data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.js +72 -0
- data/webpack/scenes/ContentViews/components/EnvironmentPaths/EnvironmentPaths.scss +8 -0
- data/webpack/scenes/ContentViews/components/TaskPresenter/TaskPresenter.js +85 -0
- data/webpack/scenes/SmartProxy/SmartProxyContentTable.js +9 -8
- data/webpack/scenes/Subscriptions/SubscriptionsPage.js +4 -25
- data/webpack/scenes/Subscriptions/__tests__/SubscriptionsPage.test.js +0 -3
- data/webpack/scenes/Subscriptions/__tests__/__snapshots__/SubscriptionsPage.test.js.snap +3 -3
- data/webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableSchema.js +4 -2
- data/webpack/scenes/Subscriptions/components/SubscriptionsTable/__tests__/__snapshots__/SubscriptionsTable.test.js.snap +24 -0
- data/webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Table.js +4 -1
- data/webpack/scenes/Subscriptions/index.js +1 -4
- metadata +74 -39
- data/app/lib/actions/candlepin/environment/create.rb +0 -21
- data/app/lib/actions/foreman/environment/destroy.rb +0 -23
- data/app/lib/actions/katello/content_view/environment_create.rb +0 -21
- data/app/lib/actions/katello/repository/export.rb +0 -85
- data/app/lib/actions/katello/repository/purge_empty_content.rb +0 -16
- data/app/lib/actions/katello/repository/upload_errata.rb +0 -38
- data/app/lib/katello/util/proxy_uri.rb +0 -64
- data/app/models/katello/rhsm_fact_importer.rb +0 -20
- data/app/models/katello/rhsm_fact_name.rb +0 -17
- data/app/models/katello/rhsm_fact_parser.rb +0 -120
data/app/lib/katello/errors.rb
CHANGED
@@ -106,6 +106,7 @@ module Katello
|
|
106
106
|
|
107
107
|
class CandlepinNotRunning < StandardError; end
|
108
108
|
class CandlepinPoolGone < CandlepinError; end
|
109
|
+
class CandlepinEnvironmentGone < CandlepinError; end
|
109
110
|
|
110
111
|
class Pulp3Error < StandardError; end
|
111
112
|
class Pulp3MigrationError < StandardError; end
|
@@ -34,8 +34,25 @@ module Katello
|
|
34
34
|
@json[key] = value
|
35
35
|
end
|
36
36
|
|
37
|
+
REQUEST_MAP = {
|
38
|
+
get: Net::HTTP::Get,
|
39
|
+
post: Net::HTTP::Post,
|
40
|
+
put: Net::HTTP::Put,
|
41
|
+
delete: Net::HTTP::Delete
|
42
|
+
}.freeze
|
43
|
+
|
37
44
|
class << self
|
38
|
-
|
45
|
+
REQUEST_MAP.keys.each do |key|
|
46
|
+
define_method(key) do |*args|
|
47
|
+
issue_request(
|
48
|
+
method: key,
|
49
|
+
path: args.first,
|
50
|
+
headers: args.length > 1 ? args.last : nil,
|
51
|
+
payload: args.length > 2 ? args[1] : nil # non-GET method signatures use payload as the second argument, keeping headers as the last element
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
39
56
|
def logger
|
40
57
|
fail NotImplementedError
|
41
58
|
end
|
@@ -64,64 +81,19 @@ module Katello
|
|
64
81
|
fail RestClientException, {:message => message, :service_code => service_code, :code => status_code}, caller
|
65
82
|
end
|
66
83
|
|
67
|
-
def
|
84
|
+
def issue_request(method:, path:, headers: {}, payload: nil)
|
85
|
+
logger.debug("Resource #{method.upcase} request: #{path}")
|
68
86
|
logger.debug "Headers: #{headers.to_json}"
|
69
87
|
logger.debug "Body: #{filter_sensitive_data(payload.to_json)}"
|
70
|
-
end
|
71
88
|
|
72
|
-
|
73
|
-
|
74
|
-
print_debug_info(a_path, headers)
|
75
|
-
a_path = URI.encode(a_path)
|
76
|
-
client = rest_client(Net::HTTP::Get, :get, a_path)
|
77
|
-
result = process_response(client.get(headers))
|
78
|
-
result
|
79
|
-
rescue RestClient::Exception => e
|
80
|
-
raise_rest_client_exception e, a_path, "GET"
|
81
|
-
rescue Errno::ECONNREFUSED
|
82
|
-
service = a_path.split("/").second
|
83
|
-
raise Errors::ConnectionRefusedException, _("A backend service [ %s ] is unreachable") % service.capitalize
|
84
|
-
end
|
85
|
-
|
86
|
-
def post(a_path, payload = {}, headers = {})
|
87
|
-
logger.debug "Resource POST request: #{a_path}, #{payload}"
|
88
|
-
print_debug_info(a_path, headers, payload)
|
89
|
-
a_path = URI.encode(a_path)
|
90
|
-
client = rest_client(Net::HTTP::Post, :post, a_path)
|
91
|
-
result = process_response(client.post(payload, headers))
|
92
|
-
result
|
93
|
-
rescue RestClient::Exception => e
|
94
|
-
raise_rest_client_exception e, a_path, "POST"
|
95
|
-
rescue Errno::ECONNREFUSED
|
96
|
-
service = a_path.split("/").second
|
97
|
-
raise Katello::Errors::ConnectionRefusedException, _("A backend service [ %s ] is unreachable") % service.capitalize
|
98
|
-
end
|
89
|
+
client = rest_client(REQUEST_MAP[method], method, path)
|
90
|
+
args = [method, payload, headers].compact
|
99
91
|
|
100
|
-
|
101
|
-
logger.debug "Resource PUT request: #{a_path}, #{payload}"
|
102
|
-
print_debug_info(a_path, headers, payload)
|
103
|
-
a_path = URI.encode(a_path)
|
104
|
-
client = rest_client(Net::HTTP::Put, :put, a_path)
|
105
|
-
result = process_response(client.put(payload, headers))
|
106
|
-
result
|
92
|
+
process_response(client.send(*args))
|
107
93
|
rescue RestClient::Exception => e
|
108
|
-
raise_rest_client_exception e,
|
94
|
+
raise_rest_client_exception e, path, method.upcase
|
109
95
|
rescue Errno::ECONNREFUSED
|
110
|
-
service =
|
111
|
-
raise Errors::ConnectionRefusedException, _("A backend service [ %s ] is unreachable") % service.capitalize
|
112
|
-
end
|
113
|
-
|
114
|
-
def delete(a_path = nil, headers = {})
|
115
|
-
logger.debug "Resource DELETE request: #{a_path}"
|
116
|
-
print_debug_info(a_path, headers)
|
117
|
-
a_path = URI.encode(a_path)
|
118
|
-
client = rest_client(Net::HTTP::Delete, :delete, a_path)
|
119
|
-
result = process_response(client.delete(headers))
|
120
|
-
result
|
121
|
-
rescue RestClient::Exception => e
|
122
|
-
raise_rest_client_exception e, a_path, "DELETE"
|
123
|
-
rescue Errno::ECONNREFUSED
|
124
|
-
service = a_path.split("/").second
|
96
|
+
service = path.split("/").second
|
125
97
|
raise Errors::ConnectionRefusedException, _("A backend service [ %s ] is unreachable") % service.capitalize
|
126
98
|
end
|
127
99
|
|
@@ -139,10 +111,6 @@ module Katello
|
|
139
111
|
end
|
140
112
|
end
|
141
113
|
|
142
|
-
def create_thing(request_type)
|
143
|
-
request_type.new
|
144
|
-
end
|
145
|
-
|
146
114
|
# Creates a RestClient::Resource class with a signed OAuth style
|
147
115
|
# Authentication header added to the request headers.
|
148
116
|
def rest_client(http_type, method, path)
|
@@ -180,23 +148,8 @@ module Katello
|
|
180
148
|
RestClient::Resource.new(url, options)
|
181
149
|
end
|
182
150
|
|
183
|
-
# Encode url element if its not nil. This helper method is used mainly in resource path methods.
|
184
|
-
#
|
185
|
-
# @param [String] element to encode
|
186
|
-
# @return [String] encoded element or nil
|
187
|
-
def url_encode(element)
|
188
|
-
CGI.escape element.to_s unless element.nil?
|
189
|
-
end
|
190
|
-
|
191
151
|
def hash_to_query(query_parameters)
|
192
|
-
|
193
|
-
so_far << "&" unless so_far == "?"
|
194
|
-
if current[1].is_a?(Array)
|
195
|
-
so_far << current[1].map { |attr| "#{current[0]}=#{attr}" }.join('&')
|
196
|
-
else
|
197
|
-
so_far << "#{current[0].to_s}=#{url_encode(current[1])}"
|
198
|
-
end
|
199
|
-
end
|
152
|
+
"?#{URI.encode_www_form(query_parameters)}"
|
200
153
|
end
|
201
154
|
end
|
202
155
|
end
|
@@ -74,13 +74,11 @@ module Katello
|
|
74
74
|
def initialize(url:, ssl_cert_file:, ssl_key_file:, ssl_ca_file:)
|
75
75
|
@url = url
|
76
76
|
ssl_domain = ::Qpid::Proton::SSLDomain.new(::Qpid::Proton::SSLDomain::MODE_CLIENT)
|
77
|
-
ssl_domain.peer_authentication(::Qpid::Proton::SSLDomain::VERIFY_PEER_NAME)
|
78
77
|
ssl_domain.credentials(ssl_cert_file, ssl_key_file, nil) if ssl_cert_file && ssl_key_file
|
79
78
|
ssl_domain.trusted_ca_db(ssl_ca_file) if ssl_ca_file
|
80
79
|
@connection_options = {
|
81
80
|
ssl_domain: ssl_domain,
|
82
|
-
sasl_allowed_mechs: 'external'
|
83
|
-
virtual_host: URI.parse(url).host
|
81
|
+
sasl_allowed_mechs: 'external'
|
84
82
|
}
|
85
83
|
end
|
86
84
|
|
@@ -46,7 +46,7 @@ module Katello
|
|
46
46
|
|
47
47
|
def create(env_id, parameters, activation_key_cp_ids)
|
48
48
|
parameters['installedProducts'] ||= [] #if installed products is nil, candlepin won't attach custom products
|
49
|
-
url = "/candlepin/environments/#{
|
49
|
+
url = "/candlepin/environments/#{env_id}/consumers/"
|
50
50
|
url += "?activation_keys=" + activation_key_cp_ids.join(",") if activation_key_cp_ids.length > 0
|
51
51
|
|
52
52
|
response = self.post(url, parameters.to_json, self.default_headers).body
|
@@ -23,30 +23,17 @@ module Katello
|
|
23
23
|
class RegistryResource < HttpResource
|
24
24
|
class << self
|
25
25
|
def load_class
|
26
|
-
registry_url = nil
|
27
26
|
pulp_primary = ::SmartProxy.pulp_primary
|
27
|
+
content_app_url = pulp_primary.setting(SmartProxy::PULP3_FEATURE, 'content_app_url')
|
28
28
|
|
29
|
-
|
30
|
-
if pulp_primary&.pulp3_repository_type_support?(::Katello::Repository::DOCKER_TYPE)
|
31
|
-
uri = URI(pulp_primary.setting(SmartProxy::PULP3_FEATURE, 'content_app_url'))
|
32
|
-
uri.path = "/pulpcore_registry/"
|
33
|
-
registry_url = uri.to_s
|
29
|
+
fail Errors::ContainerRegistryNotConfigured unless content_app_url
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
elsif (container_config = SETTINGS.dig(:katello, :container_image_registry))
|
38
|
-
registry_url = container_config[:crane_url]
|
39
|
-
ca_cert_file = container_config[:registry_ca_cert_file]
|
40
|
-
end
|
41
|
-
|
42
|
-
fail Errors::ContainerRegistryNotConfigured unless registry_url
|
43
|
-
|
44
|
-
uri = URI.parse(registry_url)
|
45
|
-
self.prefix = uri.path
|
31
|
+
uri = URI.parse(content_app_url)
|
32
|
+
self.prefix = "/pulpcore_registry/"
|
46
33
|
self.site = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
47
|
-
self.
|
48
|
-
self
|
49
|
-
|
34
|
+
self.ca_cert_file = Setting[:ssl_ca_file]
|
35
|
+
pulp_primary.pulp3_ssl_configuration(self)
|
36
|
+
|
50
37
|
self
|
51
38
|
end
|
52
39
|
|
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'katello/util/proxy_uri'
|
2
|
-
|
3
1
|
module Katello
|
4
2
|
module Util
|
5
3
|
module HttpProxy
|
6
4
|
def proxy_uri
|
7
5
|
#Reset the scheme to proxy(s) based on http or https to handle cgi unescaping in rest-client
|
8
|
-
# this relies on katello/util/proxy_uri
|
9
6
|
if proxy
|
10
7
|
scheme = 'proxy' if proxy_scheme == 'http'
|
11
8
|
scheme = 'proxys' if proxy_scheme == 'https'
|
@@ -33,7 +33,7 @@ module Katello
|
|
33
33
|
|
34
34
|
def self.validate_line_length(record, attribute, value)
|
35
35
|
value.each_line do |line|
|
36
|
-
record.errors[attribute] << _("must contain valid Public GPG Key") if line.length >
|
36
|
+
record.errors[attribute] << _("must contain valid Public GPG Key") if line.length > ContentCredential::MAX_CONTENT_LINE_LENGTH
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -85,7 +85,6 @@ module Katello
|
|
85
85
|
property :subscription_manager_configuration_url, String, desc: 'Returns URL for subscription manager configuration'
|
86
86
|
property :rhsm_organization_label, String, desc: 'Returns label of the Red Hat Subscription Manager organization'
|
87
87
|
property :host_collections, array_of: 'HostCollection', desc: 'Returns list of the host collections the host belongs to'
|
88
|
-
property :comment, String, desc: 'Returns comment given to the host'
|
89
88
|
property :pools, array_of: 'Pool', desc: 'Returns subscription pool objects associated with the host'
|
90
89
|
property :hypervisor_host, 'Host', desc: 'Returns hypervisor host object of this host'
|
91
90
|
property :lifecycle_environment, 'KTEnvironment', desc: 'Returns lifecycle environment object associated with the host'
|
@@ -215,15 +214,10 @@ module Katello
|
|
215
214
|
new_ids = new_available_module_streams.keys - old_associated_ids
|
216
215
|
new_ids.each do |new_id|
|
217
216
|
module_stream = new_available_module_streams[new_id]
|
218
|
-
status = module_stream["status"]
|
219
|
-
# Set status to "unknown" only if the active field is in use and set to false and the module is enabled
|
220
|
-
if enabled_module_stream_inactive?(module_stream)
|
221
|
-
status = "unknown"
|
222
|
-
end
|
223
217
|
self.host_available_module_streams.create!(host_id: self.id,
|
224
218
|
available_module_stream_id: new_id,
|
225
219
|
installed_profiles: module_stream["installed_profiles"],
|
226
|
-
status: status)
|
220
|
+
status: module_stream["status"])
|
227
221
|
end
|
228
222
|
|
229
223
|
upgradable_streams.each do |hams|
|
@@ -233,10 +227,6 @@ module Katello
|
|
233
227
|
if hams.attributes.slice(*shared_keys) != module_stream_data
|
234
228
|
hams.update!(module_stream_data)
|
235
229
|
end
|
236
|
-
# Set status to "unknown" only if the active field is in use and set to false and the module is enabled
|
237
|
-
if enabled_module_stream_inactive?(module_stream)
|
238
|
-
hams.update!(status: "unknown")
|
239
|
-
end
|
240
230
|
end
|
241
231
|
end
|
242
232
|
|
@@ -356,17 +346,13 @@ module Katello
|
|
356
346
|
self.get_status(::Katello::TraceStatus).refresh!
|
357
347
|
self.refresh_global_status!
|
358
348
|
end
|
359
|
-
|
360
|
-
def enabled_module_stream_inactive?(module_stream)
|
361
|
-
!module_stream["active"].nil? && module_stream["active"] == false && module_stream["status"] == "enabled"
|
362
|
-
end
|
363
349
|
end
|
364
350
|
end
|
365
351
|
end
|
366
352
|
|
367
353
|
class ::Host::Managed::Jail < Safemode::Jail
|
368
354
|
allow :content_source, :subscription_manager_configuration_url, :rhsm_organization_label,
|
369
|
-
:host_collections, :
|
355
|
+
:host_collections, :pools, :hypervisor_host, :lifecycle_environment, :content_view,
|
370
356
|
:installed_packages
|
371
357
|
end
|
372
358
|
|
@@ -21,7 +21,7 @@ module Katello
|
|
21
21
|
# has_many :environments is already defined in Foreman taxonomy.rb
|
22
22
|
has_many :kt_environments, :class_name => "Katello::KTEnvironment", :dependent => :restrict_with_exception, :inverse_of => :organization
|
23
23
|
has_one :library, lambda { where(:library => true) }, :class_name => "Katello::KTEnvironment", :dependent => :destroy
|
24
|
-
has_many :gpg_keys, :class_name => "Katello::
|
24
|
+
has_many :gpg_keys, :class_name => "Katello::ContentCredential", :dependent => :destroy, :inverse_of => :organization
|
25
25
|
has_many :sync_plans, :class_name => "Katello::SyncPlan", :dependent => :destroy, :inverse_of => :organization
|
26
26
|
has_many :host_collections, :class_name => "Katello::HostCollection", :dependent => :destroy, :inverse_of => :organization
|
27
27
|
has_many :contents, :class_name => "Katello::Content", :dependent => :destroy, :inverse_of => :organization
|
@@ -127,7 +127,7 @@ module Katello
|
|
127
127
|
"#{self.name.demodulize.underscore}_id"
|
128
128
|
end
|
129
129
|
|
130
|
-
def import_all(pulp_ids = nil, repository = nil)
|
130
|
+
def import_all(pulp_ids = nil, repository = nil, content_type_name = nil)
|
131
131
|
ids_to_associate = []
|
132
132
|
service_class = SmartProxy.pulp_primary!.content_service(content_type)
|
133
133
|
service_class.pulp_units_batch_all(pulp_ids).each do |units|
|
@@ -145,21 +145,25 @@ module Katello
|
|
145
145
|
end
|
146
146
|
service = service_class.new(model.pulp_id)
|
147
147
|
service.backend_data = unit
|
148
|
-
|
148
|
+
if repository&.generic?
|
149
|
+
service.update_model(model, repository.repository_type, content_type_name)
|
150
|
+
else
|
151
|
+
service.update_model(model)
|
152
|
+
end
|
149
153
|
ids_to_associate << model.pulp_id
|
150
154
|
end
|
151
155
|
end
|
152
156
|
sync_repository_associations(repository, :pulp_ids => ids_to_associate, :additive => true) if self.many_repository_associations && repository && ids_to_associate.present?
|
153
157
|
end
|
154
158
|
|
155
|
-
def import_for_repository(repository)
|
159
|
+
def import_for_repository(repository, content_type_name = nil)
|
156
160
|
pulp_id_href_map = {}
|
157
161
|
service_class = SmartProxy.pulp_primary!.content_service(content_type)
|
158
162
|
fetch_only_ids = !repository.content_view.default? &&
|
159
163
|
!repository.repository_type.unique_content_per_repo &&
|
160
164
|
service_class.supports_id_fetch?
|
161
165
|
|
162
|
-
service_class.pulp_units_batch_for_repo(repository, fetch_identifiers: fetch_only_ids).each do |units|
|
166
|
+
service_class.pulp_units_batch_for_repo(repository, fetch_identifiers: fetch_only_ids, content_type: content_type_name).each do |units|
|
163
167
|
units.each do |unit|
|
164
168
|
unit = unit.with_indifferent_access
|
165
169
|
pulp_id = unit[service_class.unit_identifier]
|
@@ -171,7 +175,11 @@ module Katello
|
|
171
175
|
service = service_class.new(model.pulp_id)
|
172
176
|
service.backend_data = unit
|
173
177
|
model.repository_id = repository.id unless many_repository_associations
|
174
|
-
|
178
|
+
if repository.generic?
|
179
|
+
service.update_model(model, repository.repository_type, content_type_name)
|
180
|
+
else
|
181
|
+
service.update_model(model)
|
182
|
+
end
|
175
183
|
end
|
176
184
|
pulp_id_href_map[pulp_id] = backend_identifier
|
177
185
|
end
|
@@ -150,12 +150,14 @@ module Katello
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def pulp3_ssl_configuration(config)
|
153
|
+
legacy_pulp_cert = !self.setting(PULP3_FEATURE, 'client_authentication')&.include?('client_certificates')
|
154
|
+
|
153
155
|
if Faraday.default_adapter == :excon
|
154
|
-
config.ssl_client_cert = ::Cert::Certs.ssl_client_cert_filename
|
155
|
-
config.ssl_client_key = ::Cert::Certs.ssl_client_key_filename
|
156
|
+
config.ssl_client_cert = ::Cert::Certs.ssl_client_cert_filename(use_admin_as_cn_cert: legacy_pulp_cert)
|
157
|
+
config.ssl_client_key = ::Cert::Certs.ssl_client_key_filename(use_admin_as_cn_cert: legacy_pulp_cert)
|
156
158
|
elsif Faraday.default_adapter == :net_http
|
157
|
-
config.ssl_client_cert = ::Cert::Certs.ssl_client_cert
|
158
|
-
config.ssl_client_key = ::Cert::Certs.ssl_client_key
|
159
|
+
config.ssl_client_cert = ::Cert::Certs.ssl_client_cert(use_admin_as_cn_cert: legacy_pulp_cert)
|
160
|
+
config.ssl_client_key = ::Cert::Certs.ssl_client_key(use_admin_as_cn_cert: legacy_pulp_cert)
|
159
161
|
else
|
160
162
|
fail "Unexpected faraday default_adapter #{Faraday.default_adapter}! Cannot continue, this is likely a bug."
|
161
163
|
end
|
@@ -205,23 +207,18 @@ module Katello
|
|
205
207
|
repository ? pulp3_repository_type_support?(repository.try(:content_type)) : false
|
206
208
|
end
|
207
209
|
|
208
|
-
def pulp2_preferred_for_type?(repository_type)
|
209
|
-
if SETTINGS[:katello][:use_pulp_2_for_content_type].nil? ||
|
210
|
-
SETTINGS[:katello][:use_pulp_2_for_content_type][repository_type.to_sym].nil?
|
211
|
-
return false
|
212
|
-
else
|
213
|
-
return SETTINGS[:katello][:use_pulp_2_for_content_type][repository_type.to_sym]
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
210
|
def missing_pulp3_capabilities?
|
218
211
|
pulp3_enabled? && self.capabilities(PULP3_FEATURE).empty?
|
219
212
|
end
|
220
213
|
|
221
214
|
def fix_pulp3_capabilities(type)
|
222
|
-
|
215
|
+
if type.is_a?(String) || type.is_a?(Symbol)
|
216
|
+
repository_type_obj = Katello::RepositoryTypeManager.defined_repository_types[type]
|
217
|
+
else
|
218
|
+
repository_type_obj = type
|
219
|
+
end
|
223
220
|
|
224
|
-
if missing_pulp3_capabilities? && repository_type_obj.pulp3_plugin
|
221
|
+
if missing_pulp3_capabilities? && repository_type_obj.pulp3_plugin
|
225
222
|
self.refresh
|
226
223
|
if self.capabilities(::SmartProxy::PULP3_FEATURE).empty?
|
227
224
|
fail Katello::Errors::PulpcoreMissingCapabilities
|
@@ -229,23 +226,22 @@ module Katello
|
|
229
226
|
end
|
230
227
|
end
|
231
228
|
|
232
|
-
def pulp3_repository_type_support?(repository_type
|
233
|
-
repository_type_obj = repository_type.is_a?(String) ? Katello::RepositoryTypeManager.
|
229
|
+
def pulp3_repository_type_support?(repository_type)
|
230
|
+
repository_type_obj = repository_type.is_a?(String) ? Katello::RepositoryTypeManager.find(repository_type) : repository_type
|
234
231
|
fail "Cannot find repository type #{repository_type}, is it enabled?" unless repository_type_obj
|
235
232
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
check_pulp2_preferred ? pulp3_supported && !pulp2_preferred_for_type?(repository_type_obj.id) : pulp3_supported
|
233
|
+
repository_type_obj.pulp3_plugin.present? &&
|
234
|
+
pulp3_enabled? &&
|
235
|
+
(self.capabilities(PULP3_FEATURE).try(:include?, repository_type_obj.pulp3_plugin) ||
|
236
|
+
self.capabilities(PULP3_FEATURE).try(:include?, 'pulp_' + repository_type_obj.pulp3_plugin))
|
242
237
|
end
|
243
238
|
|
244
239
|
def pulp3_content_support?(content_type)
|
245
240
|
content_type_obj = content_type.is_a?(String) ? Katello::RepositoryTypeManager.find_content_type(content_type) : content_type
|
246
|
-
|
241
|
+
content_type_string = content_type_obj&.label || content_type
|
242
|
+
fail "Content type #{content_type_string} does not belong to an enabled repo type." unless content_type_obj
|
247
243
|
|
248
|
-
found_type = Katello::RepositoryTypeManager.
|
244
|
+
found_type = Katello::RepositoryTypeManager.enabled_repository_types.values.find { |repo_type| repo_type.content_types.include?(content_type_obj) }
|
249
245
|
fail "Cannot find repository type for content_type #{content_type}, is it enabled?" unless found_type
|
250
246
|
pulp3_repository_type_support?(found_type)
|
251
247
|
end
|
@@ -274,24 +270,15 @@ module Katello
|
|
274
270
|
end
|
275
271
|
|
276
272
|
def supported_pulp_types
|
277
|
-
|
278
|
-
pulp2: { supported_types: [] },
|
279
|
-
pulp3: { supported_types: [], overriden_to_pulp2: [] }
|
280
|
-
}
|
273
|
+
supported_types = []
|
281
274
|
|
282
|
-
::Katello::RepositoryTypeManager.
|
283
|
-
if pulp3_repository_type_support?(type
|
284
|
-
|
285
|
-
supported_map[:pulp3][:overriden_to_pulp2] << type
|
286
|
-
else
|
287
|
-
supported_map[:pulp3][:supported_types] << type
|
288
|
-
end
|
289
|
-
else
|
290
|
-
supported_map[:pulp2][:supported_types] << type
|
275
|
+
::Katello::RepositoryTypeManager.enabled_repository_types.keys.each do |type|
|
276
|
+
if pulp3_repository_type_support?(type)
|
277
|
+
supported_types << type
|
291
278
|
end
|
292
279
|
end
|
293
280
|
|
294
|
-
|
281
|
+
supported_types
|
295
282
|
end
|
296
283
|
|
297
284
|
#deprecated methods
|
@@ -312,8 +299,17 @@ module Katello
|
|
312
299
|
end
|
313
300
|
|
314
301
|
def content_service(content_type)
|
315
|
-
|
316
|
-
|
302
|
+
if content_type.is_a?(String)
|
303
|
+
content_type_obj = RepositoryTypeManager.find_content_type(content_type)
|
304
|
+
else
|
305
|
+
content_type_obj = content_type
|
306
|
+
end
|
307
|
+
content_type_string = content_type_obj&.label || content_type
|
308
|
+
unless content_type_obj
|
309
|
+
fail _("Content type %{content_type_string} does not belong to an enabled repo type.") %
|
310
|
+
{ content_type_string: content_type_string }
|
311
|
+
end
|
312
|
+
pulp3_content_support?(content_type_obj) ? content_type_obj.pulp3_service_class : content_type_obj.pulp2_service_class
|
317
313
|
end
|
318
314
|
|
319
315
|
def set_default_download_policy
|
@@ -410,6 +406,14 @@ module Katello
|
|
410
406
|
def smart_proxy_service
|
411
407
|
@smart_proxy_service ||= Pulp::SmartProxyRepository.new(self)
|
412
408
|
end
|
409
|
+
|
410
|
+
def rhsm_url
|
411
|
+
if pulp_primary?
|
412
|
+
"https://#{URI.parse(url).host}/rhsm"
|
413
|
+
elsif pulp_mirror?
|
414
|
+
"https://#{URI.parse(url).host}:8443/rhsm"
|
415
|
+
end
|
416
|
+
end
|
413
417
|
end
|
414
418
|
end
|
415
419
|
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Katello
|
2
|
-
class
|
2
|
+
class ContentCredential < Katello::Model
|
3
3
|
audited :associations => [:products]
|
4
4
|
|
5
5
|
include ForemanTasks::Concerns::ActionSubject
|
6
|
-
include Katello::Authorization::
|
6
|
+
include Katello::Authorization::ContentCredential
|
7
7
|
MAX_CONTENT_LINE_LENGTH = 65
|
8
8
|
|
9
9
|
GPG_KEY_TYPE = 'gpg_key'.freeze
|
10
10
|
CERT_TYPE = 'cert'.freeze
|
11
11
|
|
12
|
-
has_many :root_repositories, :class_name => "Katello::RootRepository", :inverse_of => :gpg_key, :dependent => :nullify
|
12
|
+
has_many :root_repositories, :class_name => "Katello::RootRepository", :inverse_of => :gpg_key, :dependent => :nullify, :foreign_key => 'gpg_key_id'
|
13
13
|
has_many :repositories, :through => :root_repositories
|
14
14
|
|
15
|
-
has_many :products, :class_name => "Katello::Product", :inverse_of => :gpg_key, :dependent => :nullify
|
15
|
+
has_many :products, :class_name => "Katello::Product", :inverse_of => :gpg_key, :dependent => :nullify, :foreign_key => 'gpg_key_id'
|
16
16
|
has_many :ssl_ca_products, :class_name => "Katello::Product", :foreign_key => "ssl_ca_cert_id",
|
17
17
|
:inverse_of => :ssl_ca_cert, :dependent => :nullify
|
18
18
|
has_many :ssl_client_products, :class_name => "Katello::Product", :foreign_key => "ssl_client_cert_id",
|
@@ -107,6 +107,10 @@ module Katello
|
|
107
107
|
joins(:content_view_versions => :repositories).where("katello_repositories.root_id" => root_repository.id).uniq
|
108
108
|
end
|
109
109
|
|
110
|
+
def self.in_organization(org)
|
111
|
+
where(organization_id: org.id)
|
112
|
+
end
|
113
|
+
|
110
114
|
def to_s
|
111
115
|
name
|
112
116
|
end
|
@@ -265,7 +269,8 @@ module Katello
|
|
265
269
|
end
|
266
270
|
|
267
271
|
def last_task
|
268
|
-
history.order(:created_at)
|
272
|
+
last_task_id = history.order(:created_at)&.last&.task_id
|
273
|
+
last_task_id ? ForemanTasks::Task.find(last_task_id) : nil
|
269
274
|
end
|
270
275
|
|
271
276
|
def history
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Katello
|
2
|
+
class GenericContentUnit < Katello::Model
|
3
|
+
self.table_name = 'katello_generic_content_units'
|
4
|
+
include Concerns::PulpDatabaseUnit
|
5
|
+
|
6
|
+
CONTENT_TYPE = 'generic_content_unit'.freeze
|
7
|
+
|
8
|
+
def self.default_sort
|
9
|
+
order(:name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.total_for_repositories(repos)
|
13
|
+
self.in_repositories(repos).count
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -42,7 +42,7 @@ module Katello
|
|
42
42
|
def sync_status
|
43
43
|
all_repos = repos(self.library, nil, false)
|
44
44
|
task = last_repo_sync_task
|
45
|
-
last_synced_repo = task ? all_repos.find { |repo| task.
|
45
|
+
last_synced_repo = task ? all_repos.find { |repo| task.locks.where(:resource_type => ::Katello::Repository.name).pluck(:resource_id).map(&:to_s).include?(repo.id.to_s) } : nil
|
46
46
|
::Katello::SyncStatusPresenter.new(last_synced_repo, task).sync_progress
|
47
47
|
end
|
48
48
|
|
@@ -68,11 +68,10 @@ module Katello
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def last_repo_sync_tasks
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
.joins(:locks).where("foreman_tasks_locks.resource_id in (?) and foreman_tasks_locks.resource_type = ?", all_repos.pluck(:id), ::Katello::Repository.name)
|
71
|
+
ids = repos(self.library, nil, false).pluck(:id).join(',')
|
72
|
+
label = ::Actions::Katello::Repository::Sync.name
|
73
|
+
type = ::Katello::Repository.name
|
74
|
+
ForemanTasks::Task.search_for("label = #{label} and resource_type = #{type} and resource_id ^ (#{ids})")
|
76
75
|
.order("started_at desc")
|
77
76
|
end
|
78
77
|
|
@@ -86,25 +85,10 @@ module Katello
|
|
86
85
|
end
|
87
86
|
|
88
87
|
def last_repo_sync_task_by_repoid
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
.
|
93
|
-
.where("foreman_tasks_locks.resource_id in (?) and foreman_tasks_locks.resource_type = ?", all_repos.pluck(:id), ::Katello::Repository.name)
|
94
|
-
|
95
|
-
max_per_repoid = ForemanTasks::Task::DynflowTask
|
96
|
-
.joins(:locks)
|
97
|
-
.select("#{ForemanTasks::Task::DynflowTask.table_name}.*, inner_select.resource_id")
|
98
|
-
.joins(
|
99
|
-
"INNER JOIN (#{base_combined_table
|
100
|
-
.select("MAX(foreman_tasks_tasks.started_at) AS started_at", "foreman_tasks_locks.resource_id AS resource_id")
|
101
|
-
.group("foreman_tasks_locks.resource_id")
|
102
|
-
.to_sql}) inner_select
|
103
|
-
ON inner_select.started_at = #{ForemanTasks::Task::DynflowTask.table_name}.started_at
|
104
|
-
AND inner_select.resource_id = locks_foreman_tasks_tasks.resource_id")
|
105
|
-
.distinct
|
106
|
-
|
107
|
-
max_per_repoid.index_by { |x| [x.resource_id, x] }
|
88
|
+
ForemanTasks::Task.latest_tasks_by_resource_ids(
|
89
|
+
::Actions::Katello::Repository::Sync.name,
|
90
|
+
Katello::Repository.name,
|
91
|
+
repos(self.library, nil, false).pluck(:id))
|
108
92
|
end
|
109
93
|
|
110
94
|
def sync_state_aggregated
|