Class: Actions::Pulp3::Orchestration::ContentViewVersion::ExportRepository

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

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



31
32
33
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 31

def humanized_name
  _("Export Repository")
end

#plan(repository, opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 6

def plan(repository, opts = {})
  opts[:format] ||= ::Katello::Pulp3::ContentViewVersion::Export::IMPORTABLE
  action_subject(repository)
  validate_repositories_immediate!(repository)
  validate_export_types!(repository, opts[:format])
  content_view = ::Katello::Pulp3::ContentViewVersion::Export.find_or_create_repository_export_view(
                                                                 repository: repository,
                                                                 format: opts[:format])
  content_view.update!(repository_ids: [repository.library_instance_or_self.id])

  sequence do
    publish_action = plan_action(::Actions::Katello::ContentView::Publish, content_view, '')
    export_action = plan_action(Actions::Katello::ContentViewVersion::Export,
                                content_view_version: publish_action.version,
                                chunk_size: opts[:chunk_size],
                                from_history: opts[:from_history],
                                format: opts[:format])
    plan_self(export_action_output: export_action.output)
  end
end

#rescue_strategyObject



35
36
37
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 35

def rescue_strategy
  Dynflow::Action::Rescue::Skip
end

#runObject



27
28
29
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 27

def run
  output[:export_history_id] = input[:export_action_output]&.[](:export_history_id)
end

#validate_export_types!(repository, format) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 48

def validate_export_types!(repository, format)
  return if ::Katello::Repository.exportable(format: format).where(id: repository.id).exists?
  if format == ::Katello::Pulp3::ContentViewVersion::Export::SYNCABLE
    fail _("NOTE: Unable to export repository '%{repository}' because"\
           " it does not have an syncably exportable content type."\
             % { repository: repository.name })
  end

  fail _("NOTE: Unable to export repository '%{repository}' because"\
         " it does not have an exportable content type."\
           % { repository: repository.name })
end

#validate_repositories_immediate!(repository) ⇒ Object



39
40
41
42
43
44
45
46
# File 'app/lib/actions/pulp3/orchestration/content_view_version/export_repository.rb', line 39

def validate_repositories_immediate!(repository)
  unless repository.download_policy.blank? || repository.immediate?
    fail _("NOTE: Unable to fully export repository '%{repository}' because"\
           " it does not have the 'immediate' download policy."\
           " Update the download policy and sync the affected repository to include them in the export."\
             % { repository: repository.name })
  end
end