Sha256: f7718d9cffa1a536172013308d0edc9fdee000a880c83bad6f6feb9dd39f656e

Contents?: true

Size: 1.99 KB

Versions: 20

Compression:

Stored size: 1.99 KB

Contents

module Actions
  module Katello
    module Repository
      class Create < Actions::EntryAction
        include Actions::Katello::PulpSelector

        def plan(repository, clone = false, plan_create = false)
          repository.save!
          root = repository.root

          action_subject(repository)

          org = repository.organization
          pulp2_create_action = plan_create ? Actions::Pulp::Repository::CreateInPlan : Actions::Pulp::Repository::Create
          sequence do
            create_action = plan_pulp_action([pulp2_create_action, Pulp3::Orchestration::Repository::Create],
                                        repository, SmartProxy.pulp_primary)

            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

20 entries across 20 versions & 1 rubygems

Version Path
katello-4.0.3 app/lib/actions/katello/repository/create.rb
katello-4.0.2.1 app/lib/actions/katello/repository/create.rb
katello-4.1.2.1 app/lib/actions/katello/repository/create.rb
katello-4.0.2 app/lib/actions/katello/repository/create.rb
katello-4.1.2 app/lib/actions/katello/repository/create.rb
katello-4.1.1 app/lib/actions/katello/repository/create.rb
katello-4.1.0 app/lib/actions/katello/repository/create.rb
katello-4.0.1.2 app/lib/actions/katello/repository/create.rb
katello-4.1.0.rc2.2 app/lib/actions/katello/repository/create.rb
katello-4.1.0.rc2.1 app/lib/actions/katello/repository/create.rb
katello-4.0.1.1 app/lib/actions/katello/repository/create.rb
katello-4.1.0.rc2 app/lib/actions/katello/repository/create.rb
katello-4.0.1 app/lib/actions/katello/repository/create.rb
katello-4.1.0.rc1.1 app/lib/actions/katello/repository/create.rb
katello-4.1.0.rc1 app/lib/actions/katello/repository/create.rb
katello-4.0.0 app/lib/actions/katello/repository/create.rb
katello-4.0.0.rc3.1 app/lib/actions/katello/repository/create.rb
katello-4.0.0.rc3 app/lib/actions/katello/repository/create.rb
katello-4.0.0.rc2 app/lib/actions/katello/repository/create.rb
katello-4.0.0.rc1 app/lib/actions/katello/repository/create.rb