Skip to content

Commit

Permalink
F #6099: Implement non-shared vm skipping for ft/host_error.rb (#2583)
Browse files Browse the repository at this point in the history
  • Loading branch information
onenhansen authored Apr 21, 2023
1 parent 16035a1 commit 20c70e4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion share/hooks/ft/host_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 20c70e4

Please sign in to comment.