Sha256: 0028fa738813c2aee67c1d1b4eda9998ff9651e334f34a4f1b9311e1fe4cd843

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

module Actions
  module Katello
    module Repository
      class Create < Actions::EntryAction
        def plan(repository, clone = false, plan_create = false)
          repository.save!
          root = repository.root

          action_subject(repository)

          org = repository.organization
          create_action = plan_create ? Actions::Pulp::Repository::CreateInPlan : Actions::Pulp::Repository::Create
          sequence do
            create_action = plan_action(create_action, repository)

            return if create_action.error

            # when creating a clone, the following actions are handled by the
            # publish/promote process
            unless clone
              view_env = org.default_content_view.content_view_environment(org.library)
              if repository.product.redhat?
                plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => repository.content_id)
              else
                content_create = plan_action(Katello::Product::ContentCreate, root)
                plan_action(Actions::Candlepin::Environment::AddContentToEnvironment, :view_env_cp_id => view_env.cp_id, :content_id => content_create.input[:content_id])
              end
            end

            concurrence do
              plan_self(:repository_id => repository.id, :clone => clone)
            end
          end
        end

        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

        def humanized_name
          _("Create")
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
katello-3.11.2 app/lib/actions/katello/repository/create.rb
katello-3.11.1 app/lib/actions/katello/repository/create.rb
katello-3.11.0 app/lib/actions/katello/repository/create.rb
katello-3.11.0.rc2 app/lib/actions/katello/repository/create.rb
katello-3.11.0.rc1 app/lib/actions/katello/repository/create.rb