Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flags option to server.destroy #102

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ SignalException:
Description: 'Do not enforce use of fail when raising exceptions.'
# Valid values are: semantic, only_raise and only_fail
EnforcedStyle: only_raise

Metrics/ClassLength:
Enabled: false
8 changes: 6 additions & 2 deletions lib/fog/libvirt/models/compute/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ def disk_path
volumes.first.path if volumes and volumes.first
end

def destroy(options={ :destroy_volumes => false})
def destroy(options={ :destroy_volumes => false, :flags => 0 })
poweroff unless stopped?
service.vm_action(uuid, :undefine)
if options[:flags].zero?
service.vm_action(uuid, :undefine)
else
service.vm_action(uuid, :undefine, options[:flags])
end
volumes.each { |vol| vol.destroy } if options[:destroy_volumes]
true
end
Expand Down
6 changes: 3 additions & 3 deletions lib/fog/libvirt/requests/compute/vm_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ module Fog
module Libvirt
class Compute
class Real
def vm_action(uuid, action)
def vm_action(uuid, action, *params)
domain = client.lookup_domain_by_uuid(uuid)
domain.send(action)
domain.send(action, *params)
true
end
end

class Mock
def vm_action(uuid, action)
def vm_action(uuid, action, *params)
true
end
end
Expand Down