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

raw_connect method for infra provider #15914

Merged
merged 1 commit into from
Sep 13, 2017
Merged

raw_connect method for infra provider #15914

merged 1 commit into from
Sep 13, 2017

Conversation

jntullo
Copy link

@jntullo jntullo commented Aug 31, 2017

Adding a raw_connect class method for the Vmware Infra Provider that will validate the credentials. Ensuring reuse of existing code while not changing current functionality

related: ManageIQ/manageiq-providers-vmware#104

Rationale for needing raw_connect method can be found: ManageIQ/manageiq-ui-classic#1580 (will be working on similar update for infra and container providers)

@miq-bot add_label wip, providers, enhancement

@jntullo jntullo changed the title [WIP] raw_connect method for infra provider raw_connect method for infra provider Sep 5, 2017
@miq-bot miq-bot removed the wip label Sep 5, 2017
@@ -42,4 +41,38 @@ def with_provider_connection(options = {})
vim.try(:disconnect) rescue nil
end
end

module ClassMethods
def make_connection(options)
Copy link
Member

@Fryguy Fryguy Sep 8, 2017

Choose a reason for hiding this comment

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

Should this be a private method? EDIT: nvm I didn't see it used at the end of connect

end
end

def raw_connect(options)
Copy link
Member

Choose a reason for hiding this comment

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

raw_connect for the other providers typically does not verify the connection. It's purpose is closer to your make_connection method. connect and validate are usually implemented by calling raw_connect to get the native handle.

@Fryguy
Copy link
Member

Fryguy commented Sep 8, 2017

@agrare Aside, doesn't this mixin belong in manageiq-providers-vmware?

@agrare
Copy link
Member

agrare commented Sep 8, 2017

Aside, doesn't this mixin belong in manageiq-providers-vmware?

Yes it is on my list of things to move, it is used by Host here still

@agrare
Copy link
Member

agrare commented Sep 8, 2017

@jntullo not sure but I think verify_credentials is what you want to use, that is what is used by authentication_check for all the provider types.

@jntullo
Copy link
Author

jntullo commented Sep 8, 2017

@agrare @Fryguy I have been ensuring other raw connects do the validations - you can see all of the related PRs / explanation here: ManageIQ/manageiq-ui-classic#1580

@agrare
Copy link
Member

agrare commented Sep 8, 2017

@jntullo maybe it'd be better to add a class level verify_credentials so we don't mix validation and raw_connect?

@jntullo
Copy link
Author

jntullo commented Sep 8, 2017

@agrare not a bad idea, however I have already made my rounds through almost every provider to get this validation on the queue moving. Would it be okay to do a follow up to change it to a verify_credentials?

@Fryguy
Copy link
Member

Fryguy commented Sep 8, 2017

I agree with @agrare . raw_connect was always the lowest level way to get a handle as a pure function (so just pass args, and get a handle), and as such it's useful for diagnostic purposes from rails console for example. I see validation as a layer above that, so it should a separate method that uses raw_connect, IMO.

@Fryguy
Copy link
Member

Fryguy commented Sep 8, 2017

I would be ok with followups if it's going to be a pain to "undo" the changes in a number of places, but I'll leave it up to @agrare

@jntullo
Copy link
Author

jntullo commented Sep 8, 2017

if this whole validation on the queue didn't already involve > 15 PRs I would have no problem with this change :)

@agrare
Copy link
Member

agrare commented Sep 8, 2017

I'm okay with a temporary solution but can you leave the existing #connect method the way it is?

We do some specific exception handling in the VMware code to handle re-connects and I don't want the validate exception handlers messing with the exceptions being raised.

options[:user] ||= authentication_userid(options[:auth_type])
options[:pass] ||= authentication_password(options[:auth_type])

self.class.make_connection(options)
Copy link
Member

Choose a reason for hiding this comment

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

So lets leave this the way it currently is, we'll have two similar code paths for connect but when you do your followup to split raw_connect and validate we can move this over to raw_connect

do not change the connect method
@miq-bot
Copy link
Member

miq-bot commented Sep 11, 2017

Checked commit jntullo@e5a29e8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
1 file checked, 11 offenses detected

app/models/mixins/vim_connect_mixin.rb

if options[:fault_tolerant]
MiqFaultTolerantVim.new(options)
else
MiqVim.new(options[:ip], options[:user],options[:pass])
Copy link
Member

Choose a reason for hiding this comment

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

Can you fix the missing space after the comma here in a follow-up PR?

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@agrare
Copy link
Member

agrare commented Sep 13, 2017

@jntullo is ManageIQ/manageiq-providers-vmware#104 ready to be merged after this is in?

@jntullo
Copy link
Author

jntullo commented Sep 13, 2017

@agrare yup it will be! thanks! 👍

@agrare agrare merged commit 480b70e into ManageIQ:master Sep 13, 2017
@agrare agrare added this to the Sprint 69 Ending Sep 18, 2017 milestone Sep 13, 2017
@chrisarcand chrisarcand deleted the vmware_raw_connect branch November 28, 2017 19:29
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.

4 participants