From 0537cc814633a669f33e1027adf951a8793463a8 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Tue, 5 Sep 2017 14:29:33 +0200 Subject: [PATCH 1/2] Add orchestration stack targeted refresh method Add orchestration stack targeted refresh method, that based on settings will perform targeted or full refresh. --- app/models/orchestration_stack.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/models/orchestration_stack.rb b/app/models/orchestration_stack.rb index aa5649d79be..b41359b9648 100644 --- a/app/models/orchestration_stack.rb +++ b/app/models/orchestration_stack.rb @@ -139,4 +139,28 @@ def raw_exists? rescue MiqException::MiqOrchestrationStackNotExistError false end + + def refresh_ems + unless ext_management_system + raise _("No %{table} defined") % {:table => ui_lookup(:table => "ext_management_systems")} + end + unless ext_management_system.has_credentials? + raise _("No %{table} credentials defined") % {:table => ui_lookup(:table => "ext_management_systems")} + end + unless ext_management_system.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] + 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, + :association => :orchestration_stacks, + :manager_ref => {:ems_ref => ems_ref}) + EmsRefresh.queue_refresh(orchestration_stack_target) + else + # Otherwise queue a full refresh + EmsRefresh.queue_refresh(ext_management_system) + end + end end From 300deb4c9aa3f7d35401f4a61fee980921142490 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Thu, 7 Sep 2017 14:17:11 +0200 Subject: [PATCH 2/2] Add class method for OrchestrationStack refresh Add class method for OrchestrationStack refresh --- app/models/orchestration_stack.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/orchestration_stack.rb b/app/models/orchestration_stack.rb index b41359b9648..d381aeead8a 100644 --- a/app/models/orchestration_stack.rb +++ b/app/models/orchestration_stack.rb @@ -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