From 20c70e49851653974686faa215762718493dc3ae Mon Sep 17 00:00:00 2001 From: Neal <92747003+onenhansen@users.noreply.github.com> Date: Fri, 21 Apr 2023 02:45:52 -0600 Subject: [PATCH] F #6099: Implement non-shared vm skipping for ft/host_error.rb (#2583) --- share/hooks/ft/host_error.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/share/hooks/ft/host_error.rb b/share/hooks/ft/host_error.rb index 322ba81f3d3..2637c3fe4ea 100755 --- a/share/hooks/ft/host_error.rb +++ b/share/hooks/ft/host_error.rb @@ -122,7 +122,7 @@ def states_xpath(*arr) mode = nil # **must** be set to something other than nil using the options force = false # By default, don't recreate/delete suspended and poweroff VMs -repeat = 2 # By default, wait for 2 monitorization cycles +repeat = 2 # By default, wait for 2 monitorization cycles fencing = true opts = GetoptLong.new( @@ -248,6 +248,13 @@ def states_xpath(*arr) exit_error "Could not get vm pool" end +ds_pool = OpenNebula::DatastorePool.new(client) +rc = ds_pool.info_all + +if OpenNebula.is_error?(rc) + exit_error "Could not get datastore pool" +end + # STATE=3: ACTIVE (LCM unknown) # STATE=5: SUSPENDED # STATE=8: POWEROFF @@ -283,6 +290,21 @@ def states_xpath(*arr) log "delete #{vm_id}" vm.delete when :migrate + begin + vm_ds_id = vm.retrieve_elements('/VM/HISTORY_RECORDS/HISTORY[last()]/DS_ID')[0] + + ds_xpath = "/DATASTORE_POOL/DATASTORE[ID=\"#{vm_ds_id}\"]/TEMPLATE/SHARED" + is_shared = ds_pool.retrieve_elements(ds_xpath)[0] + + if is_shared.upcase == "NO" + log "Skipping VM #{vm_id} deployed on non-shared datastore" + next + end + rescue + log_error "Could not get Datastore ID or SHARED attribute for VM #{vm_id}" + next + end + log "resched #{vm_id}" vm.resched else