Class: Actions::Katello::Organization::ManifestImport

Inherits:
AbstractAsyncTask
  • Object
show all
Includes:
Helpers::Notifications
Defined in:
app/lib/actions/katello/organization/manifest_import.rb

Instance Method Summary collapse

Methods included from Helpers::Notifications

#get_foreman_task, included, #plan_failed?, #send_notification, #subject_organization

Methods inherited from AbstractAsyncTask

#humanized_output, #rescue_strategy

Instance Method Details

#failure_notification(plan) ⇒ Object



35
36
37
38
39
40
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 35

def failure_notification(plan)
  ::Katello::UINotifications::Subscriptions::ManifestImportError.deliver!(
    :subject => subject_organization,
    :task => get_foreman_task(plan)
  )
end

#finalizeObject



58
59
60
61
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 58

def finalize
  subject_organization.clear_manifest_expired_notifications
  subject_organization.audit_manifest_action(_('Manifest imported'))
end

#humanized_inputObject

results in correct grammar on Tasks page, e.g. “Import manifest for organization Default Organization”



54
55
56
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 54

def humanized_input
  "for organization '#{input[:organization_name]}'"
end

#humanized_nameObject



48
49
50
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 48

def humanized_name
  _("Import Manifest")
end

#plan(organization, path, force) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 9

def plan(organization, path, force)
  action_subject organization
  manifest_update = organization.products.redhat.any?

  sequence do
    plan_action(Candlepin::Owner::Import,
                :label => organization.label,
                :path => path,
                :force => force)
    plan_action(Candlepin::Owner::ImportProducts, :organization_id => organization.id)

    if manifest_update
      repositories = ::Katello::Repository.in_default_view.in_product(::Katello::Product.redhat.in_org(organization))
      repositories.each do |repo|
        plan_action(Katello::Repository::RefreshRepository, repo)
      end
    end
    plan_self(:organization_name => organization.name)
  end
end

#runObject



30
31
32
33
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 30

def run
  organization = ::Organization.find_by(name: input[:organization_name])
  organization&.manifest_expiration_date(cached: false) # update the date
end

#success_notification(_plan) ⇒ Object



42
43
44
45
46
# File 'app/lib/actions/katello/organization/manifest_import.rb', line 42

def success_notification(_plan)
  ::Katello::UINotifications::Subscriptions::ManifestImportSuccess.deliver!(
    subject_organization
  )
end