Class: InsightsCloud::Async::VmaasReposcanSync
- Inherits:
-
Actions::EntryAction
- Object
- Actions::EntryAction
- InsightsCloud::Async::VmaasReposcanSync
- Includes:
- ForemanRhCloud::CertAuth
- Defined in:
- lib/insights_cloud/async/vmaas_reposcan_sync.rb
Overview
Triggers VMaaS reposcan sync via IoP gateway when repositories are synced
Class Method Summary collapse
-
.subscribe ⇒ Object
Subscribe to Katello repository sync hook action, if available.
Instance Method Summary collapse
- #organization ⇒ Object
- #plan(repo, *_args) ⇒ Object
- #rescue_strategy_for_self ⇒ Object
- #run ⇒ Object
Methods included from ForemanRhCloud::CertAuth
#cert_auth_available?, #execute_cloud_request, #foreman_certificate
Methods included from CandlepinCache
#candlepin_id_cert, #cp_owner_id, #upstream_owner
Methods included from ForemanRhCloud::CloudRequest
Class Method Details
.subscribe ⇒ Object
Subscribe to Katello repository sync hook action, if available
10 11 12 13 14 15 |
# File 'lib/insights_cloud/async/vmaas_reposcan_sync.rb', line 10 def self.subscribe 'Actions::Katello::Repository::SyncHook'.constantize rescue NameError Rails.logger.debug('VMaaS reposcan sync: Repository::SyncHook action not found') nil end |
Instance Method Details
#organization ⇒ Object
67 68 69 |
# File 'lib/insights_cloud/async/vmaas_reposcan_sync.rb', line 67 def organization @organization ||= Organization.find(input[:organization_id]) end |
#plan(repo, *_args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/insights_cloud/async/vmaas_reposcan_sync.rb', line 17 def plan(repo, *_args) return unless ::ForemanRhCloud.with_iop_smart_proxy? repo_id = repo.is_a?(Hash) ? (repo[:id] || repo['id']) : nil unless repo_id logger.error("VMaaS reposcan sync: missing repository id in SyncHook plan parameters: #{repo.inspect}") return end organization_id = Katello::Repository.find(repo_id).organization_id plan_self(organization_id: organization_id) end |
#rescue_strategy_for_self ⇒ Object
63 64 65 |
# File 'lib/insights_cloud/async/vmaas_reposcan_sync.rb', line 63 def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end |
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/insights_cloud/async/vmaas_reposcan_sync.rb', line 31 def run url = ::InsightsCloud.vmaas_reposcan_sync_url response = execute_cloud_request( organization: organization, method: :put, url: url, headers: { 'Content-Type' => 'application/json' } ) if response.code >= 200 && response.code < 300 = "VMaaS reposcan sync triggered successfully: #{response.code}" logger.info() else = "VMaaS reposcan sync failed with status: #{response.code}, body: #{response.body}" logger.error() end output[:message] = response rescue RestClient::ExceptionWithResponse => e = "VMaaS reposcan sync failed: #{e.response&.code} - #{e.response&.body}" logger.error() output[:message] = raise rescue StandardError => e = "Error triggering VMaaS reposcan sync: #{e.}, response: #{e.respond_to?(:response) ? e.response : nil}" logger.error() output[:message] = raise end |