Class: Actions::Katello::CapsuleContent::Sync

Inherits:
EntryAction
  • Object
show all
Includes:
ObservableAction
Defined in:
app/lib/actions/katello/capsule_content/sync.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



45
46
47
48
49
50
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 45

def finalize
  smart_proxy = SmartProxy.unscoped.authorized(:view_capsule_content).find(input[:smart_proxy_id])
  unless smart_proxy&.pulp_primary?
    smart_proxy&.audit_capsule_sync
  end
end

#humanized_inputObject



21
22
23
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 21

def humanized_input
  input['smart_proxy'].nil? || input['smart_proxy']['name'].nil? ? super : ["'#{input['smart_proxy']['name']}'"] + super
end

#humanized_nameObject



17
18
19
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 17

def humanized_name
  _("Synchronize smart proxy")
end

#notify_on_failure(_plan) ⇒ Object



52
53
54
55
56
57
58
59
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 52

def notify_on_failure(_plan)
  notification = MailNotification[:proxy_sync_failure]
  proxy = SmartProxy.find(input.fetch(:smart_proxy, {})[:id])
  subjects = subjects(input[:options]).merge(smart_proxy: proxy)
  notification.users.with_enabled_email.each do |user|
    notification.deliver(subjects.merge(user: user, task: task))
  end
end

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 25

def plan(smart_proxy, options = {})
  input[:options] = options

  action_subject(smart_proxy)
  smart_proxy.verify_ueber_certs

  subjects = subjects(options)

  fail _("Action not allowed for the default smart proxy.") if smart_proxy.pulp_primary?

  refresh_options = options.merge(subjects)
  sequence do
    if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE)
      plan_action(Actions::Pulp3::ContentGuard::Refresh, smart_proxy)
    end
    plan_action(SyncCapsule, smart_proxy, refresh_options)
  end
  plan_self(smart_proxy_id: smart_proxy.id)
end

#resource_locksObject



7
8
9
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 7

def resource_locks
  :link
end

#subjects(options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/lib/actions/katello/capsule_content/sync.rb', line 61

def subjects(options = {})
  environment_id = options.fetch(:environment_id, nil)
  environment = ::Katello::KTEnvironment.find(environment_id) if environment_id

  repository_id = options.fetch(:repository_id, nil)
  repository = ::Katello::Repository.find(repository_id) if repository_id

  content_view_id = options.fetch(:content_view_id, nil)
  content_view = ::Katello::ContentView.find(content_view_id) if content_view_id

  {content_view: content_view, environment: environment, repository: repository}
end