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

Add support for custom endpoint #274

Merged
merged 1 commit into from
Jul 20, 2018
Merged

Add support for custom endpoint #274

merged 1 commit into from
Jul 20, 2018

Conversation

djberg96
Copy link
Collaborator

@djberg96 djberg96 commented Jul 3, 2018

In order to support the Azure Stack environment we need to allow the users to set a custom endpoint since the default environments will not work. With the help of automatic discovery baked into the azure-armrest gem, we can support this fairly easily. If no endpoint is set then it simply defaults to finding the environment based on region as before.

Partially addresses https://bugzilla.redhat.com/show_bug.cgi?id=1594381

We will still need a modification on the UI side as well.

WIP for now until I add some specs.

@miq-bot miq-bot added the wip label Jul 3, 2018
expect(clientid).to eq("klmnopqrst")
expect(clientkey).to eq("1234567890")
expect(azure_tenant_id).to eq("abcdefghij")
expect(subscription).to eq("fghij67890")
Copy link

Choose a reason for hiding this comment

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

@djberg96 why are lines 111 through 114 repeated so many times in this spec?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bronaghs Just to make sure they weren't negatively affected. I can of course remove them if you feel they're redundant.

Copy link

Choose a reason for hiding this comment

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

I think they are, thanks.

@e.subscription = "fghij67890"
@e.endpoint = 'http://www.foo.bar'
@e.connect
end
Copy link

Choose a reason for hiding this comment

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

@djberg96 - how about a test for a valid endpoint with a path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, will add that.

@djberg96 djberg96 changed the title [WIP] Add support for custom endpoint Add support for custom endpoint Jul 5, 2018
@djberg96 djberg96 self-assigned this Jul 5, 2018
@djberg96
Copy link
Collaborator Author

djberg96 commented Jul 5, 2018

@bronaghs Ok, updated the specs, and even added a few more.

@miq-bot miq-bot removed the wip label Jul 5, 2018
Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

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

Looks great. 👍

@djberg96
Copy link
Collaborator Author

djberg96 commented Jul 9, 2018

@bronaghs @Ladas I actually want to undo some things first. It turns out there's already a default_endpoint method that will work for us, so this PR is a bit overworked atm.

@djberg96 djberg96 changed the title Add support for custom endpoint [WIP] Add support for custom endpoint Jul 9, 2018
@miq-bot miq-bot added the wip label Jul 9, 2018
@djberg96 djberg96 changed the title [WIP] Add support for custom endpoint Add support for custom endpoint Jul 9, 2018
@miq-bot miq-bot removed the wip label Jul 9, 2018
@@ -25,6 +26,18 @@ def raw_connect(client_id, client_key, azure_tenant_id, subscription, proxy_uri
$azure_log.warn("No region selected. Validating credentials against public environment.")
end

endpoint_url = endpoint.respond_to?(:url) ? endpoint.url : endpoint.to_s

Choose a reason for hiding this comment

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

endpoint.try(:url) || endpoint.to_s - maybe a little simpler

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, though I'm hoping ManageIQ/manageiq#17678 will get merged so I can just call to_s.

Choose a reason for hiding this comment

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

Ok, but if ManageIQ/manageiq#17678 doesn't end up getting merged, can you simplify this line?

environment = ::Azure::Armrest::Environment.discover(:url => endpoint_url, :proxy => proxy_uri)
rescue SocketError
raise MiqException::MiqInvalidCredentialsError, _("Invalid endpoint")
end

Choose a reason for hiding this comment

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

Is it always a credentials error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It basically means the endpoint is invalid, which I'm counting as "credentials" for our purposes. I actually couldn't find a better error, but I'm open to suggestions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe this should be switched to an MiqUnreachableError.

Choose a reason for hiding this comment

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

Agreed.

Added endpoint and endpoint= methods to CloudManager.

Updated connect and raw_connect which now assumes an Endpoint object, and verifies properly.

Alter environment error check, add a spec.

Added endpoint specs.

Added an endpoint with path spec, removed some unnecessary checks.

Added endpoint specs.

Re-raise a SocketError as an MiqUnreachableError.
@miq-bot
Copy link
Member

miq-bot commented Jul 16, 2018

Checked commit https://github.com/djberg96/manageiq-providers-azure/commit/52c102b79822ad773826e5fc291202ddc219072c with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@bronaghs bronaghs merged commit f32b42e into ManageIQ:master Jul 20, 2018
@bronaghs bronaghs added this to the Sprint 91 Ending Jul 30, 2018 milestone Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants