From d911eaee29126a92d3e4bbd68b397ce3b6021652 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 10 Mar 2017 16:23:56 +0100 Subject: [PATCH 1/4] manager_refresh_targets needs to be public manager_refresh_targets needs to be public --- app/models/ems_event.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/ems_event.rb b/app/models/ems_event.rb index 96219c5c8a5..c9b59e57775 100644 --- a/app/models/ems_event.rb +++ b/app/models/ems_event.rb @@ -222,6 +222,10 @@ def tenant_identity (vm_or_template || ext_management_system).tenant_identity end + def manager_refresh_targets + ext_management_system.class::EventTargetParser.new(self).parse + end + private def self.create_event(event) @@ -324,8 +328,4 @@ def ems_cluster_refresh_target def ems_refresh_target ext_management_system end - - def manager_refresh_targets - ext_management_system.class::EventTargetParser.new(self).parse - end end From 3ef4cca2834761e36459d31249f49b88fa87199e Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 10 Mar 2017 16:24:23 +0100 Subject: [PATCH 2/4] Changed format of queued_refresh Changed format of queued_refresh --- app/models/ems_event/automate.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/ems_event/automate.rb b/app/models/ems_event/automate.rb index b8209181e8c..dcf6353279f 100644 --- a/app/models/ems_event/automate.rb +++ b/app/models/ems_event/automate.rb @@ -7,7 +7,7 @@ def graph_refresh(sync: false) return if refresh_targets.empty? - EmsRefresh.queue_refresh(refresh_targets, nil, sync) + EmsRefresh.queue_refresh(refresh_targets, nil, :create_task => sync) end def refresh(*targets, sync) From 2abefbde46385ffe14740a4571176c8531881f08 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 10 Mar 2017 16:26:02 +0100 Subject: [PATCH 3/4] Change graph_refresh to manager_refresh Change graph_refresh to manager_refresh --- app/models/ems_event/automate.rb | 2 +- .../engine/miq_ae_engine/miq_ae_builtin_method.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/ems_event/automate.rb b/app/models/ems_event/automate.rb index dcf6353279f..d00e7c1d34b 100644 --- a/app/models/ems_event/automate.rb +++ b/app/models/ems_event/automate.rb @@ -2,7 +2,7 @@ class EmsEvent module Automate extend ActiveSupport::Concern - def graph_refresh(sync: false) + def manager_refresh(sync: false) refresh_targets = manager_refresh_targets return if refresh_targets.empty? diff --git a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb index 7d3e2634602..e8bb807a31b 100644 --- a/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb +++ b/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_builtin_method.rb @@ -106,11 +106,11 @@ def self.miq_host_and_storage_least_utilized(obj, _inputs) end def self.miq_refresh(obj, _inputs) - event_object_from_workspace(obj).graph_refresh(:sync => false) + event_object_from_workspace(obj).manager_refresh(:sync => false) end def self.miq_refresh_sync(obj, _inputs) - event_object_from_workspace(obj).graph_refresh(:sync => true) + event_object_from_workspace(obj).manager_refresh(:sync => true) end def self.miq_event_action_refresh(obj, inputs) From b847cf4b7a5ed008f435d57e7716d20e87b2dd42 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Fri, 10 Mar 2017 16:44:55 +0100 Subject: [PATCH 4/4] A spec for queuing of ManagerRefresh::Target A spec for queuing of ManagerRefresh::Target --- spec/models/ems_refresh_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/models/ems_refresh_spec.rb b/spec/models/ems_refresh_spec.rb index f41053e020a..26cb2193620 100644 --- a/spec/models/ems_refresh_spec.rb +++ b/spec/models/ems_refresh_spec.rb @@ -10,6 +10,17 @@ queue_refresh_and_assert_queue_item(target, [target]) end + it "with ManagerRefresh::Target" do + target = ManagerRefresh::Target.load( + :manager_id => @ems.id, + :association => :vms, + :manager_ref => {:ems_ref => "vm_1"}, + :options => {:opt1 => "opt1", :opt2 => "opt2"} + ) + + queue_refresh_and_assert_queue_item(target, [target]) + end + it "with Host" do target = FactoryGirl.create(:host_vmware, :ext_management_system => @ems) queue_refresh_and_assert_queue_item(target, [target])