From 2adb6c33953c85c754b20473e320c799dc3ba3c1 Mon Sep 17 00:00:00 2001 From: "nasarak_786@hotmail.com" Date: Wed, 11 Oct 2023 15:23:40 -0400 Subject: [PATCH] separate vm store and datastore scan supports checks --- app/models/vm_scan/dispatcher.rb | 16 ++++------------ spec/models/vm_or_template_spec.rb | 4 +++- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/models/vm_scan/dispatcher.rb b/app/models/vm_scan/dispatcher.rb index 8f5ee293056..3d05719f0ee 100644 --- a/app/models/vm_scan/dispatcher.rb +++ b/app/models/vm_scan/dispatcher.rb @@ -246,18 +246,10 @@ def get_eligible_proxies_for_job(job) return [] end - if @vm.requires_storage_for_scan? - if @vm.storage.nil? - msg = "Vm [#{@vm.path}] is not located on a storage, aborting job [#{job.guid}]." - queue_signal(job, {:args => [:abort, msg, "error"]}) - return [] - else - unless @vm.storage.supports?(:smartstate_analysis) - msg = @vm.storage.unsupported_reason(:smartstate_analysis) - queue_signal(job, {:args => [:abort, msg, "error"]}) - return [] - end - end + unless @vm.supports?(:smartstate_analysis) + msg = @vm.unsupported_reason(:smartstate_analysis) + queue_signal(job, {:args => [:abort, msg, "error"]}) + return [] end vm_proxies, = Benchmark.realtime_block(:get_eligible_proxies_for_job__proxies4job) { @vm.proxies4job(job) } diff --git a/spec/models/vm_or_template_spec.rb b/spec/models/vm_or_template_spec.rb index 5a6485eefd2..a07823168fc 100644 --- a/spec/models/vm_or_template_spec.rb +++ b/spec/models/vm_or_template_spec.rb @@ -663,7 +663,9 @@ context "#supports?(:smartstate_analysis)" do it "returns true for VMware VM" do - vm = FactoryBot.create(:vm_vmware) + vm = FactoryBot.create(:vm_vmware, + :storage => storage) + allow(vm).to receive_messages(:archived? => false) allow(vm).to receive_messages(:orphaned? => false) expect(vm.supports?(:smartstate_analysis)).to eq(true)