From 571737618958791a4fa2559343e9201ce9c92c18 Mon Sep 17 00:00:00 2001 From: Piotr Kliczewski Date: Fri, 1 Sep 2017 16:31:14 +0200 Subject: [PATCH] save_vms_inventory needs to respect disconnect flag When we provision new vm we call `save_ems_inventory_no_disconnect` which updates the db with disconnect flag set to false. `save_vms_inventory` ignores the flag and disconnects the vms (ems set to nil). This patch fixes the issue. --- app/models/ems_refresh/save_inventory.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/ems_refresh/save_inventory.rb b/app/models/ems_refresh/save_inventory.rb index e147ccc1ed2..f3b0edb1aa7 100644 --- a/app/models/ems_refresh/save_inventory.rb +++ b/app/models/ems_refresh/save_inventory.rb @@ -36,9 +36,9 @@ def save_vms_inventory(ems, hashes, target = nil, disconnect = true) target = ems if target.nil? && disconnect log_header = "EMS: [#{ems.name}], id: [#{ems.id}]" - disconnects = if target.kind_of?(ExtManagementSystem) || target.kind_of?(Host) + disconnects = if disconnect && (target.kind_of?(ExtManagementSystem) || target.kind_of?(Host)) target.vms_and_templates.reload.to_a - elsif target.kind_of?(Vm) + elsif disconnect && target.kind_of?(Vm) [target.ruby_clone] else []