-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from ggiamarchi/issue#37
Fix #37 - Avoid multiple 'connect_openstack'
- Loading branch information
Showing
13 changed files
with
302 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/keystone' | ||
|
||
module VagrantPlugins | ||
module Openstack | ||
module Utils | ||
def handle_response(response) | ||
case response.code | ||
when 200, 201, 202, 204 | ||
response | ||
when 401 | ||
fail Errors::AuthenticationRequired | ||
when 400 | ||
fail Errors::VagrantOpenstackError, message: JSON.parse(response.to_s)['badRequest']['message'] | ||
else | ||
fail Errors::VagrantOpenstackError, message: response.to_s | ||
end | ||
end | ||
|
||
def authenticated(env) | ||
nb_retry = 0 | ||
begin | ||
return yield | ||
rescue Errors::AuthenticationRequired => e | ||
nb_retry += 1 | ||
env[:ui].warn(e) | ||
env[:ui].warn(I18n.t('vagrant_openstack.trying_authentication')) | ||
env[:openstack_client].keystone.authenticate(env) | ||
retry if nb_retry < 3 | ||
raise e | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.