Class: Actions::Katello::Product::Create

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

Instance Method Summary collapse

Instance Method Details

#finalizeObject



33
34
35
36
37
# File 'app/lib/actions/katello/product/create.rb', line 33

def finalize
  product = ::Katello::Product.find(input[:product][:id])
  product.cp_id = input[:cp_id]
  product.save!
end

#humanized_nameObject



39
40
41
# File 'app/lib/actions/katello/product/create.rb', line 39

def humanized_name
  _("Product Create")
end

#plan(product, organization) ⇒ Object



5
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
# File 'app/lib/actions/katello/product/create.rb', line 5

def plan(product, organization)
  sequence do
    product.provider = organization.anonymous_provider
    product.organization = organization

    cp_create = plan_action(::Actions::Candlepin::Product::Create,
                            :name => product.name,
                            :multiplier => 1,
                            :attributes => [{:name => "arch", :value => "ALL"}])

    cp_id = cp_create.output[:response][:id]

    sub_create = plan_action(::Actions::Candlepin::Product::CreateUnlimitedSubscription,
                :owner_key => organization.label,
                :product_id => cp_id)

    subscription_id = sub_create.output[:response][:id]

    plan_action(::Actions::Candlepin::Owner::RefreshSubscriptions,
                          :label => organization.label)
    product.save!
    action_subject product, :cp_id => cp_id

    plan_self
    plan_action Katello::Product::ReindexSubscriptions, product, subscription_id
  end
end