Class: Actions::Katello::Repository::Sync

Inherits:
EntryAction
  • Object
show all
Extended by:
ApipieDSL::Class
Includes:
Helpers::Presenter, JailConcern::Organization, ObservableAction
Defined in:
app/lib/actions/katello/repository/sync.rb

Defined Under Namespace

Classes: Jail

Instance Method Summary collapse

Methods included from JailConcern::Organization

included, #organization_id, #organization_label, #organization_name

Instance Method Details

#contents_changedObject



125
126
127
# File 'app/lib/actions/katello/repository/sync.rb', line 125

def contents_changed
  input['contents_changed']
end

#finalizeObject



70
71
72
# File 'app/lib/actions/katello/repository/sync.rb', line 70

def finalize
  ::Katello::Repository.find(input[:id])&.audit_sync
end

#humanized_nameObject



74
75
76
77
78
79
80
81
82
# File 'app/lib/actions/katello/repository/sync.rb', line 74

def humanized_name
  if input && input[:validate_contents]
    _("Synchronize: Validate Content")
  elsif input && input[:skip_metadata_check]
    _("Synchronize: Skip Metadata Check")
  else
    _("Synchronize")
  end
end

#plan(repo, options = {}) ⇒ Object

Parameters:

  • repo
  • pulp_sync_task_id

    in case the sync was triggered outside of Katello and we just need to finish the rest of the orchestration



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
57
58
59
60
61
# File 'app/lib/actions/katello/repository/sync.rb', line 19

def plan(repo, options = {})
  action_subject(repo)

  source_url = options.fetch(:source_url, nil)
  validate_contents = options.fetch(:validate_contents, false)
   = options.fetch(:skip_metadata_check, false) || (validate_contents && (repo.yum? || repo.deb?))
  generate_applicability =  options.fetch(:generate_applicability, repo.yum? || repo.deb?)

  validate_repo!(repo: repo,
                source_url: source_url,
                validate_contents: validate_contents,
                skip_metadata_check: ,
                skip_candlepin_check: options.fetch(:skip_candlepin_check, false))

  pulp_sync_options = {}
  pulp_sync_options[:download_policy] = ::Katello::RootRepository::DOWNLOAD_ON_DEMAND if validate_contents && repo.yum?

  #pulp3 options
  pulp_sync_options[:optimize] = false if  && (repo.yum? || repo.deb?)

  sequence do
    if validate_contents
      plan_action(Katello::Repository::VerifyChecksum, repo)
    else
      sync_action = plan_action(Actions::Pulp3::Orchestration::Repository::Sync,
                                repo,
                                SmartProxy.pulp_primary,
                                pulp_sync_options)
      output = sync_action.output

      plan_action(Katello::Repository::IndexContent, :id => repo.id, :force_index => )
      plan_action(Katello::Foreman::ContentUpdate, repo.environment, repo.content_view, repo)
      plan_action(Katello::Repository::FetchPxeFiles, :id => repo.id)
      concurrence do
        plan_action(Katello::Repository::ErrataMail, repo)
        plan_action(Actions::Katello::Applicability::Repository::Regenerate, :repo_ids => [repo.id]) if generate_applicability
      end
      plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => , :validate_contents => validate_contents,
                :contents_changed => output[:contents_changed])
      plan_action(Katello::Repository::SyncHook, :id => repo.id)
    end
  end
end

#presenterObject



91
92
93
94
95
# File 'app/lib/actions/katello/repository/sync.rb', line 91

def presenter
  found = all_planned_actions(Pulp3::Repository::Sync) if found.empty?
  found = all_planned_actions(Pulp3::Repository::Repair) if found.empty?
  Helpers::Presenter::Delegated.new(self, found)
end

#product_idObject



113
114
115
# File 'app/lib/actions/katello/repository/sync.rb', line 113

def product_id
  input['product']['id']
end

#product_labelObject



121
122
123
# File 'app/lib/actions/katello/repository/sync.rb', line 121

def product_label
  input['product']['label']
end

#product_nameObject



117
118
119
# File 'app/lib/actions/katello/repository/sync.rb', line 117

def product_name
  input['product']['name']
end

#repository_idObject



101
102
103
# File 'app/lib/actions/katello/repository/sync.rb', line 101

def repository_id
  input['repository']['id']
end

#repository_labelObject



109
110
111
# File 'app/lib/actions/katello/repository/sync.rb', line 109

def repository_label
  input['repository']['label']
end

#repository_nameObject



105
106
107
# File 'app/lib/actions/katello/repository/sync.rb', line 105

def repository_name
  input['repository']['name']
end

#rescue_strategyObject



97
98
99
# File 'app/lib/actions/katello/repository/sync.rb', line 97

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

#runObject



63
64
65
66
67
68
# File 'app/lib/actions/katello/repository/sync.rb', line 63

def run
  repo = ::Katello::Repository.find(input[:id])
  repo.clear_smart_proxy_sync_histories if input[:contents_changed]
  ForemanTasks.async_task(Repository::CapsuleSync, repo) if Setting[:foreman_proxy_content_auto_sync]
rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to
end

#sync_resultObject



129
130
131
# File 'app/lib/actions/katello/repository/sync.rb', line 129

def sync_result
  input['sync_result']
end

#validate_repo!(repo:, source_url:, validate_contents:, skip_metadata_check:, skip_candlepin_check:) ⇒ Object



84
85
86
87
88
89
# File 'app/lib/actions/katello/repository/sync.rb', line 84

def validate_repo!(repo:, source_url:, validate_contents:, skip_metadata_check:, skip_candlepin_check:)
  fail ::Katello::Errors::InvalidActionOptionError, _("Unable to sync repo. This repository does not have a feed url.") if repo.url.blank? && source_url.blank?
  fail ::Katello::Errors::InvalidActionOptionError, _("Cannot validate contents on non-yum/deb repositories.") if validate_contents && !repo.yum? && !repo.deb?
  fail ::Katello::Errors::InvalidActionOptionError, _("Cannot skip metadata check on non-yum/deb repositories.") if  && !repo.yum? && !repo.deb?
  ::Katello::Util::CandlepinRepositoryChecker.check_repository_for_sync!(repo) if repo.yum? && !skip_candlepin_check
end