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

Check that the Embedded Ansible role is on #15045

Merged
merged 2 commits into from
May 10, 2017

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented May 9, 2017

  1. Raise an error if an attempt at raw_connect is made and the role is not enabled
  2. Continue on as normal with the raw_connect if the role is enabled

https://bugzilla.redhat.com/show_bug.cgi?id=1448186

@syncrou
Copy link
Contributor Author

syncrou commented May 9, 2017

@miq-bot add_label wip, bug

@miq-bot assign @gmcculloug

cc - @bdunne, @carbonin

@miq-bot miq-bot changed the title Check the Embedded Ansible role is on [WIP] Check the Embedded Ansible role is on May 9, 2017
@syncrou
Copy link
Contributor Author

syncrou commented May 9, 2017

@bdunne, @carbonin - Left this as a WIP to make sure I was taking the right path. Certainly wouldn't mind your thoughts.

Copy link
Member

@carbonin carbonin left a 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) }
Copy link
Member

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.

Copy link
Member

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) }
Copy link
Member

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.

@carbonin
Copy link
Member

carbonin commented May 9, 2017

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.

@syncrou syncrou force-pushed the override_embedded_provider_connection branch from 1d06e17 to f691103 Compare May 9, 2017 21:25
@syncrou
Copy link
Contributor Author

syncrou commented May 9, 2017

@miq-bot remove_label wip

@miq-bot miq-bot changed the title [WIP] Check the Embedded Ansible role is on Check the Embedded Ansible role is on May 9, 2017
@miq-bot miq-bot removed the wip label May 9, 2017
@syncrou syncrou force-pushed the override_embedded_provider_connection branch from f691103 to a8eb279 Compare May 9, 2017 21:33
@carbonin carbonin requested a review from bdunne May 9, 2017 21:44
@syncrou syncrou changed the title Check the Embedded Ansible role is on Check that the Embedded Ansible role is on May 9, 2017
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
@syncrou syncrou force-pushed the override_embedded_provider_connection branch from a8eb279 to 621a7ca Compare May 10, 2017 18:05
@gmcculloug
Copy link
Member

@carbonin Can you quickly review after updates to get tests passing?

Copy link
Member

@carbonin carbonin left a 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.

@@ -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
Copy link
Member

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?
Copy link
Member

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

@syncrou syncrou force-pushed the override_embedded_provider_connection branch from 621a7ca to 6b99c98 Compare May 10, 2017 19:00
@miq-bot
Copy link
Member

miq-bot commented May 10, 2017

Checked commits syncrou/manageiq@27dc7f8~...6b99c98 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
8 files checked, 0 offenses detected
Everything looks fine. 👍

Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@bdunne bdunne merged commit dcf61f4 into ManageIQ:master May 10, 2017
@bdunne bdunne added this to the Sprint 61 Ending May 22, 2017 milestone May 10, 2017
@syncrou syncrou deleted the override_embedded_provider_connection branch May 10, 2017 19:17
@syncrou
Copy link
Contributor Author

syncrou commented May 10, 2017

@miq-bot add_label blocker

simaishi pushed a commit that referenced this pull request May 10, 2017
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 262fb8c7c05eb692da6f6a127d3587e8b231b8e8
Author: Brandon Dunne <brandondunne@hotmail.com>
Date:   Wed May 10 15:16:20 2017 -0400

    Merge pull request #15045 from syncrou/override_embedded_provider_connection
    
    Check that the Embedded Ansible role is on
    (cherry picked from commit dcf61f46181adf1dacc1e5e3eff2af4aa4a88240)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1449846

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants