Sha256: 13915b847abf1aa762e84c0293f385463601b2a41ebb43408f605c5f85eb2fb5

Contents?: true

Size: 1.5 KB

Versions: 88

Compression:

Stored size: 1.5 KB

Contents

module Katello
  module UINotifications
    module Pulp
      class ProxyDiskSpace
        class << self
          def deliver!
            SmartProxy.unscoped.with_content.each do |proxy|
              percentage = proxy.pulp_disk_usage[0]['percentage']
              if percentage < 90 && notification_already_exists?(proxy)
                blueprint.notifications.where(subject: proxy).destroy_all
              elsif update_notifications(proxy).empty? && percentage > 90
                ::Notification.create!(
                  :subject => proxy,
                  :initiator => User.anonymous_admin,
                  :audience => Notification::AUDIENCE_ADMIN,
                  :message => ::UINotifications::StringParser.new(
                    blueprint.message,
                    :subject => proxy,
                    :percentage => percentage
                  ),
                  :notification_blueprint => blueprint
                )
              end
            end
          end

          def notification_already_exists?(subject)
            blueprint.notifications.where(:subject => subject).any?
          end

          def update_notifications(subject)
            notifs = blueprint.notifications
            notifs.where(subject: subject).update_all(expired_at: blueprint.expired_at)
            notifs
          end

          def blueprint
            @blueprint ||= NotificationBlueprint.unscoped.find_by(
              :name => 'pulp_low_disk_space')
          end
        end
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
katello-4.14.2 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.15.0 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.15.0.rc2 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.15.0.rc1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.0 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.0.rc3 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.0.rc2 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.0.rc1.1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.14.0.rc1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.13.1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.13.0 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.12.1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.13.0.rc1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.12.0 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.12.0.rc3 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.12.0.rc2 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.12.0.rc1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.11.1 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb
katello-4.11.0 app/services/katello/ui_notifications/pulp/proxy_disk_space.rb