Class: ForemanInventoryUpload::Async::DestroyOrganizationHbiHostsJob
- Inherits:
-
Actions::EntryAction
- Object
- Actions::EntryAction
- ForemanInventoryUpload::Async::DestroyOrganizationHbiHostsJob
show all
- Includes:
- ForemanRhCloud::CertAuth
- Defined in:
- lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb
Instance Method Summary
collapse
#cert_auth_available?, #execute_cloud_request, #foreman_certificate
#candlepin_id_cert, #cp_owner_id, #upstream_owner
#execute_cloud_request
Instance Method Details
#humanized_name ⇒ Object
44
45
46
|
# File 'lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb', line 44
def humanized_name
_("Destroy HBI hosts for organization")
end
|
#logger ⇒ Object
36
37
38
|
# File 'lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb', line 36
def logger
Foreman::Logging.logger('background')
end
|
#plan(organization_id) ⇒ Object
6
7
8
|
# 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 ⇒ Object
40
41
42
|
# File 'lib/foreman_inventory_upload/async/destroy_organization_hbi_hosts_job.rb', line 40
def rescue_strategy
Dynflow::Action::Rescue::Skip
end
|
#run ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# 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
|