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

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

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



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

def humanized_name
  _("Remove Content")
end

#plan(repository, content_units) ⇒ 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
# File 'app/lib/actions/katello/repository/remove_content.rb', line 7

def plan(repository, content_units)
  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)

  pulp_action = case repository.content_type
                when ::Katello::Repository::YUM_TYPE
                  Pulp::Repository::RemoveRpm
                when ::Katello::Repository::PUPPET_TYPE
                  Pulp::Repository::RemovePuppetModule
                when ::Katello::Repository::DOCKER_TYPE
                  Pulp::Repository::RemoveDockerManifest
                end

  uuids = content_units.map(&:uuid)
  repository.remove_content(content_units)

  sequence do
    plan_action(pulp_action, :pulp_id => repository.pulp_id,
                             :clauses => {:association => {'unit_id' => {'$in' => uuids}}
    })

    plan_self(:repository_id => repository.id, :user_id => ::User.current.id)
  end
end

#resource_locksObject



38
39
40
# File 'app/lib/actions/katello/repository/remove_content.rb', line 38

def resource_locks
  :link
end

#runObject



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

def run
  output[:task_id] = ForemanTasks.async_task(Actions::Katello::Repository::MetadataGenerate,
                                             ::Katello::Repository.find(input['repository_id'])).id
end