Skip to content

Commit

Permalink
Merge pull request #15936 from Ladas/add_targeted_refresh_to_orchestr…
Browse files Browse the repository at this point in the history
…ation_stack

Add orchestration stack targeted refresh method
  • Loading branch information
agrare committed Sep 7, 2017
2 parents fcf0d0c + 300deb4 commit aadb3e0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/models/orchestration_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,34 @@ def raw_exists?
rescue MiqException::MiqOrchestrationStackNotExistError
false
end

def refresh_ems
self.class.refresh_ems(ext_management_system.id, ems_ref)
end

def self.refresh_ems(manager_id, manager_ref)
manager = ExtManagementSystem.find_by(:id => manager_id)

unless manager
raise _("No %{table} defined") % {:table => ui_lookup(:table => "ext_management_systems")}
end
unless manager.has_credentials?
raise _("No %{table} credentials defined") % {:table => ui_lookup(:table => "ext_management_systems")}
end
unless manager.authentication_status_ok?
raise _("%{table} failed last authentication check") % {:table => ui_lookup(:table => "ext_management_systems")}
end

manager_settings = Settings.ems_refresh[manager.class.ems_type]
if manager_settings[:inventory_object_refresh] && manager_settings[:allow_targeted_refresh]
# Queue new targeted refresh if allowed
orchestration_stack_target = ManagerRefresh::Target.new(:manager => manager,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => manager_ref})
EmsRefresh.queue_refresh(orchestration_stack_target)
else
# Otherwise queue a full refresh
EmsRefresh.queue_refresh(manager)
end
end
end

0 comments on commit aadb3e0

Please sign in to comment.