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

Inherits:
EntryAction
  • Object
show all
Extended by:
ApipieDSL::Class
Includes:
Helpers::Presenter, Helpers::RollingCVRepos, Helpers::SmartProxySyncHelper, 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

Methods included from Helpers::SmartProxySyncHelper

#schedule_async_repository_proxy_sync

Methods included from Helpers::RollingCVRepos

#find_related_rolling_repos, #update_rolling_content_views, #update_rolling_content_views_async

Instance Method Details

#contents_changedObject



154
155
156
# File 'app/lib/actions/katello/repository/sync.rb', line 154

def contents_changed
  input['contents_changed']
end

#finalizeObject



69
70
71
72
73
74
75
76
77
78
# File 'app/lib/actions/katello/repository/sync.rb', line 69

def finalize
  repo = ::Katello::Repository.find(input[:id])
  if repo
    repo&.audit_sync
    update_rolling_content_views_async(repo, input[:contents_changed])
  end
  repo.clear_smart_proxy_sync_histories if input[:contents_changed]
  schedule_async_repository_proxy_sync(repo)
rescue ::Katello::Errors::CapsuleCannotBeReached # skip any capsules that cannot be connected to
end

#humanized_nameObject



80
81
82
83
84
85
86
87
88
# File 'app/lib/actions/katello/repository/sync.rb', line 80

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

#notify_on_failure(_plan) ⇒ Object



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

def notify_on_failure(_plan)
  notification = MailNotification[:repository_sync_failure]
  repo = ::Katello::Repository.find(input.fetch(:repository, {})[:id])
  notification.users.with_enabled_email.each do |user|
    notification.deliver(user: user, repo: repo, task: task)
  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



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
62
63
64
# File 'app/lib/actions/katello/repository/sync.rb', line 23

def plan(repo, options = {})
  action_subject(repo)
  repo.check_ready_to_act!

  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,
                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

      update_deb_content(repo)
      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



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

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



142
143
144
# File 'app/lib/actions/katello/repository/sync.rb', line 142

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

#product_labelObject



150
151
152
# File 'app/lib/actions/katello/repository/sync.rb', line 150

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

#product_nameObject



146
147
148
# File 'app/lib/actions/katello/repository/sync.rb', line 146

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

#repository_idObject



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

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

#repository_labelObject



138
139
140
# File 'app/lib/actions/katello/repository/sync.rb', line 138

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

#repository_nameObject



134
135
136
# File 'app/lib/actions/katello/repository/sync.rb', line 134

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

#rescue_strategyObject



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

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

#runObject



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

def run
end

#sync_resultObject



158
159
160
# File 'app/lib/actions/katello/repository/sync.rb', line 158

def sync_result
  input['sync_result']
end

#update_deb_content(repo) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'app/lib/actions/katello/repository/sync.rb', line 103

def update_deb_content(repo)
  return unless repo.deb?

  plan_action(::Actions::Candlepin::Product::ContentUpdate,
              owner:           repo.organization.label,
              repository_id:   repo.id,
              name:            repo.root.name,
              type:            repo.root.content_type,
              arches:          repo.root.format_arches,
              label:           repo.root.,
              content_url:     repo.root.custom_content_path,
              gpg_key_url:     repo.yum_gpg_key_url,
              metadata_expire: repo.root.)
end

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



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

def validate_repo!(repo:, 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?
  fail ::Katello::Errors::InvalidActionOptionError, _("Cannot skip metadata check on non-yum/deb repositories.") if  && !repo.yum? && !repo.deb?
  fail ::Katello::Errors::InvalidActionOptionError, _("Unable to sync repo. This repository is not a library instance repository.") unless repo.library_instance?
  ::Katello::Util::CandlepinRepositoryChecker.check_repository_for_sync!(repo) if repo.yum? && !skip_candlepin_check
end