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



64
65
66
# File 'app/lib/actions/katello/repository/create.rb', line 64

def humanized_name
  _("Create")
end

#plan(repository, clone = false, plan_create = false) ⇒ Object

rubocop:disable 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
48
49
50
51
52
# File 'app/lib/actions/katello/repository/create.rb', line 6

def plan(repository, clone = false, plan_create = false)
  repository.save!
  action_subject(repository)

  org = repository.organization
  path = repository.relative_path unless repository.puppet?

  create_action = plan_create ? Actions::Pulp::Repository::CreateInPlan : Actions::Pulp::Repository::Create
  sequence do
    certs = repository.importer_ssl_options
    create_action = plan_action(create_action,
                                content_type: repository.content_type,
                                pulp_id: repository.pulp_id,
                                name: repository.name,
                                docker_upstream_name: repository.docker_upstream_name,
                                feed: repository.url,
                                ssl_ca_cert: certs[:ssl_ca_cert],
                                ssl_client_cert: certs[:ssl_client_cert],
                                ssl_client_key: certs[:ssl_client_key],
                                unprotected: repository.unprotected,
                                checksum_type: repository.checksum_type,
                                path: path,
                                download_policy: repository.download_policy,
                                with_importer: true,
                                mirror_on_sync: repository.mirror_on_sync?)

    return if create_action.error

    # when creating a clone, the following actions are handled by the
    # publish/promote process
    unless clone
      if repository.product.redhat?
        plan_action(ContentView::UpdateEnvironment, org.default_content_view,
                    org.library, repository.content_id)
      else
        content_create = plan_action(Katello::Product::ContentCreate, repository)
        plan_action(ContentView::UpdateEnvironment, org.default_content_view,
                    org.library, content_create.input[:content_id])
      end
    end

    concurrence do
      plan_action(::Actions::Pulp::Repos::Update, repository.product) if repository.product.sync_plan
      plan_self(:repository_id => repository.id, :clone => clone)
    end
  end
end

#runObject



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

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