Skip to content

Commit

Permalink
Merge pull request #14272 from Ladas/small_extentions_to_queued_manag…
Browse files Browse the repository at this point in the history
…er_refresh

Small extentions to queued manager refresh
  • Loading branch information
agrare authored Mar 10, 2017
2 parents 7d7fe08 + b847cf4 commit 150dc58
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/models/ems_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions app/models/ems_event/automate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ 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?

EmsRefresh.queue_refresh(refresh_targets, nil, sync)
EmsRefresh.queue_refresh(refresh_targets, nil, :create_task => sync)
end

def refresh(*targets, sync)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions spec/models/ems_refresh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 150dc58

Please sign in to comment.