Class: Actions::Pulp3::ContentViewVersion::CreateExportHistory

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

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



58
59
60
# File 'app/lib/actions/pulp3/content_view_version/create_export_history.rb', line 58

def humanized_name
  _("Create Export History")
end

#runObject

rubocop:disable Metrics/AbcSize



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
51
52
53
54
55
56
# File 'app/lib/actions/pulp3/content_view_version/create_export_history.rb', line 19

def run # rubocop:disable Metrics/AbcSize
  smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id])
  api = ::Katello::Pulp3::Api::Core.new(smart_proxy)
  export_data = api.export_api.list(input[:exporter_data][:pulp_href]).results.first
  output[:exported_file_checksum] = export_data.output_file_info
  if output[:exported_file_checksum].blank?
    output[:export_history_id] = nil
    output[:message] = _("Export failed: One or more repositories needs to be synced (with Immediate download policy.)")
    return
  end
  file_name = output[:exported_file_checksum].first&.first
  path = File.dirname(file_name.to_s)
  output[:path] = path
  cvv = ::Katello::ContentViewVersion.find(input[:content_view_version_id])
  from_cvv = ::Katello::ContentViewVersion.find(input[:from_content_view_version_id]) unless input[:from_content_view_version_id].blank?

   = ::Katello::Pulp3::ContentViewVersion::Export.create(
                                             content_view_version: cvv,
                                             smart_proxy: smart_proxy,
                                             format: ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE,
                                             from_content_view_version: from_cvv).

  toc_path_info = output[:exported_file_checksum].find { |item| item.first.end_with?("toc.json") }
  [:toc] = File.basename(toc_path_info.first)

  history = ::Katello::ContentViewVersionExportHistory.create!(
    content_view_version_id: input[:content_view_version_id],
    destination_server: input[:destination_server],
    path: path,
    metadata: ,
    audit_comment: ::Katello::ContentViewVersionExportHistory.generate_audit_comment(content_view_version: cvv,
                                                                                     user: User.current,
                                                                                     from_version: from_cvv,
                                                                                     metadata: )
  )
  output[:export_history_id] = history.id
  output[:format] = ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE
end