-
Notifications
You must be signed in to change notification settings - Fork 900
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
Move snapshot code to Vm in service model. #12726
Conversation
@lfu You are now exposing these methods on every VM/Template which is not valid in a lot of cases. Before it was only exposed on VMs from automate and I think we should keep it at that level, just move it into the base VM service model. Also, we should raise an error for providers where we do not support snapshot features with a "Feature not supported" error message. @durandom I see there is a For example, VMware supports |
d417398
to
6738731
Compare
end | ||
|
||
def snapshot_operation(task, options = {}) | ||
options.merge!(:ids => [id], :task => task.to_s) |
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.
This does not provide any feedback to the caller if snapshots are not supported on the provider. Since we are moving from a specific provider implementation to a generic VM one we should add a call at the top of this method to raise an error if not supported.
LIke this (also address rubocop issues):
def snapshot_operation(task, options = {})
raise "#{task} operation not supported for #{self.class.name}" unless @object.supports_snapshots?
options[:ids] = [id]
options[:task] = task.to_s
Vm.process_tasks(options)
end
6738731
to
6054eba
Compare
I guess we would have to add all operations as features and then ask the Vm if it supports that operation. So far I only see snapshot features for openstack cloud_volumes and rh vms. ❯ git --no-pager grep -E 'supports(_not)? :.*snapshot'
app/models/manageiq/providers/openstack/cloud_manager/cloud_volume.rb: supports :snapshot_create
app/models/manageiq/providers/redhat/infra_manager/vm/operations/snapshot.rb: supports :snapshots do |
@lfu Please review failing tests |
6054eba
to
e98295c
Compare
@miq-bot add_label automate, bug, euwe/yes |
The snapshot code in automate was moved from VmOrTemplate to VMware specific class by PR ManageIQ#3707 when VMware was the only class that supports snapshot. But snapshot support has been added to RHEVM and Openstack as of version Euwe. The snapshot code in automate should be available at Vm level. https://bugzilla.redhat.com/show_bug.cgi?id=1395175
e98295c
to
3569ecf
Compare
Checked commit lfu@3569ecf with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 lib/miq_automation_engine/service_models/miq_ae_service_vm.rb
spec/lib/miq_automation_engine/service_methods/miq_ae_service_manageiq-providers-vmware-infra_manager-vm_spec.rb
|
Thanks @durandom. That seems outside of the scope of this PR so I am going to merge this and we can look into adding individual snapshot method checks later. |
Move snapshot code to Vm in service model. (cherry picked from commit eef6493) https://bugzilla.redhat.com/show_bug.cgi?id=1399207
Euwe backport details:
|
The snapshot code in automate was moved from VmOrTemplate to VMware specific class by PR #3707 when VMware was the only class that supported snapshot.
But snapshot support has been added to RHEVM and Openstack as of version Euwe.
The snapshot code in automate should be made available at Vm level.
Links
https://bugzilla.redhat.com/show_bug.cgi?id=1395175
cc @gmcculloug @mkanoor