-
Notifications
You must be signed in to change notification settings - Fork 69
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
Added support for VM delete #184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
module ManageIQ::Providers::Vmware::CloudManager::Vm::Operations | ||
extend ActiveSupport::Concern | ||
|
||
include_concern 'Power' | ||
|
||
included do | ||
supports :terminate do | ||
unsupported_reason_add(:terminate, "The VM is powered on") unless current_state == "off" | ||
end | ||
end | ||
|
||
def raw_destroy | ||
raise "VM has no #{ui_lookup(:table => "ext_management_systems")}, unable to destroy VM" unless ext_management_system | ||
ext_management_system.with_provider_connection do |service| | ||
response = service.delete_vapp(ems_ref) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of checking for exceptions we are simply passing to the underlying provider connection. Looking at OpenStack and Amazon, this is exactly how these two are handled. In case an exception occurs it will be propagated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 perfect |
||
service.process_task(response.body) | ||
end | ||
update_attributes!(:raw_power_state => "off") | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agrare we have modified the code to resemble the behaviour of VCD. Now, it is not possible to delete a VM that is running (powered on). To this end we had to redefine the
supports_terminate?
by looking at thecurrent_state
of the VM.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I like that, we actually have a helper method for this that you can use, https://github.com/ManageIQ/manageiq/blob/master/app/models/vm/operations/power.rb#L22-L24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @agrare. I’ll make another PR to use this.