Skip to content

Commit

Permalink
Add class method for OrchestrationStack refresh
Browse files Browse the repository at this point in the history
Add class method for OrchestrationStack refresh
  • Loading branch information
Ladas committed Sep 7, 2017
1 parent 0537cc8 commit 300deb4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/models/orchestration_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,32 @@ def raw_exists?
end

def refresh_ems
unless ext_management_system
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 ext_management_system.has_credentials?
unless manager.has_credentials?
raise _("No %{table} credentials defined") % {:table => ui_lookup(:table => "ext_management_systems")}
end
unless ext_management_system.authentication_status_ok?
unless manager.authentication_status_ok?
raise _("%{table} failed last authentication check") % {:table => ui_lookup(:table => "ext_management_systems")}
end

manager_settings = Settings.ems_refresh[ext_management_system.class.ems_type]
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 => ext_management_system,
orchestration_stack_target = ManagerRefresh::Target.new(:manager => manager,
:association => :orchestration_stacks,
:manager_ref => {:ems_ref => ems_ref})
:manager_ref => {:ems_ref => manager_ref})
EmsRefresh.queue_refresh(orchestration_stack_target)
else
# Otherwise queue a full refresh
EmsRefresh.queue_refresh(ext_management_system)
EmsRefresh.queue_refresh(manager)
end
end
end

0 comments on commit 300deb4

Please sign in to comment.