HewlettPackard / oneview-sdk-ruby

This project is no longer being developed and has limited support. In the near future this repository will be fully deprecated. Please consider using other OneView projects, such as Golang and Python.
Apache License 2.0
12 stars 16 forks source link

REST methods should handle redirects #145

Closed jsmartt closed 7 years ago

jsmartt commented 7 years ago

Scenario/Intent

The REST methods should handle redirects. One issue I've already run into is that for Synergy Enclsoures, trying to get the script (enc.script) gives a 301 error message saying it has moved to a LogicalEnclosure uri.

I think we could implements something pretty similar to this, where we only follow redirects up to 3 or 5 times.

Because we need the data to re-submit the request, we'll need to handle this in the rest_api method, not response_handler.

Environment Details

Steps to Reproduce

With a client using api_version 300 as @client, talking to a v300 DCS...

@client.api_version = 300
OneviewSDK.api_version = 300
OneviewSDK::API300.variant = 'Synergy'

e = @client.get_all(:Enclosures).first
e.script

Expected Result

It to be able to get the script (following any redirects needed to get there)

Actual Result

I get this error:

OneviewSDK::RequestError: 301
from /usr/local/rvm/gems/ruby-2.2.4/gems/oneview-sdk-3.1.0/lib/oneview-sdk/rest.rb:162:in `response_handler'
jsmartt commented 7 years ago

@tmiotto , @ricardogpsf , @aalexmonteiro , @fgbulsoni or @piantola , do any of you have any concerns with this, or shall I implement it?

tmiotto commented 7 years ago

@jsmartt I have one concern that is to avoid being eternally redirected, maybe we should have a limit for it, or timeout.

By the way, I'm okay with you implementing it.

jsmartt commented 7 years ago

@tmiotto , correct. We'd definitely have to set a limit

ricardogpsf commented 7 years ago

@jsmartt I'm okay too with the idea of implementation.