Class: Actions::Katello::Product::ContentCreate

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/katello/product/content_create.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/lib/actions/katello/product/content_create.rb', line 45

def finalize
  root = ::Katello::RootRepository.find(input[:root_repository_id])
  content_url = root.custom_content_path
  if root.deb?
    repository = ::Katello::Repository.find(input[:repository_id])
    content_url += repository.deb_content_url_options
    repository.update(:content_id => input[:content_id])
  else
    root.update(:content_id => input[:content_id])
  end

  content = ::Katello::Content.where(organization_id: root.product.organization_id, cp_content_id: input[:content_id]).first_or_create do |new_content|
    new_content.name = root.name
    new_content.content_type = root.content_type
    new_content.label = root.
    new_content.content_url = content_url
    new_content.vendor = ::Katello::Provider::CUSTOM
  end

  # custom product content is always disabled by default
  ::Katello::ProductContent.where(product: root.product, content: content).first_or_create do |pc|
    pc.enabled = false
  end
end

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

def plan(repository)
  root = repository.root
  sequence do
    if repository.content_id.nil?
      content_create = plan_action(Candlepin::Product::ContentCreate,
                                   repository_id: repository.id,
                                   owner:         root.organization.label,
                                   name:          root.name,
                                   type:          root.content_type,
                                   arches:        root.format_arches,
                                   label:         root.,
                                   content_url:   root.custom_content_path,
                                   os_versions:   root.os_versions&.join(','))
      content_id = content_create.output[:response][:id]
      plan_action(Candlepin::Product::ContentAdd, owner: root.product.organization.label,
                            product_id: root.product.cp_id,
                            content_id: content_id)

    else
      content_id = repository.content_id
    end

    plan_self(root_repository_id: root.id, repository_id: repository.id, content_id: content_id)

    if root.gpg_key
      plan_action(Candlepin::Product::ContentUpdate,
                  repository_id: repository.id,
                  owner:         root.organization.label,
                  name:          root.name,
                  type:          root.content_type,
                  arches:        root.format_arches,
                  label:         root.,
                  content_url:   root.custom_content_path,
                  gpg_key_url:   root.library_instance.yum_gpg_key_url)
    end
  end
end