Skip to content

Instantly share code, notes, and snippets.

@jeremylenz
Last active January 20, 2021 20:57
Show Gist options
  • Save jeremylenz/4f5d0b6c33bbdb3082d4587de2c34b64 to your computer and use it in GitHub Desktop.
Save jeremylenz/4f5d0b6c33bbdb3082d4587de2c34b64 to your computer and use it in GitHub Desktop.
# make a new product from an existing custom product
# and attach an existing pool
def make_new_product(product, pool, ak)
new_prod = product.dup
new_prod.name += ' ' + SecureRandom.uuid
new_prod.label = new_prod.name.gsub(/ /, '_').gsub(/[()]/, '_')
new_prod.save!
new_prod.pools << pool
# ak.products << new_prod
# ak.subscribe(pool.cp_id)
new_prod
end
ak = Katello::ActivationKey.find_by(name: 'My Activation Key')
product = Katello::Product.find_by(name: "My Product")
pool = product.pools.first
5.times do
make_new_product(product, pool, ak)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment