-
Notifications
You must be signed in to change notification settings - Fork 898
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
Check that the Embedded Ansible role is on #15045
Check that the Embedded Ansible role is on #15045
Conversation
@miq-bot add_label wip, bug @miq-bot assign @gmcculloug |
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.
A few spec suggestions.
@@ -35,5 +35,17 @@ | |||
end | |||
end | |||
end | |||
|
|||
context "Embedded Ansible role" do | |||
let(:miq_server) { FactoryGirl.create(:miq_server) } |
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.
let
is lazy evaluated so this won't actually get run.
I think a better option would be to do this in a before
and actually set up the role on that server for the success case.
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.
Then you can get rid of the allow(described_class)
as well.
@@ -3,15 +3,18 @@ | |||
shared_examples_for "ansible provider" do | |||
describe "#connect" do | |||
let(:attrs) { {:username => "admin", :password => "smartvm", :verify_ssl => OpenSSL::SSL::VERIFY_PEER} } | |||
let(:miq_server) { FactoryGirl.create(:miq_server) } |
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.
These changes are embedded specific, so I feel like they belong in the embedded provider spec rather than in the shared examples.
Yeah, sorry I just jumped in when I saw the notification @syncrou This is what we talked about so the implementation looks good to me. I just had spec comments. |
1d06e17
to
f691103
Compare
@miq-bot remove_label wip |
f691103
to
a8eb279
Compare
1. Raise an error if an attempt at raw_connect is made if the role is not enabled 2. Continue on as normal with the connect if the role is enabled https://bugzilla.redhat.com/show_bug.cgi?id=1448186
a8eb279
to
621a7ca
Compare
@carbonin Can you quickly review after updates to get tests passing? |
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.
Yup, I'm still okay with this.
spec/support/evm_spec_helper.rb
Outdated
@@ -21,6 +21,12 @@ def self.vmware_nested_folders(ems) | |||
end | |||
end | |||
|
|||
def self.assign_embedded_ansible_role(server = nil) | |||
miq_server = server.nil? ? local_miq_server : server |
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.
could simplify to miq_server = server || local_miq_server
or
def self.assign_embedded_ansible_role(miq_server = nil)
miq_server ||= local_miq_server
...
@@ -8,4 +8,14 @@ class ManageIQ::Providers::EmbeddedAnsible::Provider < ::Provider | |||
:class_name => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager", | |||
:dependent => :destroy, | |||
:autosave => true | |||
|
|||
def self.raw_connect(base_url, username, password, verify_ssl) | |||
raise StandardError, 'Embedded ansible is disabled' unless role_enabled? |
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.
Maybe prefer the positive case?
def self.raw_connect(base_url, username, password, verify_ssl)
return super if role_enabled?
raise...
end
621a7ca
to
6b99c98
Compare
Checked commits syncrou/manageiq@27dc7f8~...6b99c98 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
@miq-bot add_label blocker |
…nection Check that the Embedded Ansible role is on (cherry picked from commit dcf61f4) https://bugzilla.redhat.com/show_bug.cgi?id=1449846
Fine backport details:
|
raw_connect
is made and the role is not enabledraw_connect
if the role is enabledhttps://bugzilla.redhat.com/show_bug.cgi?id=1448186