Sha256: e3849941e4a2ac12e01ae2f4af74fed1505c7227f9da98cd9be593b733995b82

Contents?: true

Size: 972 Bytes

Versions: 9

Compression:

Stored size: 972 Bytes

Contents

module Actions
  module Candlepin
    module Product
      class Create < Candlepin::Abstract
        input_format do
          param :name, String
          param :multiplier
          param :attributes
          param :owner
        end

        def run
          output[:response] = ::Katello::Resources::Candlepin::Product.create(input[:owner], :name => input[:name],
                                                                              :id => unused_product_id,
                                                                              :multiplier => input[:multiplier],
                                                                              :attributes => input[:attributes])
        end

        def unused_product_id
          id = SecureRandom.random_number(999_999_999_999)
          if ::Katello::Product.find_by(:cp_id => id)
            unused_product_id
          else
            id
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-3.4.5 app/lib/actions/candlepin/product/create.rb
katello-3.4.4 app/lib/actions/candlepin/product/create.rb
katello-3.4.2 app/lib/actions/candlepin/product/create.rb
katello-3.4.1 app/lib/actions/candlepin/product/create.rb
katello-3.4.0.2 app/lib/actions/candlepin/product/create.rb
katello-3.4.0.1 app/lib/actions/candlepin/product/create.rb
katello-3.4.0 app/lib/actions/candlepin/product/create.rb
katello-3.4.0.rc2 app/lib/actions/candlepin/product/create.rb
katello-3.4.0.rc1 app/lib/actions/candlepin/product/create.rb