-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting timeout value for REST calls
Fix #183
- Loading branch information
1 parent
fc26a6a
commit 670e815
Showing
22 changed files
with
173 additions
and
32 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
source/lib/vagrant-openstack-provider/action/connect_openstack.rb
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/openstack' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/http_utils' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
module VagrantPlugins | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/http_utils' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/http_utils' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/http_utils' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
require 'vagrant-openstack-provider/client/heat' | ||
|
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'log4r' | ||
require 'restclient' | ||
require 'json' | ||
|
||
module VagrantPlugins | ||
|
25 changes: 25 additions & 0 deletions
25
source/lib/vagrant-openstack-provider/client/rest_utils.rb
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,25 @@ | ||
require 'restclient' | ||
|
||
module VagrantPlugins | ||
module Openstack | ||
module RestUtils | ||
def self.get(env, url, headers = {}, &block) | ||
config = env[:machine].provider_config | ||
RestClient::Request.execute(method: :get, url: url, headers: headers, | ||
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, &block) | ||
end | ||
|
||
def self.post(env, url, payload, headers = {}, &block) | ||
config = env[:machine].provider_config | ||
RestClient::Request.execute(method: :post, url: url, payload: payload, headers: headers, | ||
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, &block) | ||
end | ||
|
||
def self.delete(env, url, headers = {}, &block) | ||
config = env[:machine].provider_config | ||
RestClient::Request.execute(method: :delete, url: url, headers: headers, | ||
timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, &block) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module VagrantPlugins | ||
module Openstack | ||
class HttpConfig | ||
UNSET_VALUE = Vagrant.plugin('2', :config).const_get(:UNSET_VALUE) | ||
|
||
# | ||
# @return [Integer] | ||
attr_accessor :open_timeout | ||
|
||
# | ||
# @return [Integer] | ||
attr_accessor :read_timeout | ||
|
||
def initialize | ||
@open_timeout = UNSET_VALUE | ||
@read_timeout = UNSET_VALUE | ||
end | ||
|
||
def finalize! | ||
@open_timeout = 60 if @open_timeout == UNSET_VALUE | ||
@read_timeout = 30 if @read_timeout == UNSET_VALUE | ||
end | ||
|
||
def merge(other) | ||
result = self.class.new | ||
|
||
[self, other].each do |obj| | ||
obj.instance_variables.each do |key| | ||
next if key.to_s.start_with?('@__') | ||
|
||
value = obj.instance_variable_get(key) | ||
result.instance_variable_set(key, value) if value != UNSET_VALUE | ||
end | ||
end | ||
result | ||
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
Oops, something went wrong.