Class: Katello::HostAvailableModuleStream
- Defined in:
- app/models/katello/host_available_module_stream.rb
Constant Summary collapse
- ENABLED =
"enabled".freeze
- DISABLED =
"disabled".freeze
- UNKNOWN =
"unknown".freeze
- INSTALLED =
"installed".freeze
- UPGRADABLE =
"upgradable".freeze
- STATUS =
[ENABLED, DISABLED, UNKNOWN].freeze
- API_STATES =
{ ENABLED => :enabled, DISABLED => :disabled, UNKNOWN => :unknown, INSTALLED => :installed, UPGRADABLE => :upgradable }.with_indifferent_access
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Model
Class Method Details
.installed_status(status, host) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/katello/host_available_module_stream.rb', line 51 def self.installed_status(status, host) case status when 'not installed' where(installed_profiles: []) when 'upgradable' where(id: upgradable(host).pluck(:id)) when 'up to date' where(status: 'enabled').where.not(installed_profiles: []).where.not(id: upgradable(host).pluck(:id)) end end |
.upgradable(host) ⇒ Object
62 63 64 65 66 67 |
# File 'app/models/katello/host_available_module_stream.rb', line 62 def self.upgradable(host) upgradable_module_name_streams = ModuleStream.installable_for_hosts([host]).select(:name, :stream) enabled.joins(:available_module_stream).where(:host_id => host). where("(#{AvailableModuleStream.table_name}.name, #{AvailableModuleStream.table_name}.stream) in (#{upgradable_module_name_streams.to_sql})") end |
Instance Method Details
#install_status ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/models/katello/host_available_module_stream.rb', line 41 def install_status return 'Not installed' if installed_profiles.blank? case status when 'disabled' 'Installed' when 'enabled' upgradable? ? 'Upgradable' : 'Up-to-date' end end |
#upgradable? ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'app/models/katello/host_available_module_stream.rb', line 33 def upgradable? return false if status != ENABLED ModuleStream.installable_for_hosts([host_id]). where(ModuleStream.table_name => {:name => available_module_stream.name, :stream => available_module_stream.stream}).exists? end |