Sha256: 0869d8c0b228ca29fcec83ed9a9143abaf8a01d6467c0dd8e137147ebb6f79bd

Contents?: true

Size: 863 Bytes

Versions: 11

Compression:

Stored size: 863 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 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 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

11 entries across 11 versions & 1 rubygems

Version Path
katello-4.1.4 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.3 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.2.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.2 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0.rc2.2 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0.rc2.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0.rc2 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0.rc1.1 app/lib/actions/foreman/environment/destroy.rb
katello-4.1.0.rc1 app/lib/actions/foreman/environment/destroy.rb