Class: Actions::Katello::Repository::RemoveContent

Inherits:
EntryAction
  • Object
show all
Includes:
Dynflow::Action::WithSubPlans
Defined in:
app/lib/actions/katello/repository/remove_content.rb

Instance Method Summary collapse

Instance Method Details

#create_sub_plansObject



43
44
45
46
# File 'app/lib/actions/katello/repository/remove_content.rb', line 43

def create_sub_plans
  trigger(Actions::Katello::Repository::MetadataGenerate,
          ::Katello::Repository.find(input[:repository][:id]), :force_publication => true)
end

#finalizeObject



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

def finalize
  if (input[:content_unit_class] && input[:content_unit_ids])
    content_units = input[:content_unit_class].constantize.where(:id => input[:content_unit_ids])
    content_units.each do |content_unit|
      content_unit.remove_from_repository(input[:repository][:id])
    end
  end
end

#humanized_nameObject



61
62
63
# File 'app/lib/actions/katello/repository/remove_content.rb', line 61

def humanized_name
  _("Remove Content")
end

#plan(repository, content_units, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/lib/actions/katello/repository/remove_content.rb', line 7

def plan(repository, content_units, options = {})
  sync_capsule = options.fetch(:sync_capsule, true)
  if repository.redhat?
    fail _("Cannot remove content from a non-custom repository")
  end
  unless repository.content_view.default?
    fail _("Can only remove content from within the Default Content View")
  end

  action_subject(repository)

  content_unit_ids = content_units.map(&:id)
  if repository.generic?
    content_unit_type = options[:content_type] || content_units.first.content_type
  else
    content_unit_type = options[:content_type] || content_units.first.class::CONTENT_TYPE
  end
  ::Katello::RepositoryTypeManager.check_content_matches_repo_type!(repository, content_unit_type)

  generate_applicability = options.fetch(:generate_applicability, repository.yum?)

  sequence do
    remove_content_args = {
      :contents => content_unit_ids,
      :content_unit_type => content_unit_type}
    repository.clear_smart_proxy_sync_histories
    pulp_action = plan_action(
      Pulp3::Orchestration::Repository::RemoveUnits,
      repository, SmartProxy.pulp_primary, remove_content_args)
    return if pulp_action.error
    plan_self(:content_unit_class => content_units.first.class.name, :content_unit_ids => content_unit_ids)
    plan_action(CapsuleSync, repository) if sync_capsule
    plan_action(Actions::Katello::Applicability::Repository::Regenerate, :repo_ids => [repository.id]) if generate_applicability
  end
end

#resource_locksObject



48
49
50
# File 'app/lib/actions/katello/repository/remove_content.rb', line 48

def resource_locks
  :link
end