diff --git a/app/models/ems_cluster.rb b/app/models/ems_cluster.rb index b6913010bd0..7db3ecd3259 100644 --- a/app/models/ems_cluster.rb +++ b/app/models/ems_cluster.rb @@ -328,9 +328,14 @@ def register_host(host) end end - def self.node_types - return :non_openstack unless openstack_clusters_exists? - non_openstack_clusters_exists? ? :mixed_clusters : :openstack + cache_with_timeout(:node_types) do + if !openstack_clusters_exists? + :non_openstack + elsif non_openstack_clusters_exists? + :mixed_clusters + else + :openstack + end end def self.openstack_clusters_exists? diff --git a/app/models/host.rb b/app/models/host.rb index a1fcfff4d72..f029be6208f 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -1813,9 +1813,14 @@ def has_compliance_policies? !plist.blank? end - def self.node_types # TODO: This doesn't belong here - return :non_openstack unless openstack_hosts_exists? - non_openstack_hosts_exists? ? :mixed_hosts : :openstack + cache_with_timeout(:node_types) do # TODO: This doesn't belong here + if !openstack_hosts_exists? + :non_openstack + elsif non_openstack_hosts_exists? + :mixed_hosts + else + :openstack + end end def self.openstack_hosts_exists? # TODO: This doesn't belong here