class ForemanInventoryUpload::Async::DestroyOrganizationHbiHostsJob
Public Instance Methods
humanized_name()
click to toggle source
# File lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb, line 44 def humanized_name _("Destroy HBI hosts for organization") end
logger()
click to toggle source
# File lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb, line 36 def logger Foreman::Logging.logger('background') end
plan(organization_id)
click to toggle source
# File lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb, line 6 def plan(organization_id) plan_self(organization_id: organization_id) end
rescue_strategy()
click to toggle source
# File lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb, line 40 def rescue_strategy Dynflow::Action::Rescue::Skip end
run()
click to toggle source
# File lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb, line 10 def run org = Organization.find_by(id: input[:organization_id]) unless org output[:result] = _("Organization not found") return end logger.info("Destroying all HBI hosts for organization #{org.label} (id: #{org.id})") execute_cloud_request( organization: org, method: :delete, url: ForemanInventoryUpload.hosts_delete_all_url, headers: { content_type: :json, } ) output[:result] = format(_("Successfully deleted all HBI hosts for organization %s"), org.label) rescue RestClient::NotFound output[:result] = format(_("No HBI hosts found for organization %s"), org&.label) rescue StandardError => e logger.error(format(_("Failed to destroy HBI hosts for organization %s: %s"), org&.label, e.message)) raise end