Class: Actions::Katello::Repository::Create

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

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



59
60
61
# File 'app/lib/actions/katello/repository/create.rb', line 59

def humanized_name
  _("Create")
end

#plan(repository, args = {}) ⇒ Object

rubocop:disable Metrics/MethodLength



6
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
42
43
44
45
46
47
# File 'app/lib/actions/katello/repository/create.rb', line 6

def plan(repository, args = {})
  clone = args[:clone] || false
  force_repo_create = args[:force_repo_create] || false
  repository.save!
  root = repository.root

  action_subject(repository)

  org = repository.organization
  sequence do
    create_action = plan_action(Pulp3::Orchestration::Repository::Create,
                                repository, SmartProxy.pulp_primary, force_repo_create)

    return if create_action.error

    # when creating a clone, the following actions are handled by the
    # publish/promote process
    unless clone
      view_env = org.default_content_view.content_view_environment(org.library)
      if repository.product.redhat?
        plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => repository.content_id)
      else
        unless root.content
          content_create = plan_action(Katello::Product::ContentCreate, root)
          plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => content_create.input[:content_id])
        end
      end
    end

    concurrence do
      plan_self(:repository_id => repository.id, :clone => clone)
      if !clone && repository.url.present?
        repository.product.alternate_content_sources.with_type(repository.content_type).each do |acs|
          acs.smart_proxies.each do |smart_proxy|
            smart_proxy_acs = ::Katello::SmartProxyAlternateContentSource.create(alternate_content_source_id: acs.id, smart_proxy_id: smart_proxy.id, repository_id: repository.id)
            plan_action(Pulp3::Orchestration::AlternateContentSource::Create, smart_proxy_acs)
          end
        end
      end
    end
  end
end

#runObject



49
50
51
52
53
54
55
56
57
# File 'app/lib/actions/katello/repository/create.rb', line 49

def run
  ::User.current = ::User.anonymous_api_admin
  unless input[:clone]
    repository = ::Katello::Repository.find(input[:repository_id])
    ForemanTasks.async_task(Katello::Repository::MetadataGenerate, repository)
  end
ensure
  ::User.current = nil
end