Class: Actions::Katello::ContentViewVersion::Import

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/content_view_version/import.rb

Instance Method Summary collapse

Instance Method Details

#clean_failed_import(execution_plan) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'app/lib/actions/katello/content_view_version/import.rb', line 56

def clean_failed_import(execution_plan)
  return unless execution_plan.run_steps.any? { |s| s.action_class == ::Actions::Pulp3::ContentViewVersion::CreateImport && s.state != :success }

  version = ::Katello::ContentViewVersion.find_by(id: output[:content_view_version_id])
  return unless version

  ForemanTasks.async_task(::Actions::Katello::ContentView::Remove, version.content_view,
                content_view_versions: [version],
                content_view_environments: version.content_view_environments)
end

#humanized_nameObject



67
68
69
# File 'app/lib/actions/katello/content_view_version/import.rb', line 67

def humanized_name
  _("Import Content View Version")
end

#plan(opts = {}) ⇒ Object



7
8
9
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/lib/actions/katello/content_view_version/import.rb', line 7

def plan(opts = {})
   = ::Katello::Pulp3::ContentViewVersion::MetadataMap.new(metadata: opts[:metadata])

  import = ::Katello::Pulp3::ContentViewVersion::Import.new(
    organization: opts[:organization],
    metadata_map: ,
    path: opts[:path],
    smart_proxy: SmartProxy.pulp_primary!
  )

  import.check!

  gpg_helper = ::Katello::Pulp3::ContentViewVersion::ImportGpgKeys.
                  new(organization: opts[:organization],
                      metadata_gpg_keys: .gpg_keys)
  gpg_helper.import!

  sequence do
    plan_action(AutoCreateProducts, { import: import })
    plan_action(AutoCreateRepositories, { import: import, path: opts[:path] })
    plan_action(AutoCreateRedhatRepositories, { import: import, path: opts[:path] })

    if .syncable_format?
      plan_action(::Actions::BulkAction,
            ::Actions::Katello::Repository::Sync,
            import..exportable(format: .format),
            { skip_candlepin_check: true }
            )
    end

    if import.content_view
      plan_action(ResetContentViewRepositoriesFromMetadata, { import: import })
      publish_output = plan_action(::Actions::Katello::ContentView::Publish, import.content_view, .content_view_version.description,
                  { path: opts[:path],
                    metadata: opts[:metadata],
                    importing: !.syncable_format?,
                    syncable: .syncable_format?,
                    major: .content_view_version.major,
                    minor: .content_view_version.minor,
                  }).output
      plan_self(content_view_id: import.content_view.id, content_view_version_id: publish_output[:content_view_version_id])
    end
  end
end

#runObject



52
53
54
# File 'app/lib/actions/katello/content_view_version/import.rb', line 52

def run
  output[:content_view_version_id] = input[:content_view_version_id]
end