From 7f46472fc80c2127025e576a32bb44953cd0514e Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Wed, 26 Aug 2020 11:44:34 -0400 Subject: [PATCH] Remove hardcoded types in favor of a supports feature check Part of #19440 --- .../manageiq/providers/cloud_manager/template.rb | 10 ---------- .../manageiq/providers/infra_manager/template.rb | 7 ------- app/models/miq_template.rb | 3 ++- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/app/models/manageiq/providers/cloud_manager/template.rb b/app/models/manageiq/providers/cloud_manager/template.rb index 36975c9342c0..31ced4f4667f 100644 --- a/app/models/manageiq/providers/cloud_manager/template.rb +++ b/app/models/manageiq/providers/cloud_manager/template.rb @@ -11,16 +11,6 @@ def snapshot? !genealogy_parent.nil? end - def self.eligible_for_provisioning - super.where(:type => %w(ManageIQ::Providers::Amazon::CloudManager::Template - ManageIQ::Providers::Azure::CloudManager::Template - ManageIQ::Providers::Google::CloudManager::Template - ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::Template - ManageIQ::Providers::Openstack::CloudManager::Template - ManageIQ::Providers::Openstack::CloudManager::VolumeTemplate - ManageIQ::Providers::Openstack::CloudManager::VolumeSnapshotTemplate)) - end - def self.class_by_ems(ext_management_system) ext_management_system.class::Template end diff --git a/app/models/manageiq/providers/infra_manager/template.rb b/app/models/manageiq/providers/infra_manager/template.rb index 10c2f89a5b69..c8bf8e9a0df4 100644 --- a/app/models/manageiq/providers/infra_manager/template.rb +++ b/app/models/manageiq/providers/infra_manager/template.rb @@ -1,13 +1,6 @@ class ManageIQ::Providers::InfraManager::Template < MiqTemplate default_value_for :cloud, false - def self.eligible_for_provisioning - super.where(:type => %w(ManageIQ::Providers::Redhat::InfraManager::Template - ManageIQ::Providers::Vmware::InfraManager::Template - ManageIQ::Providers::Microsoft::InfraManager::Template - ManageIQ::Providers::Kubevirt::InfraManager::Template)) - end - def self.display_name(number = 1) n_('Template', 'Templates', number) end diff --git a/app/models/miq_template.rb b/app/models/miq_template.rb index 0fc4d94e18e8..a3e06096461a 100644 --- a/app/models/miq_template.rb +++ b/app/models/miq_template.rb @@ -35,7 +35,8 @@ def self.supports_kickstart_provisioning? delegate :supports_kickstart_provisioning?, :to => :class def self.eligible_for_provisioning - where(arel_table[:ems_id].not_eq(nil)) + types = descendants.select(&:supports_provisioning?) + where(:type => types).where.not(:ems_id => nil) end def self.without_volume_templates