Skip to content

Commit

Permalink
Correctly pass UNDEFINE_NVRAM when flags isn't pased
Browse files Browse the repository at this point in the history
If destroy() is called with options that doesn't contain a flags value
then it should still default to UNDEFINE_NVRAM. That wasn't happening.

Fixes: 21d1bf8 ("Undefine NVRAM on vm destruction")
  • Loading branch information
ekohl committed Jul 12, 2024
1 parent 41781ed commit 46da4fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/fog/libvirt/models/compute/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ def disk_path

def destroy(options={ :destroy_volumes => false, :flags => ::Libvirt::Domain::UNDEFINE_NVRAM })
poweroff unless stopped?
if options.fetch(:flags, ::Libvirt::Domain::UNDEFINE_NVRAM).zero?
flags = options.fetch(:flags, ::Libvirt::Domain::UNDEFINE_NVRAM)
if flags.zero?
service.vm_action(uuid, :undefine)
else
service.vm_action(uuid, :undefine, options[:flags])
service.vm_action(uuid, :undefine, flags)
end
volumes.each { |vol| vol.destroy } if options[:destroy_volumes]
true
Expand Down

0 comments on commit 46da4fd

Please sign in to comment.