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

#create_content?(repository, clone) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
73
74
# File 'app/lib/actions/katello/repository/create.rb', line 66

def create_content?(repository, clone)
  if repository.deb_using_structured_apt?
    return true
  elsif clone || repository.content
    return false
  else
    return true
  end
end

#humanized_nameObject



62
63
64
# File 'app/lib/actions/katello/repository/create.rb', line 62

def humanized_name
  _("Create")
end

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

rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



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
48
49
50
# 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!

  action_subject(repository)

  sequence do
    # Container push repositories will already be in pulp. The version_href is
    # directly updated after a push.
    unless repository.root.is_container_push && repository.in_default_view?
      create_action = plan_action(Pulp3::Orchestration::Repository::Create,
                                  repository, SmartProxy.pulp_primary, force_repo_create)
      return if create_action.error
    end

    content_id = false
    if !clone && repository.product.redhat?
      content_id = repository.content_id
    elsif create_content?(repository, clone)
      content_create = plan_action(Katello::Product::ContentCreate, repository)
      content_id = content_create.input[:content_id]
    end

    if !clone && content_id
      view_env = repository.organization.default_content_view.content_view_environment(repository.organization.library)
      plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => content_id)
    end

    # Container push repos do not need metadata generation or ACS (they do not sync)
    unless repository.root.is_container_push && repository.in_default_view?
      concurrence do
        plan_self(:repository_id => repository.id, :clone => clone)
        if !clone && repository.url.present? && !repository.url.start_with?('uln')
          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
end

#runObject



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

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