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



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

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

#finalizeObject



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

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”



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

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

#humanized_nameObject



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

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

#success_notification(_plan) ⇒ Object



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

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