Sha256: 1039c3051b8bbb552a2033cca9cd97fb922fe8ef336eec7b7b59f82e97b72c9e

Contents?: true

Size: 877 Bytes

Versions: 158

Compression:

Stored size: 877 Bytes

Contents

module Actions
  module Foreman
    module Environment
      class Destroy < Actions::Base
        def plan(environment)
          if environment.hosts.count > 0
            names = environment.hosts.limit(5).pluck(:name).join(', ')
            fail _("The puppet environment %{name} is in use by %{count} Host(s) including %{names}") %
                     {:name => environment.name, :names => names, :count => environment.hosts.count}
          end

          if environment.hostgroups.count > 0
            names = environment.hostgroups.limit(5).pluck(:name).join(', ')
            fail _("The puppet environment %{name} is in use by %{count} Host Group(s) including %{names}") %
                     {:name => environment.name, :names => names, :count => environment.hostgroups.count}
          end

          environment.destroy!
        end
      end
    end
  end
end

Version data entries

158 entries across 158 versions & 1 rubygems

Version Path
katello-4.0.3 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.5 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.2.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.2 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.4 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.1.2 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.3.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.1.1 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.3 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.0 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.0.rc3.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.0.rc3 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.2.1 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.2 app/lib/actions/foreman/environment/destroy.rb
katello-3.17.3 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.0.rc2 app/lib/actions/foreman/environment/destroy.rb
katello-3.18.1.1 app/lib/actions/foreman/environment/destroy.rb
katello-3.17.2 app/lib/actions/foreman/environment/destroy.rb
katello-4.0.0.rc1 app/lib/actions/foreman/environment/destroy.rb