-
Notifications
You must be signed in to change notification settings - Fork 897
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
Fail with descriptive message when no EMS #15807
Fail with descriptive message when no EMS #15807
Conversation
@gmcculloug please review |
app/models/miq_provision_request.rb
Outdated
@@ -29,6 +29,10 @@ def self.request_task_class_from(attribs) | |||
vm_or_template = VmOrTemplate.find_by(:id => source_id) | |||
raise MiqException::MiqProvisionError, "Unable to find source Template/Vm with id [#{source_id}]" if vm_or_template.nil? | |||
|
|||
if vm_or_template.ext_management_system.nil? |
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.
I think I would like this better if we pulled both checks (line 30 and line 32) into a single method. Since we check for both a template
and with this change an ems
it makes sense to consolidate the code that in either case can raise
the same exception.
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.
I've extracted it into a method to retrieve the vm/template or raise an exception if failed to.
7e599b6
to
a0dcf2a
Compare
app/models/miq_provision_request.rb
Outdated
|
||
via = MiqRequestMixin.get_option(:provision_type, nil, attribs['options']) | ||
vm_or_template.ext_management_system.class.provision_class(via) | ||
end | ||
|
||
def self.fetch_vm_or_template_for_provision!(source_id) |
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.
Suggest renaming to self.source_vm_or_template!
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.
done
When no EMS is associated with a VM or template, the provision request fails with a non-descriptive message. Such case might happen when the VM or template were removed from the provider side, but still exist as archived on vmdb. The purpose of the PR is to provide a clear failure message when there is no EMS. https://bugzilla.redhat.com/show_bug.cgi?id=1471124
a0dcf2a
to
92ed48a
Compare
Checked commit masayag@92ed48a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
👍 LGTM
…o_ems Fail with descriptive message when no EMS (cherry picked from commit fa24dff) https://bugzilla.redhat.com/show_bug.cgi?id=1481845
Fine backport details:
|
…te_has_no_ems Fail with descriptive message when no EMS (cherry picked from commit fa24dff) https://bugzilla.redhat.com/show_bug.cgi?id=1481845
When no EMS is associated with a VM or template, the provision request
fails with a non-descriptive message. Such case might happen when the VM
or template were removed from the provider side, but still exist as
archived on vmdb. The purpose of the PR is to provide a clear failure
message when there is no EMS.
https://bugzilla.redhat.com/show_bug.cgi?id=1471124