Sha256: 0d53d73853f11dedbdd99c39f8b147eb6323aad8d3727f5cb6103c17cef30f00

Contents?: true

Size: 1.71 KB

Versions: 39

Compression:

Stored size: 1.71 KB

Contents

module Actions
  module Katello
    module Repository
      # Clones the contnet of the repository into the environment
      # effectively promotion the repository to the environment
      class CloneToEnvironment < Actions::Base
        include Actions::Katello::PulpSelector
        def plan(repository, environment)
          clone = find_or_build_environment_clone(repository, environment)

          sequence do
            if clone.new_record?
              plan_action(Repository::Create, clone, true, false)
            else
              #only clear if it should be empty, but its not
              plan_optional_pulp_action([Actions::Pulp::Repository::Clear], clone, SmartProxy.pulp_primary)
              # Do we need to refresh distributors here?
              plan_optional_pulp_action([Actions::Pulp::Orchestration::Repository::RefreshIfNeeded], clone, SmartProxy.pulp_primary)
            end

            plan_action(::Actions::Katello::Repository::CloneContents, [repository], clone, :copy_contents => !clone.yum?)
          end
        end

        # The environment clone clone of the repository is the one
        # visible for the systems in the environment
        def find_or_build_environment_clone(repository, environment)
          version = repository.content_view_version
          clone = version.content_view.get_repo_clone(environment, repository).first

          if clone
            clone = ::Katello::Repository.find(clone.id) # reload readonly object
            clone.update!(content_view_version_id: version.id)
          else
            clone = repository.build_clone(environment: environment, content_view: version.content_view)
          end
          return clone
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
katello-4.0.3 app/lib/actions/katello/repository/clone_to_environment.rb
katello-3.18.5 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.2.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.2.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.2 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.2 app/lib/actions/katello/repository/clone_to_environment.rb
katello-3.18.4 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.1.2 app/lib/actions/katello/repository/clone_to_environment.rb
katello-3.18.3.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0.rc2.2 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0.rc2.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.1.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-3.18.3 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0.rc2 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0.rc1.1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.1.0.rc1 app/lib/actions/katello/repository/clone_to_environment.rb
katello-4.0.0 app/lib/actions/katello/repository/clone_to_environment.rb